Removing caching from STSTokenLoginModule
package org.apache.cxf.ws.security.trust;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
import java.security.Principal;
import java.util.Collections;
@@ -46,7 +45,6 @@ import org.apache.cxf.Bus;
import org.apache.cxf.BusException;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.security.SimplePrincipal;
import org.apache.cxf.endpoint.EndpointException;
@@ -57,10 +55,6 @@ import org.apache.cxf.rt.security.claims.ClaimCollection;
import org.apache.cxf.rt.security.saml.utils.SAMLUtils;
import org.apache.cxf.rt.security.utils.SecurityUtils;
import org.apache.cxf.ws.security.SecurityConstants;
-import org.apache.cxf.ws.security.tokenstore.EHCacheTokenStore;
-import org.apache.cxf.ws.security.tokenstore.TokenStore;
-import org.apache.cxf.ws.security.tokenstore.TokenStoreException;
-import org.apache.cxf.ws.security.tokenstore.TokenStoreFactory;
import org.apache.cxf.ws.security.trust.claims.RoleClaimsCallbackHandler;
import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
import org.apache.wss4j.common.WSS4JConstants;
@@ -147,7 +141,6 @@ public class STSLoginModule implements LoginModule {
public static final String CXF_SPRING_CFG = "cxf.spring.config";
private static final Logger LOG = LogUtils.getL7dLogger(STSLoginModule.class);
- private static final String TOKEN_STORE_KEY = "sts.login.module.tokenstore";
private Set<Principal> roles = new HashSet<>();
private Principal userPrincipal;
@@ -165,16 +158,11 @@ public class STSLoginModule implements LoginModule {
private String tokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0";
private String namespace;
private Map<String, Object> stsClientProperties = new HashMap<>();
- private final TokenStore tokenStore;
/** the authentication status*/
private boolean succeeded;
private boolean commitSucceeded;
- public STSLoginModule() throws MalformedURLException, TokenStoreException {
- tokenStore = configureTokenStore();
- }
-
@Override
public void initialize(Subject subj, CallbackHandler cbHandler, Map<String, ?> sharedState,
Map<String, ?> options) {
@@ -269,7 +257,6 @@ public class STSLoginModule implements LoginModule {
data.setMsgContext(message);
} else {
validator.setStsClient(stsClient);
- validator.setTokenStore(tokenStore);
}
credential = validator.validate(credential, data);
@@ -336,18 +323,6 @@ public class STSLoginModule implements LoginModule {
return c;
}
- private TokenStore configureTokenStore() throws MalformedURLException, TokenStoreException {
- if (TokenStoreFactory.isEhCacheInstalled()) {
- String cfg = "cxf-ehcache.xml";
- URL url = ClassLoaderUtils.getResource(cfg, STSLoginModule.class);
- if (url == null) {
- url = new URL(cfg);
- }
- return new EHCacheTokenStore(TOKEN_STORE_KEY, BusFactory.getDefaultBus(), url);
- }
- return null;
- }
-
private UsernameToken convertToToken(String username, String password)
throws Exception {
