You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by gi...@apache.org on 2011/10/11 20:03:15 UTC
svn commit: r1181995 [5/26] - in /webservices/wss4j/branches/swssf: ./
cxf-integration/ cxf-integration/src/main/java/org/swssf/cxfIntegration/
cxf-integration/src/main/java/org/swssf/cxfIntegration/interceptor/
cxf-integration/src/main/java/org/swssf/...
Copied: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSSecurityProperties.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityProperties.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSSecurityProperties.java?p2=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSSecurityProperties.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityProperties.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityProperties.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSSecurityProperties.java Tue Oct 11 18:03:00 2011
@@ -16,17 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.ext;
+package org.swssf.wss.ext;
-import org.swssf.crypto.Crypto;
-import org.swssf.crypto.CryptoBase;
-
-import javax.security.auth.callback.CallbackHandler;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.cert.X509Certificate;
-import java.util.LinkedList;
-import java.util.List;
+import org.swssf.xmlsec.ext.XMLSecurityProperties;
/**
* Main configuration class to supply keys etc.
@@ -36,292 +28,17 @@ import java.util.List;
* @author $Author$
* @version $Revision$ $Date$
*/
-public class SecurityProperties {
-
- private List<InputProcessor> inputProcessorList = new LinkedList<InputProcessor>();
-
- /**
- * Add an additional, non standard, InputProcessor to the chain
- *
- * @param inputProcessor The InputProcessor to add
- */
- public void addInputProcessor(InputProcessor inputProcessor) {
- this.inputProcessorList.add(inputProcessor);
- }
-
- /**
- * Returns the currently registered additional InputProcessors
- *
- * @return the List with the InputProcessors
- */
- public List<InputProcessor> getInputProcessorList() {
- return inputProcessorList;
- }
-
- private Class<? extends CryptoBase> decryptionCryptoClass;
- private KeyStore decryptionKeyStore;
- private CallbackHandler callbackHandler;
-
- /**
- * Returns the decryption keystore
- *
- * @return A keystore for decryption operation
- */
- public KeyStore getDecryptionKeyStore() {
- return decryptionKeyStore;
- }
-
- /**
- * loads a java keystore from the given url for decrypt operations
- *
- * @param url The URL to the keystore
- * @param keyStorePassword The keyStorePassword
- * @throws Exception thrown if something goes wrong while loading the keystore
- */
- public void loadDecryptionKeystore(URL url, char[] keyStorePassword) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("jks");
- keyStore.load(url.openStream(), keyStorePassword);
- this.decryptionKeyStore = keyStore;
- }
-
- /**
- * Returns the decryption crypto class
- *
- * @return
- */
- public Class<? extends CryptoBase> getDecryptionCryptoClass() {
- if (decryptionCryptoClass != null) {
- return decryptionCryptoClass;
- }
- decryptionCryptoClass = org.swssf.crypto.Merlin.class;
- return decryptionCryptoClass;
- }
-
- /**
- * Sets a custom decryption class
- *
- * @param decryptionCryptoClass
- */
- public void setDecryptionCryptoClass(Class<? extends CryptoBase> decryptionCryptoClass) {
- this.decryptionCryptoClass = decryptionCryptoClass;
- }
-
- private Crypto cachedDecryptionCrypto;
- private KeyStore cachedDecryptionKeyStore;
-
- /**
- * returns the decryptionCrypto for the key-management
- *
- * @return A Crypto instance
- * @throws WSSecurityException thrown if something goes wrong
- */
- public Crypto getDecryptionCrypto() throws WSSecurityException {
-
- if (this.getDecryptionKeyStore() == null) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "decryptionKeyStoreNotSet");
- }
-
- if (this.getDecryptionKeyStore() == cachedDecryptionKeyStore) {
- return cachedDecryptionCrypto;
- }
-
- Class<? extends CryptoBase> decryptionCryptoClass = this.getDecryptionCryptoClass();
-
- try {
- CryptoBase decryptionCrypto = decryptionCryptoClass.newInstance();
- decryptionCrypto.setKeyStore(this.getDecryptionKeyStore());
- cachedDecryptionCrypto = decryptionCrypto;
- cachedDecryptionKeyStore = this.getDecryptionKeyStore();
- return decryptionCrypto;
- } catch (Exception e) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "decryptionCryptoFailure", e);
- }
- }
-
- /**
- * returns the password callback handler
- *
- * @return
- */
- public CallbackHandler getCallbackHandler() {
- return callbackHandler;
- }
-
- /**
- * sets the password callback handler
- *
- * @param callbackHandler
- */
- public void setCallbackHandler(CallbackHandler callbackHandler) {
- this.callbackHandler = callbackHandler;
- }
-
- private Constants.Action[] outAction;
+public class WSSSecurityProperties extends XMLSecurityProperties {
- private Class<? extends CryptoBase> encryptionCryptoClass;
- private KeyStore encryptionKeyStore;
- private String encryptionUser;
- private X509Certificate encryptionUseThisCertificate;
- private Constants.KeyIdentifierType encryptionKeyIdentifierType;
- private String encryptionSymAlgorithm;
- private String encryptionKeyTransportAlgorithm;
- private List<SecurePart> encryptionParts = new LinkedList<SecurePart>();
+ private WSSConstants.KeyIdentifierType signatureKeyIdentifierType;
+ private WSSConstants.KeyIdentifierType encryptionKeyIdentifierType;
- /**
- * Returns the encryption keystore
- *
- * @return A keystore for encryption operation
- */
- public KeyStore getEncryptionKeyStore() {
- return encryptionKeyStore;
- }
-
- /**
- * loads a java keystore from the given url for encrypt operations
- *
- * @param url The URL to the keystore
- * @param keyStorePassword The keyStorePassword
- * @throws Exception thrown if something goes wrong while loading the keystore
- */
- public void loadEncryptionKeystore(URL url, char[] keyStorePassword) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("jks");
- keyStore.load(url.openStream(), keyStorePassword);
- this.encryptionKeyStore = keyStore;
- }
-
- /**
- * Returns the encryption crypto class
- *
- * @return
- */
- public Class<? extends CryptoBase> getEncryptionCryptoClass() {
- if (encryptionCryptoClass != null) {
- return encryptionCryptoClass;
- }
- encryptionCryptoClass = org.swssf.crypto.Merlin.class;
- return encryptionCryptoClass;
- }
-
- /**
- * Sets a custom encryption class
- *
- * @param encryptionCryptoClass
- */
- public void setEncryptionCryptoClass(Class<? extends CryptoBase> encryptionCryptoClass) {
- this.encryptionCryptoClass = encryptionCryptoClass;
- }
-
- private Crypto cachedEncryptionCrypto;
- private KeyStore cachedEncryptionKeyStore;
-
- /**
- * returns the encryptionCrypto for the key-management
- *
- * @return A Crypto instance
- * @throws WSSecurityException thrown if something goes wrong
- */
- public Crypto getEncryptionCrypto() throws WSSecurityException {
-
- if (this.getEncryptionKeyStore() == null) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "encryptionKeyStoreNotSet");
- }
-
- if (this.getEncryptionKeyStore() == cachedEncryptionKeyStore) {
- return cachedEncryptionCrypto;
- }
-
- Class<? extends CryptoBase> encryptionCryptoClass = this.getEncryptionCryptoClass();
-
- try {
- CryptoBase encryptionCrypto = encryptionCryptoClass.newInstance();
- encryptionCrypto.setKeyStore(this.getEncryptionKeyStore());
- cachedEncryptionCrypto = encryptionCrypto;
- cachedEncryptionKeyStore = this.getEncryptionKeyStore();
- return encryptionCrypto;
- } catch (Exception e) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "encryptionCryptoFailure", e);
- }
- }
-
- /**
- * Adds a part which must be encrypted by the framework
- *
- * @param securePart
- */
- public void addEncryptionPart(SecurePart securePart) {
- encryptionParts.add(securePart);
- }
-
- /**
- * Returns the encryption parts which are actually set
- *
- * @return A List of SecurePart's
- */
- public List<SecurePart> getEncryptionSecureParts() {
- return encryptionParts;
- }
-
- /**
- * Returns the Encryption-Algo
- *
- * @return the Encryption-Algo as String
- */
- public String getEncryptionSymAlgorithm() {
- return encryptionSymAlgorithm;
- }
-
- /**
- * Specifies the encryption algorithm
- *
- * @param encryptionSymAlgorithm The algo to use for encryption
- */
- public void setEncryptionSymAlgorithm(String encryptionSymAlgorithm) {
- this.encryptionSymAlgorithm = encryptionSymAlgorithm;
- }
-
- /**
- * Returns the encryption key transport algorithm
- *
- * @return the key transport algorithm as string
- */
- public String getEncryptionKeyTransportAlgorithm() {
- return encryptionKeyTransportAlgorithm;
- }
-
- /**
- * Specifies the encryption key transport algorithm
- *
- * @param encryptionKeyTransportAlgorithm
- * the encryption key transport algorithm as string
- */
- public void setEncryptionKeyTransportAlgorithm(String encryptionKeyTransportAlgorithm) {
- this.encryptionKeyTransportAlgorithm = encryptionKeyTransportAlgorithm;
- }
-
- public X509Certificate getEncryptionUseThisCertificate() {
- return encryptionUseThisCertificate;
- }
-
- public void setEncryptionUseThisCertificate(X509Certificate encryptionUseThisCertificate) {
- this.encryptionUseThisCertificate = encryptionUseThisCertificate;
- }
-
- /**
- * Returns the alias for the encryption key in the keystore
- *
- * @return the alias for the encryption key in the keystore as string
- */
- public String getEncryptionUser() {
- return encryptionUser;
+ public WSSConstants.KeyIdentifierType getSignatureKeyIdentifierType() {
+ return signatureKeyIdentifierType;
}
- /**
- * Specifies the the alias for the encryption key in the keystore
- *
- * @param encryptionUser the the alias for the encryption key in the keystore as string
- */
- public void setEncryptionUser(String encryptionUser) {
- this.encryptionUser = encryptionUser;
+ public void setSignatureKeyIdentifierType(WSSConstants.KeyIdentifierType signatureKeyIdentifierType) {
+ this.signatureKeyIdentifierType = signatureKeyIdentifierType;
}
/**
@@ -329,7 +46,7 @@ public class SecurityProperties {
*
* @return The KeyIdentifierType
*/
- public Constants.KeyIdentifierType getEncryptionKeyIdentifierType() {
+ public WSSConstants.KeyIdentifierType getEncryptionKeyIdentifierType() {
return encryptionKeyIdentifierType;
}
@@ -338,118 +55,10 @@ public class SecurityProperties {
*
* @param encryptionKeyIdentifierType
*/
- public void setEncryptionKeyIdentifierType(Constants.KeyIdentifierType encryptionKeyIdentifierType) {
+ public void setEncryptionKeyIdentifierType(WSSConstants.KeyIdentifierType encryptionKeyIdentifierType) {
this.encryptionKeyIdentifierType = encryptionKeyIdentifierType;
}
- private List<SecurePart> signatureParts = new LinkedList<SecurePart>();
- private String signatureAlgorithm;
- private String signatureDigestAlgorithm;
- private String signatureCanonicalizationAlgorithm;
- private Class<? extends CryptoBase> signatureCryptoClass;
- private KeyStore signatureKeyStore;
- private String signatureUser;
- private Constants.KeyIdentifierType signatureKeyIdentifierType;
- private boolean useSingleCert = true;
-
- public void addSignaturePart(SecurePart securePart) {
- signatureParts.add(securePart);
- }
-
- public List<SecurePart> getSignatureSecureParts() {
- return signatureParts;
- }
-
- public String getSignatureAlgorithm() {
- return signatureAlgorithm;
- }
-
- public void setSignatureAlgorithm(String signatureAlgorithm) {
- this.signatureAlgorithm = signatureAlgorithm;
- }
-
- public String getSignatureDigestAlgorithm() {
- return signatureDigestAlgorithm;
- }
-
- public void setSignatureDigestAlgorithm(String signatureDigestAlgorithm) {
- this.signatureDigestAlgorithm = signatureDigestAlgorithm;
- }
-
- public void setSignatureUser(String signatureUser) {
- this.signatureUser = signatureUser;
- }
-
- public String getSignatureUser() {
- return signatureUser;
- }
-
- public KeyStore getSignatureKeyStore() {
- return signatureKeyStore;
- }
-
- public void loadSignatureKeyStore(URL url, char[] keyStorePassword) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("jks");
- keyStore.load(url.openStream(), keyStorePassword);
- this.signatureKeyStore = keyStore;
- }
-
- public Class<? extends CryptoBase> getSignatureCryptoClass() {
- if (signatureCryptoClass != null) {
- return signatureCryptoClass;
- }
- signatureCryptoClass = org.swssf.crypto.Merlin.class;
- return signatureCryptoClass;
- }
-
- public void setSignatureCryptoClass(Class<? extends CryptoBase> signatureCryptoClass) {
- this.signatureCryptoClass = signatureCryptoClass;
- }
-
- private Crypto cachedSignatureCrypto;
- private Class<? extends CryptoBase> cachedSignatureCryptoClass;
- private KeyStore cachedSignatureKeyStore;
-
- public Crypto getSignatureCrypto() throws WSSecurityException {
-
- if (this.getSignatureKeyStore() == null) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "signatureKeyStoreNotSet");
- }
-
- if (this.getSignatureKeyStore() == cachedSignatureKeyStore) {
- return cachedSignatureCrypto;
- }
-
- Class<? extends CryptoBase> signatureCryptoClass = this.getSignatureCryptoClass();
-
- try {
- CryptoBase signatureCrypto = signatureCryptoClass.newInstance();
- signatureCrypto.setKeyStore(this.getSignatureKeyStore());
- cachedSignatureCrypto = signatureCrypto;
- cachedSignatureCryptoClass = signatureCryptoClass;
- cachedSignatureKeyStore = this.getSignatureKeyStore();
- return signatureCrypto;
- } catch (Exception e) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "signatureCryptoFailure", e);
- }
- }
-
- public Constants.KeyIdentifierType getSignatureKeyIdentifierType() {
- return signatureKeyIdentifierType;
- }
-
- public void setSignatureKeyIdentifierType(Constants.KeyIdentifierType signatureKeyIdentifierType) {
- this.signatureKeyIdentifierType = signatureKeyIdentifierType;
- }
-
- public boolean isUseSingleCert() {
- return useSingleCert;
- }
-
- public void setUseSingleCert(boolean useSingleCert) {
- this.useSingleCert = useSingleCert;
- }
-
private Integer timestampTTL = 300;
public Integer getTimestampTTL() {
@@ -460,83 +69,6 @@ public class SecurityProperties {
this.timestampTTL = timestampTTL;
}
- /**
- * Returns the actual set actions
- *
- * @return The Actions in applied order
- */
- public Constants.Action[] getOutAction() {
- return outAction;
- }
-
- /**
- * Specifies how to secure the document eg. Timestamp, Signature, Encrypt
- *
- * @param outAction
- */
- public void setOutAction(Constants.Action[] outAction) {
- this.outAction = outAction;
- }
-
- public String getSignatureCanonicalizationAlgorithm() {
- return signatureCanonicalizationAlgorithm;
- }
-
- public void setSignatureCanonicalizationAlgorithm(String signatureCanonicalizationAlgorithm) {
- this.signatureCanonicalizationAlgorithm = signatureCanonicalizationAlgorithm;
- }
-
- private Class<? extends CryptoBase> signatureVerificationCryptoClass;
- private KeyStore signatureVerificationKeyStore;
-
- public KeyStore getSignatureVerificationKeyStore() {
- return signatureVerificationKeyStore;
- }
-
- public void loadSignatureVerificationKeystore(URL url, char[] keyStorePassword) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("jks");
- keyStore.load(url.openStream(), keyStorePassword);
- this.signatureVerificationKeyStore = keyStore;
- }
-
- public Class<? extends CryptoBase> getSignatureVerificationCryptoClass() {
- if (signatureVerificationCryptoClass != null) {
- return signatureVerificationCryptoClass;
- }
- signatureVerificationCryptoClass = org.swssf.crypto.Merlin.class;
- return signatureVerificationCryptoClass;
- }
-
- public void setSignatureVerificationCryptoClass(Class<? extends CryptoBase> signatureVerificationCryptoClass) {
- this.signatureVerificationCryptoClass = signatureVerificationCryptoClass;
- }
-
- private Crypto cachedSignatureVerificationCrypto;
- private KeyStore cachedSignatureVerificationKeyStore;
-
- public Crypto getSignatureVerificationCrypto() throws WSSecurityException {
-
- if (this.getSignatureVerificationKeyStore() == null) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "signatureVerificationKeyStoreNotSet");
- }
-
- if (this.getSignatureVerificationKeyStore() == cachedSignatureVerificationKeyStore) {
- return cachedSignatureVerificationCrypto;
- }
-
- Class<? extends CryptoBase> signatureVerificationCryptoClass = this.getSignatureVerificationCryptoClass();
-
- try {
- CryptoBase signatureVerificationCrypto = signatureVerificationCryptoClass.newInstance();
- signatureVerificationCrypto.setKeyStore(this.getSignatureVerificationKeyStore());
- cachedSignatureVerificationCrypto = signatureVerificationCrypto;
- cachedSignatureVerificationKeyStore = this.getSignatureVerificationKeyStore();
- return signatureVerificationCrypto;
- } catch (Exception e) {
- throw new WSSConfigurationException(WSSecurityException.ErrorCode.FAILURE, "signatureVerificationCryptoFailure", e);
- }
- }
-
private boolean strictTimestampCheck = true;
public boolean isStrictTimestampCheck() {
@@ -547,28 +79,8 @@ public class SecurityProperties {
this.strictTimestampCheck = strictTimestampCheck;
}
- private boolean skipDocumentEvents = false;
-
- /**
- * Returns if the framework is skipping document-events
- *
- * @return true if document-events will be skipped, false otherwise
- */
- public boolean isSkipDocumentEvents() {
- return skipDocumentEvents;
- }
-
- /**
- * specifies if the framework should forward Document-Events or not
- *
- * @param skipDocumentEvents set to true when document events should be discarded, false otherwise
- */
- public void setSkipDocumentEvents(boolean skipDocumentEvents) {
- this.skipDocumentEvents = skipDocumentEvents;
- }
-
private String tokenUser;
- private Constants.UsernameTokenPasswordType usernameTokenPasswordType;
+ private WSSConstants.UsernameTokenPasswordType usernameTokenPasswordType;
public String getTokenUser() {
return tokenUser;
@@ -578,11 +90,11 @@ public class SecurityProperties {
this.tokenUser = tokenUser;
}
- public Constants.UsernameTokenPasswordType getUsernameTokenPasswordType() {
+ public WSSConstants.UsernameTokenPasswordType getUsernameTokenPasswordType() {
return usernameTokenPasswordType;
}
- public void setUsernameTokenPasswordType(Constants.UsernameTokenPasswordType usernameTokenPasswordType) {
+ public void setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType usernameTokenPasswordType) {
this.usernameTokenPasswordType = usernameTokenPasswordType;
}
@@ -617,22 +129,22 @@ public class SecurityProperties {
}
- private Constants.KeyIdentifierType derivedKeyKeyIdentifierType;
- private Constants.DerivedKeyTokenReference derivedKeyTokenReference;
+ private WSSConstants.KeyIdentifierType derivedKeyKeyIdentifierType;
+ private WSSConstants.DerivedKeyTokenReference derivedKeyTokenReference;
- public Constants.KeyIdentifierType getDerivedKeyKeyIdentifierType() {
+ public WSSConstants.KeyIdentifierType getDerivedKeyKeyIdentifierType() {
return derivedKeyKeyIdentifierType;
}
- public void setDerivedKeyKeyIdentifierType(Constants.KeyIdentifierType derivedKeyKeyIdentifierType) {
+ public void setDerivedKeyKeyIdentifierType(WSSConstants.KeyIdentifierType derivedKeyKeyIdentifierType) {
this.derivedKeyKeyIdentifierType = derivedKeyKeyIdentifierType;
}
- public Constants.DerivedKeyTokenReference getDerivedKeyTokenReference() {
+ public WSSConstants.DerivedKeyTokenReference getDerivedKeyTokenReference() {
return derivedKeyTokenReference;
}
- public void setDerivedKeyTokenReference(Constants.DerivedKeyTokenReference derivedKeyTokenReference) {
+ public void setDerivedKeyTokenReference(WSSConstants.DerivedKeyTokenReference derivedKeyTokenReference) {
this.derivedKeyTokenReference = derivedKeyTokenReference;
}
}
Copied: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSUtils.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/Utils.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSUtils.java?p2=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSUtils.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/Utils.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/Utils.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSUtils.java Tue Oct 11 18:03:00 2011
@@ -16,129 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.ext;
+package org.swssf.wss.ext;
import org.apache.commons.codec.binary.Base64;
-import org.swssf.config.TransformerAlgorithmMapper;
+import org.swssf.xmlsec.ext.XMLSecurityUtils;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
import javax.xml.namespace.QName;
import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
-import javax.xml.stream.events.XMLEvent;
-import java.io.IOException;
-import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.Deque;
import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
/**
* @author $Author$
* @version $Revision$ $Date$
*/
-public class Utils {
+public class WSSUtils extends XMLSecurityUtils {
- private Utils() {
- }
-
- /**
- * Returns the Id reference without the leading #
- *
- * @param reference The reference on which to drop the #
- * @return The reference without a leading #
- */
- public static String dropReferenceMarker(String reference) {
- if (reference.startsWith("#")) {
- return reference.substring(1);
- }
- return reference;
- }
-
- /**
- * Returns the XMLEvent type in String form
- *
- * @param xmlEvent
- * @return The XMLEvent type as string representation
- */
- public static String getXMLEventAsString(XMLEvent xmlEvent) {
- int eventType = xmlEvent.getEventType();
-
- switch (eventType) {
- case XMLEvent.START_ELEMENT:
- return "START_ELEMENT";
- case XMLEvent.END_ELEMENT:
- return "END_ELEMENT";
- case XMLEvent.PROCESSING_INSTRUCTION:
- return "PROCESSING_INSTRUCTION";
- case XMLEvent.CHARACTERS:
- return "CHARACTERS";
- case XMLEvent.COMMENT:
- return "COMMENT";
- case XMLEvent.START_DOCUMENT:
- return "START_DOCUMENT";
- case XMLEvent.END_DOCUMENT:
- return "END_DOCUMENT";
- case XMLEvent.ATTRIBUTE:
- return "ATTRIBUTE";
- case XMLEvent.DTD:
- return "DTD";
- case XMLEvent.NAMESPACE:
- return "NAMESPACE";
- default:
- throw new IllegalArgumentException("Illegal XMLEvent received: " + eventType);
- }
- }
-
- /**
- * Executes the Callback handling. Typically used to fetch passwords
- *
- * @param callbackHandler
- * @param callback
- * @throws WSSecurityException if the callback couldn't be executed
- */
- public static void doPasswordCallback(CallbackHandler callbackHandler, Callback callback) throws WSSecurityException {
- if (callbackHandler == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCallback");
- }
- try {
- callbackHandler.handle(new Callback[]{callback});
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- } catch (UnsupportedCallbackException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- }
- }
-
- /**
- * Try to get the secret key from a CallbackHandler implementation
- *
- * @param cb a CallbackHandler implementation
- * @return An array of bytes corresponding to the secret key (can be null)
- * @throws WSSecurityException
- */
- public static void doSecretKeyCallback(CallbackHandler callbackHandler, Callback callback, String id) throws WSSecurityException {
- if (callbackHandler != null) {
- try {
- callbackHandler.handle(new Callback[]{callback});
- } catch (IOException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- } catch (UnsupportedCallbackException e) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
- }
- }
- }
-
- public static Class loadClass(String className) throws ClassNotFoundException {
- return Thread.currentThread().getContextClassLoader().loadClass(className);
+ protected WSSUtils() {
+ super();
}
public static String doPasswordDigest(byte[] nonce, String created, String password) throws WSSecurityException {
@@ -167,82 +65,12 @@ public class Utils {
}
}
- @SuppressWarnings("unchecked")
- public static XMLEvent createXMLEventNS(XMLEvent xmlEvent, Deque<List<ComparableNamespace>> nsStack, Deque<List<ComparableAttribute>> attrStack) {
- if (xmlEvent.isStartElement()) {
- StartElement startElement = xmlEvent.asStartElement();
- QName startElementName = startElement.getName();
-
- List<String> prefixList = new LinkedList<String>();
- prefixList.add(startElementName.getPrefix());
-
- List<ComparableNamespace> comparableNamespaceList = new LinkedList<ComparableNamespace>();
-
- ComparableNamespace curElementNamespace = new ComparableNamespace(startElementName.getPrefix(), startElementName.getNamespaceURI());
- comparableNamespaceList.add(curElementNamespace);
-
- @SuppressWarnings("unchecked")
- Iterator<Namespace> namespaceIterator = startElement.getNamespaces();
- while (namespaceIterator.hasNext()) {
- Namespace namespace = namespaceIterator.next();
- String prefix = namespace.getPrefix();
-
- if ((prefix == null || prefix.length() == 0) && (namespace.getNamespaceURI() == null || namespace.getNamespaceURI().length() == 0)) {
- continue;
- }
-
- if (!prefixList.contains(prefix)) {
- prefixList.add(prefix);
- ComparableNamespace tmpNameSpace = new ComparableNamespace(prefix, namespace.getNamespaceURI());
- comparableNamespaceList.add(tmpNameSpace);
- }
- }
-
- List<ComparableAttribute> comparableAttributeList = new LinkedList<ComparableAttribute>();
-
- @SuppressWarnings("unchecked")
- Iterator<Attribute> attributeIterator = startElement.getAttributes();
- while (attributeIterator.hasNext()) {
- Attribute attribute = attributeIterator.next();
- String prefix = attribute.getName().getPrefix();
-
- if (prefix != null && prefix.length() == 0 && attribute.getName().getNamespaceURI().length() == 0) {
- continue;
- }
- if (!"xml".equals(prefix)) {
- if (!"".equals(prefix)) {
- //does an attribute have an namespace?
- if (!prefixList.contains(prefix)) {
- prefixList.add(prefix);
- ComparableNamespace tmpNameSpace = new ComparableNamespace(prefix, attribute.getName().getNamespaceURI());
- comparableNamespaceList.add(tmpNameSpace);
- }
- continue;
- }
- }
- //add all attrs with xml - prefix (eg. xml:lang) to attr list:
- comparableAttributeList.add(new ComparableAttribute(attribute.getName(), attribute.getValue()));
- }
-
- nsStack.push(comparableNamespaceList);
- attrStack.push(comparableAttributeList);
-
- return new XMLEventNS(xmlEvent, nsStack.toArray(new List[nsStack.size()]), attrStack.toArray(new List[attrStack.size()]));
- } else if (xmlEvent.isEndElement()) {
- XMLEventNS xmlEventNS = new XMLEventNS(xmlEvent, nsStack.toArray(new List[nsStack.size()]), attrStack.toArray(new List[attrStack.size()]));
- nsStack.pop();
- attrStack.pop();
- return xmlEventNS;
- }
- return xmlEvent;
- }
-
public static boolean isResponsibleActorOrRole(StartElement startElement, String soapVersionNamespace, String responsibleActor) {
QName actorRole;
- if (Constants.NS_SOAP11.equals(soapVersionNamespace)) {
- actorRole = Constants.ATT_soap11_Actor;
+ if (WSSConstants.NS_SOAP11.equals(soapVersionNamespace)) {
+ actorRole = WSSConstants.ATT_soap11_Actor;
} else {
- actorRole = Constants.ATT_soap12_Role;
+ actorRole = WSSConstants.ATT_soap12_Role;
}
String actor = null;
@@ -261,17 +89,4 @@ public class Utils {
return responsibleActor.equals(actor);
}
}
-
- public static Transformer getTransformer(Object methodParameter1, Object methodParameter2, String algorithm) throws WSSecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
- Class<Transformer> transformerClass = TransformerAlgorithmMapper.getTransformerClass(algorithm);
- Transformer childTransformer;
- try {
- Constructor<Transformer> constructor = transformerClass.getConstructor(Transformer.class);
- childTransformer = constructor.newInstance(methodParameter1);
- } catch (NoSuchMethodException e) {
- Constructor<Transformer> constructor = transformerClass.getConstructor(String.class, OutputStream.class);
- childTransformer = constructor.newInstance(methodParameter1, methodParameter2);
- }
- return childTransformer;
- }
}
Copied: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityContext.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityContext.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityContext.java?p2=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityContext.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityContext.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityContext.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityContext.java Tue Oct 11 18:03:00 2011
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.ext;
+package org.swssf.wss.ext;
-import org.swssf.securityEvent.SecurityEvent;
-import org.swssf.securityEvent.SecurityEventListener;
-import java.util.List;
+import org.swssf.wss.securityEvent.SecurityEvent;
+import org.swssf.wss.securityEvent.SecurityEventListener;
+import org.swssf.xmlsec.ext.SecurityContext;
/**
* The document security context
@@ -29,35 +29,7 @@ import java.util.List;
* @author $Author$
* @version $Revision$ $Date$
*/
-public interface SecurityContext {
-
- public <T> void put(String key, T value);
-
- public <T> T get(String key);
-
- public <T> T remove(String key);
-
- public <T extends List> void putList(Class key, T value);
-
- public <T> void putAsList(Class key, T value);
-
- public <T> List<T> getAsList(Class key);
-
- /**
- * Register a new SecurityTokenProvider.
- *
- * @param id A unique id
- * @param securityTokenProvider The actual SecurityTokenProvider to register.
- */
- public void registerSecurityTokenProvider(String id, SecurityTokenProvider securityTokenProvider);
-
- /**
- * Returns a registered SecurityTokenProvider with the given id or null if not found
- *
- * @param id The SecurityTokenProvider's id
- * @return The SecurityTokenProvider
- */
- public SecurityTokenProvider getSecurityTokenProvider(String id);
+public interface WSSecurityContext extends SecurityContext {
/**
* Registers a SecurityEventListener to receive Security-Events
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityException.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityException.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityException.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/ext/WSSecurityException.java Tue Oct 11 18:03:00 2011
@@ -17,10 +17,11 @@
* under the License.
*/
-package org.swssf.ext;
+package org.swssf.wss.ext;
+
+import org.swssf.xmlsec.ext.XMLSecurityException;
import javax.xml.namespace.QName;
-import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@@ -33,11 +34,12 @@ import java.util.ResourceBundle;
/**
* Exception class for WS-Security.
+ * todo cleanup and use superclass
* <p/>
*
* @author Davanum Srinivas (dims@yahoo.com).
*/
-public class WSSecurityException extends RemoteException {
+public class WSSecurityException extends XMLSecurityException {
public enum ErrorCode {
FAILURE,
@@ -72,43 +74,43 @@ public class WSSecurityException extends
FAULT_CODE_MAP.put(
ErrorCode.UNSUPPORTED_SECURITY_TOKEN,
- Constants.UNSUPPORTED_SECURITY_TOKEN
+ WSSConstants.UNSUPPORTED_SECURITY_TOKEN
);
FAULT_CODE_MAP.put(
ErrorCode.UNSUPPORTED_ALGORITHM,
- Constants.UNSUPPORTED_ALGORITHM
+ WSSConstants.UNSUPPORTED_ALGORITHM
);
FAULT_CODE_MAP.put(
ErrorCode.INVALID_SECURITY,
- Constants.INVALID_SECURITY
+ WSSConstants.INVALID_SECURITY
);
FAULT_CODE_MAP.put(
ErrorCode.INVALID_SECURITY_TOKEN,
- Constants.INVALID_SECURITY_TOKEN
+ WSSConstants.INVALID_SECURITY_TOKEN
);
FAULT_CODE_MAP.put(
ErrorCode.FAILED_AUTHENTICATION,
- Constants.FAILED_AUTHENTICATION
+ WSSConstants.FAILED_AUTHENTICATION
);
FAULT_CODE_MAP.put(
ErrorCode.FAILED_CHECK,
- Constants.FAILED_CHECK
+ WSSConstants.FAILED_CHECK
);
FAULT_CODE_MAP.put(
ErrorCode.FAILED_SIGNATURE,
- Constants.FAILED_CHECK
+ WSSConstants.FAILED_CHECK
);
FAULT_CODE_MAP.put(
ErrorCode.FAILED_ENCRYPTION,
- Constants.FAILED_CHECK
+ WSSConstants.FAILED_CHECK
);
FAULT_CODE_MAP.put(
ErrorCode.SECURITY_TOKEN_UNAVAILABLE,
- Constants.SECURITY_TOKEN_UNAVAILABLE
+ WSSConstants.SECURITY_TOKEN_UNAVAILABLE
);
FAULT_CODE_MAP.put(
ErrorCode.MESSAGE_EXPIRED,
- Constants.MESSAGE_EXPIRED
+ WSSConstants.MESSAGE_EXPIRED
);
}
Copied: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSDocumentContextImpl.java (from r1179730, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/DocumentContextImpl.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSDocumentContextImpl.java?p2=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSDocumentContextImpl.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/DocumentContextImpl.java&r1=1179730&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/impl/DocumentContextImpl.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSDocumentContextImpl.java Tue Oct 11 18:03:00 2011
@@ -16,91 +16,42 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl;
+package org.swssf.wss.impl;
-import org.swssf.ext.Constants;
-import org.swssf.ext.DocumentContext;
+import org.swssf.wss.ext.WSSConstants;
+import org.swssf.wss.ext.WSSDocumentContext;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
import java.util.ArrayList;
import java.util.List;
/**
- * A concrete DocumentContext Implementation
+ * A concrete WSSDocumentContext Implementation
*
* @author $Author$
* @version $Revision$ $Date$
*/
-public class DocumentContextImpl implements DocumentContext, Cloneable {
-
- private static final QName nullElement = new QName("", "");
- private List<QName> path = new ArrayList<QName>(10);
- private String encoding;
-
- public String getEncoding() {
- return encoding;
- }
-
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
+public class WSSDocumentContextImpl extends org.swssf.xmlsec.impl.DocumentContextImpl implements WSSDocumentContext {
public String getSOAPMessageVersionNamespace() {
- if (path.size() >= 1 && path.get(0).equals(Constants.TAG_soap11_Envelope)) {
- return Constants.NS_SOAP11;
- } else if (path.size() >= 1 && path.get(0).equals(Constants.TAG_soap12_Envelope)) {
- return Constants.NS_SOAP12;
+ if (getPath().size() >= 1 && getPath().get(0).equals(WSSConstants.TAG_soap11_Envelope)) {
+ return WSSConstants.NS_SOAP11;
+ } else if (getPath().size() >= 1 && getPath().get(0).equals(WSSConstants.TAG_soap12_Envelope)) {
+ return WSSConstants.NS_SOAP12;
}
return null;
}
- public void addPathElement(QName qName) {
- path.add(qName);
- }
-
- public QName removePathElement() {
- return path.remove(path.size() - 1);
- }
-
- protected void setPath(List<QName> path) {
- this.path = path;
- }
-
- public List<QName> getPath() {
- return path;
- }
-
- public QName getParentElement(int eventType) {
- if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) {
- if (path.size() >= 2) {
- return path.get(path.size() - 2);
- } else {
- return nullElement;
- }
- } else {
- if (path.size() >= 1) {
- return path.get(path.size() - 1);
- } else {
- return nullElement;
- }
- }
- }
-
public boolean isInSOAPHeader() {
- return (path.size() > 1
- && path.get(1).getLocalPart().equals(Constants.TAG_soap_Header_LocalName)
- && path.get(0).getNamespaceURI().equals(path.get(1).getNamespaceURI()));
+ return (getPath().size() > 1
+ && getPath().get(1).getLocalPart().equals(WSSConstants.TAG_soap_Header_LocalName)
+ && getPath().get(0).getNamespaceURI().equals(getPath().get(1).getNamespaceURI()));
}
public boolean isInSOAPBody() {
- return (path.size() > 1
- && path.get(1).getLocalPart().equals(Constants.TAG_soap_Body_LocalName)
- && path.get(0).getNamespaceURI().equals(path.get(1).getNamespaceURI()));
- }
-
- public int getDocumentLevel() {
- return path.size();
+ return (getPath().size() > 1
+ && getPath().get(1).getLocalPart().equals(WSSConstants.TAG_soap_Body_LocalName)
+ && getPath().get(0).getNamespaceURI().equals(getPath().get(1).getNamespaceURI()));
}
private boolean inSecurityHeader = false;
@@ -113,45 +64,17 @@ public class DocumentContextImpl impleme
this.inSecurityHeader = inSecurityHeader;
}
- private int actualEncryptedContentCounter = 0;
-
- public synchronized void setIsInEncryptedContent() {
- this.actualEncryptedContentCounter++;
- }
-
- public synchronized void unsetIsInEncryptedContent() {
- this.actualEncryptedContentCounter--;
- }
-
- public boolean isInEncryptedContent() {
- return this.actualEncryptedContentCounter > 0;
- }
-
- private int actualSignedContentCounter = 0;
-
- public synchronized void setIsInSignedContent() {
- this.actualSignedContentCounter++;
- }
-
- public synchronized void unsetIsInSignedContent() {
- this.actualSignedContentCounter--;
- }
-
- public boolean isInSignedContent() {
- return this.actualSignedContentCounter > 0;
- }
-
@Override
- protected DocumentContextImpl clone() throws CloneNotSupportedException {
+ protected WSSDocumentContextImpl clone() throws CloneNotSupportedException {
super.clone();
- DocumentContextImpl documentContext = new DocumentContextImpl();
+ WSSDocumentContextImpl documentContext = new WSSDocumentContextImpl();
List<QName> subPath = new ArrayList<QName>();
- subPath.addAll(this.path);
- documentContext.setEncoding(this.encoding);
+ subPath.addAll(this.getPath());
+ documentContext.setEncoding(this.getEncoding());
documentContext.setPath(subPath);
documentContext.setInSecurityHeader(isInSecurityHeader());
- documentContext.actualEncryptedContentCounter = this.actualEncryptedContentCounter;
- documentContext.actualSignedContentCounter = this.actualSignedContentCounter;
+ documentContext.setActualEncryptedContentCounter(this.getActualEncryptedContentCounter());
+ documentContext.setActualSignedContentCounter(this.getActualSignedContentCounter());
return documentContext;
}
}
Copied: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSecurityContextImpl.java (from r1181889, webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityContextImpl.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSecurityContextImpl.java?p2=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSecurityContextImpl.java&p1=webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityContextImpl.java&r1=1181889&r2=1181995&rev=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/ext/SecurityContextImpl.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/WSSecurityContextImpl.java Tue Oct 11 18:03:00 2011
@@ -16,12 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.ext;
+package org.swssf.wss.impl;
-import org.swssf.securityEvent.SecurityEvent;
-import org.swssf.securityEvent.SecurityEventListener;
-import java.util.*;
+import org.swssf.wss.ext.WSSecurityContext;
+import org.swssf.wss.ext.WSSecurityException;
+import org.swssf.wss.securityEvent.SecurityEvent;
+import org.swssf.wss.securityEvent.SecurityEventListener;
+import org.swssf.xmlsec.impl.SecurityContextImpl;
/**
* Concrete security context implementation
@@ -29,69 +31,10 @@ import java.util.*;
* @author $Author$
* @version $Revision$ $Date$
*/
-public class SecurityContextImpl implements SecurityContext {
-
- private Map<String, SecurityTokenProvider> secretTokenProviders = new HashMap<String, SecurityTokenProvider>();
+public class WSSecurityContextImpl extends SecurityContextImpl implements WSSecurityContext {
private SecurityEventListener securityEventListener;
- @SuppressWarnings("unchecked")
- private Map content = Collections.synchronizedMap(new HashMap());
-
- @SuppressWarnings("unchecked")
- public <T> void put(String key, T value) {
- content.put(key, value);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T get(String key) {
- return (T) content.get(key);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T remove(String key) {
- return (T) content.remove(key);
- }
-
- @SuppressWarnings("unchecked")
- public <T extends List> void putList(Class key, T value) {
- if (value == null) {
- return;
- }
- List<T> entry = (List<T>) content.get(key);
- if (entry == null) {
- entry = new ArrayList<T>();
- content.put(key, entry);
- }
- entry.addAll(value);
- }
-
- @SuppressWarnings("unchecked")
- public <T> void putAsList(Class key, T value) {
- List<T> entry = (List<T>) content.get(key);
- if (entry == null) {
- entry = new ArrayList<T>();
- content.put(key, entry);
- }
- entry.add(value);
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> getAsList(Class key) {
- return (List<T>) content.get(key);
- }
-
- public void registerSecurityTokenProvider(String id, SecurityTokenProvider securityTokenProvider) {
- if (id == null) {
- throw new IllegalArgumentException("Id must not be null");
- }
- secretTokenProviders.put(id, securityTokenProvider);
- }
-
- public SecurityTokenProvider getSecurityTokenProvider(String id) {
- return secretTokenProviders.get(id);
- }
-
public void setSecurityEventListener(SecurityEventListener securityEventListener) {
this.securityEventListener = securityEventListener;
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/AlgoFactory.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/AlgoFactory.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/AlgoFactory.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/AlgoFactory.java Tue Oct 11 18:03:00 2011
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.swssf.impl.derivedKey;
+package org.swssf.wss.impl.derivedKey;
-import org.swssf.ext.Constants;
+import org.swssf.wss.ext.WSSConstants;
/**
* @author Ruchith Fernando
@@ -37,7 +37,7 @@ public class AlgoFactory {
*/
public static DerivationAlgorithm getInstance(String algorithm) throws
ConversationException {
- if ((Constants.P_SHA_1_2005_12).equals(algorithm) || (Constants.P_SHA_1).equals(algorithm)) {
+ if ((WSSConstants.P_SHA_1_2005_12).equals(algorithm) || (WSSConstants.P_SHA_1).equals(algorithm)) {
return new P_SHA1();
} else {
throw new ConversationException("No such algorithm");
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/ConversationException.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/ConversationException.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/ConversationException.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/ConversationException.java Tue Oct 11 18:03:00 2011
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.swssf.impl.derivedKey;
+package org.swssf.wss.impl.derivedKey;
-import org.swssf.ext.Constants;
+import org.swssf.wss.ext.WSSConstants;
import java.text.MessageFormat;
import java.util.MissingResourceException;
@@ -65,7 +65,7 @@ public class ConversationException exten
UNKNOWN_DERIVATION_SOURCE.equals(code) ||
UNSUPPORTED_CONTEXT_TOKEN.equals(code) ||
RENEW_NEEDED.equals(code)) {
- return Constants.PREFIX_WSC + ":" + code;
+ return WSSConstants.PREFIX_WSC + ":" + code;
} else {
return code;
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivationAlgorithm.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivationAlgorithm.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivationAlgorithm.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivationAlgorithm.java Tue Oct 11 18:03:00 2011
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.swssf.impl.derivedKey;
+package org.swssf.wss.impl.derivedKey;
/**
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivedKeyUtils.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivedKeyUtils.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivedKeyUtils.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/DerivedKeyUtils.java Tue Oct 11 18:03:00 2011
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.derivedKey;
+package org.swssf.wss.impl.derivedKey;
import org.apache.commons.codec.binary.Base64;
-import org.swssf.ext.Constants;
-import org.swssf.ext.WSSecurityException;
+import org.swssf.wss.ext.WSSConstants;
+import org.swssf.wss.ext.WSSecurityException;
/**
* @author $Author$
@@ -33,18 +33,18 @@ public class DerivedKeyUtils {
*
* @param length
* @param secret
- * @throws org.swssf.ext.WSSecurityException
+ * @throws org.swssf.wss.ext.WSSecurityException
*
*/
public static byte[] deriveKey(String algorithm, String label, int length, byte[] secret, byte[] nonce, int offset) throws WSSecurityException {
try {
if (algorithm == null || algorithm.equals("")) {
- algorithm = Constants.P_SHA_1;
+ algorithm = WSSConstants.P_SHA_1;
}
DerivationAlgorithm algo = AlgoFactory.getInstance(algorithm);
byte[] labelBytes;
if (label == null || label.length() == 0) {
- labelBytes = (Constants.WS_SecureConversation_DEFAULT_LABEL + Constants.WS_SecureConversation_DEFAULT_LABEL).getBytes("UTF-8");
+ labelBytes = (WSSConstants.WS_SecureConversation_DEFAULT_LABEL + WSSConstants.WS_SecureConversation_DEFAULT_LABEL).getBytes("UTF-8");
} else {
labelBytes = label.getBytes("UTF-8");
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/P_SHA1.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/P_SHA1.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/P_SHA1.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/derivedKey/P_SHA1.java Tue Oct 11 18:03:00 2011
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.swssf.impl.derivedKey;
+package org.swssf.wss.impl.derivedKey;
/**
*
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/BinarySecurityTokenInputHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/BinarySecurityTokenInputHandler.java?rev=1181995&r1=1179730&r2=1181995&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/BinarySecurityTokenInputHandler.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/BinarySecurityTokenInputHandler.java Tue Oct 11 18:03:00 2011
@@ -16,12 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.swssf.impl.processor.input;
+package org.swssf.wss.impl.processor.input;
import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.BinarySecurityTokenType;
-import org.swssf.crypto.Crypto;
-import org.swssf.ext.*;
-import org.swssf.impl.securityToken.SecurityTokenFactory;
+import org.swssf.wss.ext.WSSSecurityProperties;
+import org.swssf.wss.impl.securityToken.SecurityTokenFactoryImpl;
+import org.swssf.xmlsec.crypto.Crypto;
+import org.swssf.xmlsec.ext.*;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
@@ -38,7 +39,9 @@ import java.util.UUID;
*/
public class BinarySecurityTokenInputHandler extends AbstractInputSecurityHeaderHandler {
- public BinarySecurityTokenInputHandler(final InputProcessorChain inputProcessorChain, final SecurityProperties securityProperties, Deque<XMLEvent> eventQueue, Integer index) throws WSSecurityException {
+ public BinarySecurityTokenInputHandler(final InputProcessorChain inputProcessorChain,
+ final WSSSecurityProperties securityProperties,
+ Deque<XMLEvent> eventQueue, Integer index) throws XMLSecurityException {
final BinarySecurityTokenType binarySecurityTokenType = (BinarySecurityTokenType) parseStructure(eventQueue, index);
@@ -50,12 +53,12 @@ public class BinarySecurityTokenInputHan
private Map<Crypto, SecurityToken> securityTokens = new HashMap<Crypto, SecurityToken>();
- public SecurityToken getSecurityToken(Crypto crypto) throws WSSecurityException {
+ public SecurityToken getSecurityToken(Crypto crypto) throws XMLSecurityException {
SecurityToken securityToken = securityTokens.get(crypto);
if (securityToken != null) {
return securityToken;
}
- securityToken = SecurityTokenFactory.newInstance().getSecurityToken(binarySecurityTokenType, inputProcessorChain.getSecurityContext(), crypto, securityProperties.getCallbackHandler(), null);
+ securityToken = SecurityTokenFactoryImpl.getSecurityToken(binarySecurityTokenType, inputProcessorChain.getSecurityContext(), crypto, securityProperties.getCallbackHandler(), null);
securityTokens.put(crypto, securityToken);
return securityToken;
}