Author: giger
Date: Sun Apr 8 19:59:19 2012
New Revision: 1311077
URL: http://svn.apache.org/viewvc?rev=1311077&view=rev
Log:
Cache SecurityTokenFactory
Modified:
webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/EncryptedKeyInputHandler.java
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractDecryptInputProcessor.java
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractSignatureInputHandler.java
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java
Modified:
webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/EncryptedKeyInputHandler.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/EncryptedKeyInputHandler.java?rev=1311077&r1=1311076&r2=1311077&view=diff
==============================================================================
---
webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/EncryptedKeyInputHandler.java
(original)
+++
webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/EncryptedKeyInputHandler.java
Sun Apr 8 19:59:19 2012
@@ -25,12 +25,12 @@ import org.swssf.binding.xmldsig.KeyInfo
import org.swssf.binding.xmlenc.EncryptedKeyType;
import org.swssf.wss.ext.*;
import org.swssf.wss.impl.securityToken.AbstractSecurityToken;
-import org.swssf.wss.impl.securityToken.SecurityTokenFactoryImpl;
import org.swssf.wss.securityEvent.EncryptedKeyTokenSecurityEvent;
import org.swssf.wss.securityEvent.TokenSecurityEvent;
import org.swssf.xmlsec.config.JCEAlgorithmMapper;
import org.swssf.xmlsec.crypto.Crypto;
import org.swssf.xmlsec.ext.*;
+import org.swssf.xmlsec.impl.securityToken.SecurityTokenFactory;
import org.xmlsecurity.ns.configuration.AlgorithmType;
import javax.crypto.BadPaddingException;
@@ -123,7 +123,7 @@ public class EncryptedKeyInputHandler ex
return this.wrappingSecurityToken;
}
KeyInfoType keyInfoType =
encryptedKeyType.getKeyInfo();
- this.wrappingSecurityToken =
SecurityTokenFactoryImpl.newInstance().getSecurityToken(
+ this.wrappingSecurityToken =
SecurityTokenFactory.getInstance().getSecurityToken(
keyInfoType,
crypto,
securityProperties.getCallbackHandler(),
Modified:
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractDecryptInputProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractDecryptInputProcessor.java?rev=1311077&r1=1311076&r2=1311077&view=diff
==============================================================================
---
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractDecryptInputProcessor.java
(original)
+++
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractDecryptInputProcessor.java
Sun Apr 8 19:59:19 2012
@@ -238,7 +238,7 @@ public abstract class AbstractDecryptInp
final String algorithmURI =
encryptedDataType.getEncryptionMethod().getAlgorithm();
//retrieve the securityToken which must be used for decryption
- SecurityToken securityToken =
SecurityTokenFactory.newInstance().getSecurityToken(
+ SecurityToken securityToken =
SecurityTokenFactory.getInstance().getSecurityToken(
keyInfoType,
getSecurityProperties().getDecryptionCrypto(),
getSecurityProperties().getCallbackHandler(),
inputProcessorChain.getSecurityContext());
Modified:
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractSignatureInputHandler.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractSignatureInputHandler.java?rev=1311077&r1=1311076&r2=1311077&view=diff
==============================================================================
---
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractSignatureInputHandler.java
(original)
+++
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/processor/input/AbstractSignatureInputHandler.java
Sun Apr 8 19:59:19 2012
@@ -152,7 +152,7 @@ public abstract class AbstractSignatureI
this.signatureType = signatureType;
KeyInfoType keyInfoType = signatureType.getKeyInfo();
- SecurityToken securityToken =
SecurityTokenFactory.newInstance().getSecurityToken(keyInfoType,
+ SecurityToken securityToken =
SecurityTokenFactory.getInstance().getSecurityToken(keyInfoType,
securityProperties.getSignatureVerificationCrypto(),
securityProperties.getCallbackHandler(),
securityContext);
securityToken.verify();
Modified:
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java?rev=1311077&r1=1311076&r2=1311077&view=diff
==============================================================================
---
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java
(original)
+++
webservices/wss4j/branches/swssf/streaming-xml-security/src/main/java/org/swssf/xmlsec/impl/securityToken/SecurityTokenFactory.java
Sun Apr 8 19:59:19 2012
@@ -35,25 +35,28 @@ import javax.security.auth.callback.Call
*/
public abstract class SecurityTokenFactory {
- //todo caching?
- public static SecurityTokenFactory newInstance() throws
XMLSecurityException {
+ private static SecurityTokenFactory securityTokenFactory = null;
- String stf =
ConfigurationProperties.getProperty("securityTokenFactory");
- if (stf == null) {
- throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory");
- }
+ public static synchronized SecurityTokenFactory getInstance() throws
XMLSecurityException {
+ if (securityTokenFactory == null) {
+ String stf =
ConfigurationProperties.getProperty("securityTokenFactory");
+ if (stf == null) {
+ throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory");
+ }
- try {
- @SuppressWarnings("unchecked")
- Class<SecurityTokenFactory> securityTokenFactoryClass =
(Class<SecurityTokenFactory>)
SecurityTokenFactory.class.getClassLoader().loadClass(stf);
- return securityTokenFactoryClass.newInstance();
- } catch (ClassNotFoundException e) {
- throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory", e);
- } catch (InstantiationException e) {
- throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory", e);
- } catch (IllegalAccessException e) {
- throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory", e);
+ try {
+ @SuppressWarnings("unchecked")
+ Class<SecurityTokenFactory> securityTokenFactoryClass =
(Class<SecurityTokenFactory>)
SecurityTokenFactory.class.getClassLoader().loadClass(stf);
+ securityTokenFactory = securityTokenFactoryClass.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory", e);
+ } catch (InstantiationException e) {
+ throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory", e);
+ } catch (IllegalAccessException e) {
+ throw new
XMLSecurityException(XMLSecurityException.ErrorCode.INVALID_SECURITY,
"missingSecurityTokenFactory", e);
+ }
}
+ return securityTokenFactory;
}
public abstract SecurityToken getSecurityToken(KeyInfoType keyInfoType,
Crypto crypto,