ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gi...@apache.org
Subject svn commit: r1463136 [8/11] - in /webservices/wss4j/trunk: cxf-integration/src/main/java/org/apache/wss4j/cxfIntegration/interceptor/ integration/src/test/java/org/apache/wss4j/integration/test/stax/ ws-security-common/src/main/java/org/apache/wss4j/co...
Date Mon, 01 Apr 2013 13:57:35 GMT
Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -23,6 +23,7 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.stax.ext.WSSConstants;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
 import org.apache.wss4j.stax.ext.WSSUtils;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
 import org.apache.xml.security.stax.ext.*;
@@ -30,8 +31,9 @@ import org.apache.xml.security.stax.ext.
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
 import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
 import org.apache.xml.security.stax.impl.securityToken.GenericOutboundSecurityToken;
-import org.apache.xml.security.stax.impl.securityToken.OutboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
 
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
@@ -65,7 +67,7 @@ public class EncryptedKeyOutputProcessor
             if (tokenId == null) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE);
             }
-            SecurityTokenProvider wrappingSecurityTokenProvider = outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);
+            SecurityTokenProvider<OutboundSecurityToken> wrappingSecurityTokenProvider = outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);
             if (wrappingSecurityTokenProvider == null) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE);
             }
@@ -93,13 +95,13 @@ public class EncryptedKeyOutputProcessor
 
             final String ekId = IDGenerator.generateID(null);
 
-            final GenericOutboundSecurityToken encryptedKeySecurityToken = new GenericOutboundSecurityToken(ekId, WSSConstants.EncryptedKeyToken, symmetricKey);
+            final GenericOutboundSecurityToken encryptedKeySecurityToken = new GenericOutboundSecurityToken(ekId, WSSecurityTokenConstants.EncryptedKeyToken, symmetricKey);
             encryptedKeySecurityToken.setKeyWrappingToken(wrappingSecurityToken);
             wrappingSecurityToken.addWrappedToken(encryptedKeySecurityToken);
 
-            final SecurityTokenProvider encryptedKeySecurityTokenProvider = new SecurityTokenProvider() {
+            final SecurityTokenProvider<OutboundSecurityToken> encryptedKeySecurityTokenProvider =
+                    new SecurityTokenProvider<OutboundSecurityToken>() {
 
-                @SuppressWarnings("unchecked")
                 @Override
                 public OutboundSecurityToken getSecurityToken() throws XMLSecurityException {
                     return encryptedKeySecurityToken;
@@ -115,21 +117,21 @@ public class EncryptedKeyOutputProcessor
             finalEncryptedKeyOutputProcessor.setXMLSecurityProperties(getSecurityProperties());
             finalEncryptedKeyOutputProcessor.setAction(getAction());
             XMLSecurityConstants.Action action = getAction();
-            if (action.equals(WSSConstants.ENCRYPT)) {
+            if (WSSConstants.ENCRYPT.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTION, ekId);
                 if (wrappingSecurityToken.getProcessor() != null) {
                     finalEncryptedKeyOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
                     finalEncryptedKeyOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());
                 }
-            } else if (action.equals(WSSConstants.SIGNATURE_WITH_DERIVED_KEY)) {
+            } else if (WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, ekId);
                 if (wrappingSecurityToken.getProcessor() != null) {
                     finalEncryptedKeyOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
                     finalEncryptedKeyOutputProcessor.addBeforeProcessor(WSSSignatureOutputProcessor.class.getName());
                 }
-            } else if (action.equals(WSSConstants.ENCRYPT_WITH_DERIVED_KEY)) {
+            } else if (WSSConstants.ENCRYPT_WITH_DERIVED_KEY.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, ekId);
                 if (wrappingSecurityToken.getProcessor() != null) {
                     finalEncryptedKeyOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
@@ -229,7 +231,7 @@ public class EncryptedKeyOutputProcessor
                     createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_dsig_KeyInfo, true, null);
                     createSecurityTokenReferenceStructureForEncryptedKey(
                             subOutputProcessorChain, securityToken,
-                            ((WSSSecurityProperties) getSecurityProperties()).getEncryptionKeyIdentifierType(),
+                            ((WSSSecurityProperties) getSecurityProperties()).getEncryptionKeyIdentifier(),
                             getSecurityProperties().isUseSingleCert()
                     );
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_dsig_KeyInfo);
@@ -296,7 +298,7 @@ public class EncryptedKeyOutputProcessor
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_CipherValue);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_CipherData);
 
-                    if (getAction() == WSSConstants.ENCRYPT) {
+                    if (WSSConstants.ENCRYPT.equals(getAction())) {
                         WSSUtils.createReferenceListStructureForEncryption(this, subOutputProcessorChain);
                     }
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_EncryptedKey);
@@ -308,13 +310,13 @@ public class EncryptedKeyOutputProcessor
         protected void createSecurityTokenReferenceStructureForEncryptedKey(
                 OutputProcessorChain outputProcessorChain,
                 OutboundSecurityToken securityToken,
-                WSSConstants.KeyIdentifierType keyIdentifierType,
+                WSSecurityTokenConstants.KeyIdentifier keyIdentifier,
                 boolean useSingleCertificate)
                 throws XMLStreamException, XMLSecurityException {
 
             List<XMLSecAttribute> attributes = new ArrayList<XMLSecAttribute>(2);
             attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null)));
-            if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE && !useSingleCertificate) {
+            if (WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(keyIdentifier) && !useSingleCertificate) {
                 attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_X509PKIPathv1));
             }
             createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, false, attributes);
@@ -322,15 +324,15 @@ public class EncryptedKeyOutputProcessor
             X509Certificate[] x509Certificates = securityToken.getKeyWrappingToken().getX509Certificates();
             String tokenId = securityToken.getKeyWrappingToken().getId();
 
-            if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.ISSUER_SERIAL) {
-                createX509IssuerSerialStructure(outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.SKI_KEY_IDENTIFIER) {
+            if (WSSecurityTokenConstants.KeyIdentifier_IssuerSerial.equals(keyIdentifier)) {
+                WSSUtils.createX509IssuerSerialStructure(this, outputProcessorChain, x509Certificates);
+            } else if (WSSecurityTokenConstants.KeyIdentifier_SkiKeyIdentifier.equals(keyIdentifier)) {
                 WSSUtils.createX509SubjectKeyIdentifierStructure(this, outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.X509_KEY_IDENTIFIER) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_X509KeyIdentifier.equals(keyIdentifier)) {
                 WSSUtils.createX509KeyIdentifierStructure(this, outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.THUMBPRINT_IDENTIFIER) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier.equals(keyIdentifier)) {
                 WSSUtils.createThumbprintKeyIdentifierStructure(this, outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(keyIdentifier)) {
                 String valueType;
                 if (useSingleCertificate) {
                     valueType = WSSConstants.NS_X509_V3_TYPE;

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/KerberosSecurityTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/KerberosSecurityTokenOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/KerberosSecurityTokenOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/KerberosSecurityTokenOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -27,13 +27,13 @@ import org.apache.wss4j.stax.impl.securi
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.ext.AbstractOutputProcessor;
 import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.SecurityTokenProvider;
 import org.apache.xml.security.stax.ext.XMLSecurityConstants;
 import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
 import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.securityToken.OutboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
 
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -60,9 +60,9 @@ public class KerberosSecurityTokenOutput
                     );
 
 
-            final SecurityTokenProvider kerberosSecurityTokenProvider = new SecurityTokenProvider() {
+            final SecurityTokenProvider<OutboundSecurityToken> kerberosSecurityTokenProvider =
+                    new SecurityTokenProvider<OutboundSecurityToken>() {
 
-                @SuppressWarnings("unchecked")
                 @Override
                 public OutboundSecurityToken getSecurityToken() throws WSSecurityException {
                     return kerberosClientSecurityToken;
@@ -74,7 +74,7 @@ public class KerberosSecurityTokenOutput
                 }
             };
 
-            if (action.equals(WSSConstants.SIGNATURE_WITH_KERBEROS_TOKEN)) {
+            if (WSSConstants.SIGNATURE_WITH_KERBEROS_TOKEN.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE, bstId);
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_APPEND_SIGNATURE_ON_THIS_ID, bstId);
                 FinalKerberosSecurityTokenOutputProcessor finalKerberosSecurityTokenOutputProcessor =
@@ -84,7 +84,7 @@ public class KerberosSecurityTokenOutput
                 finalKerberosSecurityTokenOutputProcessor.addBeforeProcessor(WSSSignatureOutputProcessor.class.getName());
                 finalKerberosSecurityTokenOutputProcessor.init(outputProcessorChain);
                 kerberosClientSecurityToken.setProcessor(finalKerberosSecurityTokenOutputProcessor);
-            } else if (action.equals(WSSConstants.ENCRYPT_WITH_KERBEROS_TOKEN)) {
+            } else if (WSSConstants.ENCRYPT_WITH_KERBEROS_TOKEN.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTION, bstId);
                 FinalKerberosSecurityTokenOutputProcessor finalKerberosSecurityTokenOutputProcessor =
                         new FinalKerberosSecurityTokenOutputProcessor(kerberosClientSecurityToken);
@@ -131,7 +131,7 @@ public class KerberosSecurityTokenOutput
                             new Base64(76, new byte[]{'\n'}).encodeToString(securityToken.getTicket())
                     );
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse_BinarySecurityToken);
-                    if (getAction() == WSSConstants.ENCRYPT_WITH_KERBEROS_TOKEN) {
+                    if (WSSConstants.ENCRYPT_WITH_KERBEROS_TOKEN.equals(getAction())) {
                         WSSUtils.createReferenceListStructureForEncryption(this, subOutputProcessorChain);
                     }
                     outputProcessorChain.removeProcessor(this);

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SAMLTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SAMLTokenOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SAMLTokenOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SAMLTokenOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -27,6 +27,7 @@ import org.apache.wss4j.common.saml.bean
 import org.apache.wss4j.stax.ext.WSSConstants;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
 import org.apache.wss4j.stax.ext.WSSUtils;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
 import org.apache.xml.security.stax.ext.*;
@@ -35,8 +36,9 @@ import org.apache.xml.security.stax.ext.
 import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
 import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
 import org.apache.xml.security.stax.impl.securityToken.GenericOutboundSecurityToken;
-import org.apache.xml.security.stax.impl.securityToken.OutboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
 import org.opensaml.common.SAMLVersion;
 import org.w3c.dom.*;
 
@@ -112,7 +114,7 @@ public class SAMLTokenOutputProcessor ex
                 final String binarySecurityTokenId = IDGenerator.generateID(null);
 
                 final GenericOutboundSecurityToken securityToken =
-                        new GenericOutboundSecurityToken(binarySecurityTokenId, WSSConstants.X509V3Token,
+                        new GenericOutboundSecurityToken(binarySecurityTokenId, WSSecurityTokenConstants.X509V3Token,
                                 privateKey, certificates);
 
                 finalSAMLTokenOutputProcessor = new FinalSAMLTokenOutputProcessor(securityToken, samlAssertionWrapper,
@@ -120,9 +122,9 @@ public class SAMLTokenOutputProcessor ex
 
                 securityToken.setProcessor(finalSAMLTokenOutputProcessor);
 
-                SecurityTokenProvider securityTokenProvider = new SecurityTokenProvider() {
+                SecurityTokenProvider<OutboundSecurityToken> securityTokenProvider =
+                        new SecurityTokenProvider<OutboundSecurityToken>() {
 
-                    @SuppressWarnings("unchecked")
                     @Override
                     public OutboundSecurityToken getSecurityToken() throws WSSecurityException {
                         return securityToken;
@@ -171,11 +173,11 @@ public class SAMLTokenOutputProcessor ex
                 finalSAMLTokenOutputProcessor = new FinalSAMLTokenOutputProcessor(null, samlAssertionWrapper,
                         securityTokenReferenceId, senderVouches);
 
-                SecurityTokenProvider securityTokenProvider = new SecurityTokenProvider() {
+                SecurityTokenProvider<OutboundSecurityToken> securityTokenProvider =
+                        new SecurityTokenProvider<OutboundSecurityToken>() {
 
                     private GenericOutboundSecurityToken samlSecurityToken;
 
-                    @SuppressWarnings("unchecked")
                     @Override
                     public OutboundSecurityToken getSecurityToken() throws XMLSecurityException {
 
@@ -183,13 +185,13 @@ public class SAMLTokenOutputProcessor ex
                             return this.samlSecurityToken;
                         }
 
-                        XMLSecurityConstants.TokenType tokenType;
+                        WSSecurityTokenConstants.TokenType tokenType;
                         if (samlCallback.getSamlVersion() == SAMLVersion.VERSION_10) {
-                            tokenType = WSSConstants.Saml10Token;
+                            tokenType = WSSecurityTokenConstants.Saml10Token;
                         } else if (samlCallback.getSamlVersion() == SAMLVersion.VERSION_11) {
-                            tokenType = WSSConstants.Saml11Token;
+                            tokenType = WSSecurityTokenConstants.Saml11Token;
                         } else {
-                            tokenType = WSSConstants.Saml20Token;
+                            tokenType = WSSecurityTokenConstants.Saml20Token;
                         }
                         if (samlKeyInfo.getPrivateKey() != null) {
                             this.samlSecurityToken = new GenericOutboundSecurityToken(
@@ -237,7 +239,7 @@ public class SAMLTokenOutputProcessor ex
             finalSAMLTokenOutputProcessor.init(outputProcessorChain);
 
             XMLSecurityConstants.Action action = getAction();
-            if (action.equals(WSSConstants.SAML_TOKEN_SIGNED) && senderVouches) {
+            if (WSSConstants.SAML_TOKEN_SIGNED.equals(action) && senderVouches) {
                 SecurePart securePart =
                         new SecurePart(
                                 new QName(WSSConstants.SOAPMESSAGE_NS10_STRTransform),
@@ -281,8 +283,8 @@ public class SAMLTokenOutputProcessor ex
                         ((WSSSecurityProperties) getSecurityProperties()).getActor())) {
 
                     OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
-                    if (senderVouches && getSecurityProperties().getSignatureKeyIdentifierType() ==
-                            WSSConstants.WSSKeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE) {
+                    if (senderVouches && getSecurityProperties().getSignatureKeyIdentifier() ==
+                            WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference) {
 
                         WSSUtils.createBinarySecurityTokenStructure(this, outputProcessorChain, securityToken.getId(),
                                 securityToken.getX509Certificates(), getSecurityProperties().isUseSingleCert());

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityContextTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityContextTokenOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityContextTokenOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityContextTokenOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -22,14 +22,16 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.stax.ext.WSSConstants;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
 import org.apache.wss4j.stax.ext.WSSUtils;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.ext.*;
 import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
 import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
 import org.apache.xml.security.stax.impl.securityToken.GenericOutboundSecurityToken;
-import org.apache.xml.security.stax.impl.securityToken.OutboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
 
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -53,7 +55,7 @@ public class SecurityContextTokenOutputP
             if (tokenId == null) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE);
             }
-            SecurityTokenProvider wrappingSecurityTokenProvider = outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);
+            SecurityTokenProvider<OutboundSecurityToken> wrappingSecurityTokenProvider = outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);
             if (wrappingSecurityTokenProvider == null) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE);
             }
@@ -65,7 +67,7 @@ public class SecurityContextTokenOutputP
             final String wsuId = IDGenerator.generateID(null);
             final String identifier = IDGenerator.generateID(null);
 
-            final GenericOutboundSecurityToken securityContextSecurityToken = new GenericOutboundSecurityToken(wsuId, WSSConstants.SecurityContextToken) {
+            final GenericOutboundSecurityToken securityContextSecurityToken = new GenericOutboundSecurityToken(wsuId, WSSecurityTokenConstants.SecurityContextToken) {
 
                 @Override
                 public Key getSecretKey(String algorithmURI) throws XMLSecurityException {
@@ -84,9 +86,9 @@ public class SecurityContextTokenOutputP
             };
             wrappingSecurityToken.addWrappedToken(securityContextSecurityToken);
 
-            SecurityTokenProvider securityContextSecurityTokenProvider = new SecurityTokenProvider() {
+            SecurityTokenProvider<OutboundSecurityToken> securityContextSecurityTokenProvider =
+                    new SecurityTokenProvider<OutboundSecurityToken>() {
 
-                @SuppressWarnings("unchecked")
                 @Override
                 public OutboundSecurityToken getSecurityToken() throws WSSecurityException {
                     return securityContextSecurityToken;
@@ -103,14 +105,14 @@ public class SecurityContextTokenOutputP
             finalSecurityContextTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());
             finalSecurityContextTokenOutputProcessor.setAction(getAction());
             XMLSecurityConstants.Action action = getAction();
-            if (action.equals(WSSConstants.SIGNATURE_WITH_DERIVED_KEY)) {
+            if (WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, wsuId);
                 if (wrappingSecurityToken.getProcessor() != null) {
                     finalSecurityContextTokenOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
                     finalSecurityContextTokenOutputProcessor.addBeforeProcessor(WSSSignatureOutputProcessor.class.getName());
                 }
-            } else if (action.equals(WSSConstants.ENCRYPT_WITH_DERIVED_KEY)) {
+            } else if (WSSConstants.ENCRYPT_WITH_DERIVED_KEY.equals(action)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, wsuId);
                 if (wrappingSecurityToken.getProcessor() != null) {
                     finalSecurityContextTokenOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SignatureConfirmationOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SignatureConfirmationOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SignatureConfirmationOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SignatureConfirmationOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -60,7 +60,7 @@ public class SignatureConfirmationOutput
                 List<SecurityEvent> requestSecurityEvents = outputProcessorChain.getSecurityContext().getAsList(SecurityEvent.class);
                 for (int i = 0; i < requestSecurityEvents.size(); i++) {
                     SecurityEvent securityEvent = requestSecurityEvents.get(i);
-                    if (securityEvent.getSecurityEventType() == SecurityEventConstants.SignatureValue) {
+                    if (SecurityEventConstants.SignatureValue.equals(securityEvent.getSecurityEventType())) {
                         aSignatureFound = true;
                         SignatureValueSecurityEvent signatureValueSecurityEvent = (SignatureValueSecurityEvent) securityEvent;
 

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/UsernameTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/UsernameTokenOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/UsernameTokenOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/UsernameTokenOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -30,8 +30,9 @@ import org.apache.xml.security.stax.ext.
 import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
 import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.securityToken.OutboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
 
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.stream.XMLStreamConstants;
@@ -78,9 +79,9 @@ public class UsernameTokenOutputProcesso
                     );
             usernameSecurityToken.setProcessor(outputProcessor);
 
-            SecurityTokenProvider securityTokenProvider = new SecurityTokenProvider() {
+            SecurityTokenProvider<OutboundSecurityToken> securityTokenProvider =
+                    new SecurityTokenProvider<OutboundSecurityToken>() {
 
-                @SuppressWarnings("unchecked")
                 @Override
                 public OutboundSecurityToken getSecurityToken() throws WSSecurityException {
                     return usernameSecurityToken;
@@ -91,7 +92,7 @@ public class UsernameTokenOutputProcesso
                     return wsuId;
                 }
             };
-            if (getAction() == WSSConstants.USERNAMETOKEN_SIGNED) {
+            if (WSSConstants.USERNAMETOKEN_SIGNED.equals(getAction())) {
                 outputProcessorChain.getSecurityContext().registerSecurityTokenProvider(wsuId, securityTokenProvider);
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE, wsuId);
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_APPEND_SIGNATURE_ON_THIS_ID, wsuId);

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureEndingOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureEndingOutputProcessor.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureEndingOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureEndingOutputProcessor.java Mon Apr  1 13:57:32 2013
@@ -22,6 +22,7 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.stax.ext.WSSConstants;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
 import org.apache.wss4j.stax.ext.WSSUtils;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.ext.OutputProcessorChain;
 import org.apache.xml.security.stax.ext.XMLSecurityConstants;
@@ -31,9 +32,9 @@ import org.apache.xml.security.stax.ext.
 import org.apache.xml.security.stax.impl.SignaturePartDef;
 import org.apache.xml.security.stax.impl.algorithms.SignatureAlgorithm;
 import org.apache.xml.security.stax.impl.processor.output.AbstractSignatureEndingOutputProcessor;
-import org.apache.xml.security.stax.impl.securityToken.OutboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
 import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
@@ -96,42 +97,42 @@ public class WSSSignatureEndingOutputPro
             boolean useSingleCertificate)
             throws XMLStreamException, XMLSecurityException {
 
-        WSSConstants.KeyIdentifierType keyIdentifierType = getSecurityProperties().getSignatureKeyIdentifierType();
+        WSSecurityTokenConstants.KeyIdentifier keyIdentifier = getSecurityProperties().getSignatureKeyIdentifier();
 
         X509Certificate[] x509Certificates = securityToken.getX509Certificates();
 
-        if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.KEY_VALUE) {
+        if (WSSecurityTokenConstants.KeyIdentifier_KeyValue.equals(keyIdentifier)) {
             WSSUtils.createKeyValueTokenStructure(this, outputProcessorChain, x509Certificates);
         } else {
             List<XMLSecAttribute> attributes = new ArrayList<XMLSecAttribute>(2);
             attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null)));
-            if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE && !useSingleCertificate) {
+            if (WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(keyIdentifier) && !useSingleCertificate) {
                 attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_X509PKIPathv1));
-            } else if (WSSConstants.Saml10Token.equals(securityToken.getTokenType())
-                    || WSSConstants.Saml11Token.equals(securityToken.getTokenType())) {
+            } else if (WSSecurityTokenConstants.Saml10Token.equals(securityToken.getTokenType())
+                    || WSSecurityTokenConstants.Saml11Token.equals(securityToken.getTokenType())) {
                 attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_SAML11_TOKEN_PROFILE_TYPE));
-            } else if (WSSConstants.Saml20Token.equals(securityToken.getTokenType())) {
+            } else if (WSSecurityTokenConstants.Saml20Token.equals(securityToken.getTokenType())) {
                 attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_SAML20_TOKEN_PROFILE_TYPE));
-            } else if (WSSConstants.KerberosToken.equals(securityToken.getTokenType())) {
+            } else if (WSSecurityTokenConstants.KerberosToken.equals(securityToken.getTokenType())) {
                 attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_GSS_Kerberos5_AP_REQ));
             }
             createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, false, attributes);
 
             String tokenId = securityToken.getId();
 
-            if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.ISSUER_SERIAL) {
-                createX509IssuerSerialStructure(outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.SKI_KEY_IDENTIFIER) {
+            if (WSSecurityTokenConstants.KeyIdentifier_IssuerSerial.equals(keyIdentifier)) {
+                WSSUtils.createX509IssuerSerialStructure(this, outputProcessorChain, x509Certificates);
+            } else if (WSSecurityTokenConstants.KeyIdentifier_SkiKeyIdentifier.equals(keyIdentifier)) {
                 WSSUtils.createX509SubjectKeyIdentifierStructure(this, outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.X509_KEY_IDENTIFIER) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_X509KeyIdentifier.equals(keyIdentifier)) {
                 WSSUtils.createX509KeyIdentifierStructure(this, outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.THUMBPRINT_IDENTIFIER) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier.equals(keyIdentifier)) {
                 WSSUtils.createThumbprintKeyIdentifierStructure(this, outputProcessorChain, x509Certificates);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(keyIdentifier)) {
                 String valueType;
-                if (WSSConstants.Saml20Token.equals(securityToken.getTokenType())) {
+                if (WSSecurityTokenConstants.Saml20Token.equals(securityToken.getTokenType())) {
                     valueType = null;
-                } else if (WSSConstants.KerberosToken.equals(securityToken.getTokenType())) {
+                } else if (WSSecurityTokenConstants.KerberosToken.equals(securityToken.getTokenType())) {
                     valueType = WSSConstants.NS_GSS_Kerberos5_AP_REQ;
                 } else {
                     if (useSingleCertificate) {
@@ -141,12 +142,12 @@ public class WSSSignatureEndingOutputPro
                     }
                 }
                 WSSUtils.createBSTReferenceStructure(this, outputProcessorChain, tokenId, valueType);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.EMBEDDED_KEYIDENTIFIER_REF) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_EmbeddedKeyIdentifierRef.equals(keyIdentifier)) {
                 WSSUtils.createEmbeddedKeyIdentifierStructure(this, outputProcessorChain, securityToken.getTokenType(), tokenId);
-            } else if (keyIdentifierType == WSSConstants.WSSKeyIdentifierType.USERNAMETOKEN_REFERENCE) {
+            } else if (WSSecurityTokenConstants.KeyIdentifier_UsernameTokenReference.equals(keyIdentifier)) {
                 WSSUtils.createUsernameTokenReferenceStructure(this, outputProcessorChain, tokenId);
             } else {
-                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, "unsupportedSecurityToken", keyIdentifierType);
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, "unsupportedSecurityToken", keyIdentifier);
             }
             createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference);
         }

Added: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/DsaKeyValueSecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/DsaKeyValueSecurityTokenImpl.java?rev=1463136&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/DsaKeyValueSecurityTokenImpl.java (added)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/DsaKeyValueSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wss4j.stax.impl.securityToken;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.principal.PublicKeyPrincipalImpl;
+import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
+import org.apache.wss4j.stax.securityToken.DsaKeyValueSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
+import org.apache.xml.security.binding.xmldsig.DSAKeyValueType;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
+import javax.security.auth.Subject;
+import java.security.Principal;
+
+public class DsaKeyValueSecurityTokenImpl
+        extends org.apache.xml.security.stax.impl.securityToken.DsaKeyValueSecurityToken
+        implements DsaKeyValueSecurityToken {
+
+    private Principal principal;
+
+    public DsaKeyValueSecurityTokenImpl(
+            DSAKeyValueType dsaKeyValueType, WSInboundSecurityContext wsInboundSecurityContext,
+            WSSecurityTokenConstants.KeyIdentifier keyIdentifier) throws XMLSecurityException {
+        super(dsaKeyValueType, wsInboundSecurityContext, keyIdentifier);
+    }
+
+    @Override
+    public Subject getSubject() throws WSSecurityException {
+        return null;
+    }
+
+    @Override
+    public Principal getPrincipal() throws WSSecurityException {
+        if (this.principal == null) {
+            try {
+                this.principal = new PublicKeyPrincipalImpl(getPublicKey());
+            } catch (XMLSecurityException e) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, e);
+            }
+        }
+        return this.principal;
+    }
+}

Propchange: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/DsaKeyValueSecurityTokenImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ECKeyValueSecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ECKeyValueSecurityTokenImpl.java?rev=1463136&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ECKeyValueSecurityTokenImpl.java (added)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ECKeyValueSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wss4j.stax.impl.securityToken;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.principal.PublicKeyPrincipalImpl;
+import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
+import org.apache.wss4j.stax.securityToken.ECKeyValueSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
+import org.apache.xml.security.binding.xmldsig11.ECKeyValueType;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
+import javax.security.auth.Subject;
+import java.security.Principal;
+
+public class ECKeyValueSecurityTokenImpl
+        extends org.apache.xml.security.stax.impl.securityToken.ECKeyValueSecurityToken
+        implements ECKeyValueSecurityToken {
+
+    private Principal principal;
+
+    public ECKeyValueSecurityTokenImpl(
+            ECKeyValueType ecKeyValueType, WSInboundSecurityContext wsInboundSecurityContext,
+            WSSecurityTokenConstants.KeyIdentifier keyIdentifier) throws XMLSecurityException {
+        super(ecKeyValueType, wsInboundSecurityContext, keyIdentifier);
+    }
+
+    @Override
+    public Subject getSubject() throws WSSecurityException {
+        return null;
+    }
+
+    @Override
+    public Principal getPrincipal() throws WSSecurityException {
+        if (this.principal == null) {
+            try {
+                this.principal = new PublicKeyPrincipalImpl(getPublicKey());
+            } catch (XMLSecurityException e) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, e);
+            }
+        }
+        return this.principal;
+    }
+}

Propchange: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ECKeyValueSecurityTokenImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityTokenImpl.java (from r1460765, webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityToken.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityTokenImpl.java?p2=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityTokenImpl.java&p1=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityToken.java&r1=1460765&r2=1463136&rev=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/HttpsSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -18,18 +18,22 @@
  */
 package org.apache.wss4j.stax.impl.securityToken;
 
-import org.apache.wss4j.stax.ext.WSSConstants;
-import org.apache.wss4j.stax.ext.WSSecurityContext;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.stax.securityToken.HttpsSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.impl.securityToken.AbstractInboundSecurityToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
 
+import javax.security.auth.Subject;
 import java.security.Principal;
 import java.security.cert.X509Certificate;
 
-public class HttpsSecurityToken extends InboundSecurityTokenImpl {
+public class HttpsSecurityTokenImpl extends AbstractInboundSecurityToken implements HttpsSecurityToken {
 
     private String username;
     private final AuthenticationType authenticationType;
+    private Principal principal;
 
     private enum AuthenticationType {
         httpsClientAuthentication,
@@ -37,20 +41,18 @@ public class HttpsSecurityToken extends 
         httpDigestAuthentication,
     }
 
-    //todo the HttpsToken and the HttpsTokenSecEvent will be instantiated outside of wss4j so remove WSSecurityContext?
-    public HttpsSecurityToken(X509Certificate x509Certificate, WSSecurityContext wsSecurityContext)
+    public HttpsSecurityTokenImpl(X509Certificate x509Certificate)
             throws XMLSecurityException {
 
-        super(wsSecurityContext, IDGenerator.generateID(null), null);
+        super(null, IDGenerator.generateID(null), null);
         setX509Certificates(new X509Certificate[]{x509Certificate});
         this.authenticationType = AuthenticationType.httpsClientAuthentication;
     }
 
-    //todo the HttpsToken and the HttpsTokenSecEvent will be instantiated outside of wss4j so remove WSSecurityContext?
-    public HttpsSecurityToken(boolean basicAuthentication, String username, WSSecurityContext wsSecurityContext)
+    public HttpsSecurityTokenImpl(boolean basicAuthentication, String username)
             throws XMLSecurityException {
 
-        super(wsSecurityContext, IDGenerator.generateID(null), null);
+        super(null, IDGenerator.generateID(null), null);
         if (basicAuthentication) {
             this.authenticationType = AuthenticationType.httpBasicAuthentication;
         } else {
@@ -60,10 +62,11 @@ public class HttpsSecurityToken extends 
     }
 
     @Override
-    public WSSConstants.TokenType getTokenType() {
-        return WSSConstants.HttpsToken;
+    public WSSecurityTokenConstants.TokenType getTokenType() {
+        return WSSecurityTokenConstants.HttpsToken;
     }
 
+    //todo username from principal?
     public String getUsername() {
         return username;
     }
@@ -71,13 +74,25 @@ public class HttpsSecurityToken extends 
     public AuthenticationType getAuthenticationType() {
         return authenticationType;
     }
-    
+
     @Override
-    public Principal getPrincipal() throws XMLSecurityException {
-        X509Certificate[] certs = super.getX509Certificates();
-        if (certs != null && certs.length > 0) {
-            return certs[0].getSubjectX500Principal();
-        }
+    public Subject getSubject() throws WSSecurityException {
         return null;
     }
+
+    @Override
+    public Principal getPrincipal() throws WSSecurityException {
+        if (this.principal == null) {
+            try {
+                X509Certificate[] certs = getX509Certificates();
+                if (certs != null && certs.length > 0) {
+                    return this.principal = certs[0].getSubjectX500Principal();
+                }
+
+            } catch (XMLSecurityException e) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, e);
+            }
+        }
+        return this.principal;
+    }
 }

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java Mon Apr  1 13:57:32 2013
@@ -21,7 +21,7 @@ package org.apache.wss4j.stax.impl.secur
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.kerberos.KerberosClientAction;
 import org.apache.wss4j.common.kerberos.KerberosContextAndServiceNameCallback;
-import org.apache.wss4j.stax.ext.WSSConstants;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
 import org.apache.xml.security.stax.impl.securityToken.GenericOutboundSecurityToken;
@@ -46,7 +46,7 @@ public class KerberosClientSecurityToken
     private byte[] ticket;
 
     public KerberosClientSecurityToken(CallbackHandler callbackHandler, String id) throws XMLSecurityException {
-        super(id, WSSConstants.KerberosToken);
+        super(id, WSSecurityTokenConstants.KerberosToken);
         this.callbackHandler = callbackHandler;
     }
 

Copied: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java (from r1460765, webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityToken.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java?p2=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java&p1=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityToken.java&r1=1460765&r2=1463136&rev=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosServiceSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -23,11 +23,13 @@ import org.apache.wss4j.common.kerberos.
 import org.apache.wss4j.common.kerberos.KerberosServiceAction;
 import org.apache.wss4j.common.kerberos.KerberosTokenDecoder;
 import org.apache.wss4j.common.kerberos.KerberosTokenDecoderImpl;
-import org.apache.wss4j.stax.ext.WSSConstants;
-import org.apache.wss4j.stax.ext.WSSecurityContext;
+import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
+import org.apache.wss4j.stax.securityToken.KerberosServiceSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
 import org.apache.xml.security.stax.ext.XMLSecurityConstants;
+import org.apache.xml.security.stax.impl.securityToken.AbstractInboundSecurityToken;
 
 import javax.crypto.spec.SecretKeySpec;
 import javax.security.auth.Subject;
@@ -41,18 +43,20 @@ import java.security.Key;
 import java.security.Principal;
 import java.util.Set;
 
-public class KerberosServiceSecurityToken extends InboundSecurityTokenImpl {
+public class KerberosServiceSecurityTokenImpl extends AbstractInboundSecurityToken implements KerberosServiceSecurityToken {
 
     private CallbackHandler callbackHandler;
     private byte[] binaryContent;
     private String kerberosTokenValueType;
 
     private KerberosTokenDecoder kerberosTokenDecoder;
+    private Subject subject;
+    private Principal principal;
 
-    public KerberosServiceSecurityToken(WSSecurityContext wsSecurityContext, CallbackHandler callbackHandler,
-                                        byte[] binaryContent, String kerberosTokenValueType, String id,
-                                        WSSConstants.KeyIdentifierType keyIdentifierType) throws XMLSecurityException {
-        super(wsSecurityContext, id, keyIdentifierType);
+    public KerberosServiceSecurityTokenImpl(WSInboundSecurityContext wsInboundSecurityContext, CallbackHandler callbackHandler,
+                                            byte[] binaryContent, String kerberosTokenValueType, String id,
+                                            WSSecurityTokenConstants.KeyIdentifier keyIdentifier) throws XMLSecurityException {
+        super(wsInboundSecurityContext, id, keyIdentifier);
         this.callbackHandler = callbackHandler;
         this.binaryContent = binaryContent;
         this.kerberosTokenValueType = kerberosTokenValueType;
@@ -64,8 +68,8 @@ public class KerberosServiceSecurityToke
     }
 
     @Override
-    public XMLSecurityConstants.TokenType getTokenType() {
-        return WSSConstants.KerberosToken;
+    public WSSecurityTokenConstants.TokenType getTokenType() {
+        return WSSecurityTokenConstants.KerberosToken;
     }
 
     protected KerberosTokenDecoder getTGT() throws WSSecurityException {
@@ -84,8 +88,7 @@ public class KerberosServiceSecurityToke
             loginContext.login();
 
             // Get the service name to use - fall back on the principal
-            Subject subject = loginContext.getSubject();
-            setSubject(subject);
+            this.subject = loginContext.getSubject();
 
             String service = contextAndServiceNameCallback.getServiceName();
             if (service == null) {
@@ -102,13 +105,12 @@ public class KerberosServiceSecurityToke
 
             // Validate the ticket
             KerberosServiceAction action = new KerberosServiceAction(binaryContent, service);
-            Principal principal = Subject.doAs(subject, action);
-            if (principal == null) {
+            this.principal = Subject.doAs(subject, action);
+            if (this.principal == null) {
                 throw new WSSecurityException(
                         WSSecurityException.ErrorCode.FAILURE, "kerberosTicketValidationError"
                 );
             }
-            setPrincipal(principal);
 
             KerberosTokenDecoder kerberosTokenDecoder = new KerberosTokenDecoderImpl();
             kerberosTokenDecoder.setToken(binaryContent);
@@ -125,7 +127,7 @@ public class KerberosServiceSecurityToke
     }
 
     @Override
-    protected Key getKey(String algorithmURI, XMLSecurityConstants.KeyUsage keyUsage,
+    protected Key getKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algorithmUsage,
                          String correlationID) throws XMLSecurityException {
 
         Key key = getSecretKey().get(algorithmURI);
@@ -151,4 +153,14 @@ public class KerberosServiceSecurityToke
     public String getKerberosTokenValueType() {
         return kerberosTokenValueType;
     }
+
+    @Override
+    public Subject getSubject() throws WSSecurityException {
+        return subject;
+    }
+
+    @Override
+    public Principal getPrincipal() throws WSSecurityException {
+        return principal;
+    }
 }

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/OutboundUsernameSecurityToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/OutboundUsernameSecurityToken.java?rev=1463136&r1=1463135&r2=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/OutboundUsernameSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/OutboundUsernameSecurityToken.java Mon Apr  1 13:57:32 2013
@@ -18,45 +18,50 @@
  */
 package org.apache.wss4j.stax.impl.securityToken;
 
+import org.apache.wss4j.common.derivedKey.AlgoFactory;
+import org.apache.wss4j.common.derivedKey.ConversationConstants;
+import org.apache.wss4j.common.derivedKey.ConversationException;
+import org.apache.wss4j.common.derivedKey.DerivationAlgorithm;
+import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.stax.ext.WSSConstants;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
 import org.apache.xml.security.stax.impl.securityToken.GenericOutboundSecurityToken;
 
 import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
 import java.security.Key;
 
 public class OutboundUsernameSecurityToken extends GenericOutboundSecurityToken {
 
-    private final UsernameToken usernameToken;
-
-    public OutboundUsernameSecurityToken(String username, String password, String created, byte[] nonce, String id) {
-        super(id, WSSConstants.UsernameToken);
-        this.usernameToken = new UsernameToken(username, password, created, nonce, null, null);
+    private String username;
+    private String password;
+    private String createdTime;
+    private byte[] nonce;
+
+    public OutboundUsernameSecurityToken(String username, String password, String createdTime, byte[] nonce, String id) {
+        super(id, WSSecurityTokenConstants.UsernameToken);
+        this.username = username;
+        this.password = password;
+        this.createdTime = createdTime;
+        this.nonce = nonce;
     }
 
     public String getUsername() {
-        return usernameToken.getUsername();
+        return username;
     }
 
     public String getPassword() {
-        return usernameToken.getPassword();
+        return password;
     }
 
     public String getCreated() {
-        return usernameToken.getCreated();
+        return createdTime;
     }
 
     public byte[] getNonce() {
-        return usernameToken.getNonce();
-    }
-
-    public byte[] getSalt() {
-        return usernameToken.getSalt();
-    }
-
-    public Long getIteration() {
-        return usernameToken.getIteration();
+        return nonce;
     }
 
     @Override
@@ -66,10 +71,46 @@ public class OutboundUsernameSecurityTok
             return key;
         }
 
-        byte[] secretToken = usernameToken.getSecretKey(getPassword(), WSSConstants.WSE_DERIVED_KEY_LEN, WSSConstants.LABEL_FOR_DERIVED_KEY);
+        byte[] secretToken = getSecretKey(getPassword(), WSSConstants.WSE_DERIVED_KEY_LEN, WSSConstants.LABEL_FOR_DERIVED_KEY);
         String algoFamily = JCEAlgorithmMapper.getJCERequiredKeyFromURI(algorithmURI);
         key = new SecretKeySpec(secretToken, algoFamily);
         setSecretKey(algorithmURI, key);
         return key;
     }
+
+    /**
+     * Gets the secret key as per WS-Trust spec.
+     *
+     * @param keylen      How many bytes to generate for the key
+     * @param labelString the label used to generate the seed
+     * @return a secret key constructed from information contained in this
+     *         username token
+     */
+    protected byte[] getSecretKey(String rawPassword, int keylen, String labelString) throws WSSecurityException {
+        try {
+            byte[] password = rawPassword.getBytes("UTF-8");
+            byte[] label = labelString.getBytes("UTF-8");
+            byte[] nonce = getNonce();
+            byte[] created = getCreated().getBytes("UTF-8");
+            byte[] seed = new byte[label.length + nonce.length + created.length];
+
+            int offset = 0;
+            System.arraycopy(label, 0, seed, offset, label.length);
+            offset += label.length;
+
+            System.arraycopy(nonce, 0, seed, offset, nonce.length);
+            offset += nonce.length;
+
+            System.arraycopy(created, 0, seed, offset, created.length);
+
+            DerivationAlgorithm algo =
+                    AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
+            return algo.createKey(password, seed, 0, keylen);
+
+        } catch (UnsupportedEncodingException e) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
+        } catch (ConversationException e) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
+        }
+    }
 }

Added: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/RsaKeyValueSecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/RsaKeyValueSecurityTokenImpl.java?rev=1463136&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/RsaKeyValueSecurityTokenImpl.java (added)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/RsaKeyValueSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wss4j.stax.impl.securityToken;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.principal.PublicKeyPrincipalImpl;
+import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
+import org.apache.wss4j.stax.securityToken.RsaKeyValueSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
+import org.apache.xml.security.binding.xmldsig.RSAKeyValueType;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+
+import javax.security.auth.Subject;
+import java.security.Principal;
+
+public class RsaKeyValueSecurityTokenImpl
+        extends org.apache.xml.security.stax.impl.securityToken.RsaKeyValueSecurityToken
+        implements RsaKeyValueSecurityToken {
+
+    private Principal principal;
+
+    public RsaKeyValueSecurityTokenImpl(
+            RSAKeyValueType rsaKeyValueType, WSInboundSecurityContext wsInboundSecurityContext,
+            WSSecurityTokenConstants.KeyIdentifier keyIdentifier) throws XMLSecurityException {
+        super(rsaKeyValueType, wsInboundSecurityContext, keyIdentifier);
+    }
+
+    @Override
+    public Subject getSubject() throws WSSecurityException {
+        return null;
+    }
+
+    @Override
+    public Principal getPrincipal() throws WSSecurityException {
+        if (this.principal == null) {
+            try {
+                this.principal = new PublicKeyPrincipalImpl(getPublicKey());
+            } catch (XMLSecurityException e) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, e);
+            }
+        }
+        return this.principal;
+    }
+}

Propchange: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/RsaKeyValueSecurityTokenImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java (from r1460765, webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SAMLSecurityToken.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java?p2=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java&p1=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SAMLSecurityToken.java&r1=1460765&r2=1463136&rev=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SAMLSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SamlSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -22,14 +22,17 @@ import org.apache.wss4j.common.crypto.Cr
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.principal.SAMLTokenPrincipal;
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
-import org.apache.wss4j.stax.ext.WSSConstants;
+import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
-import org.apache.wss4j.stax.ext.WSSecurityContext;
+import org.apache.wss4j.stax.securityToken.SamlSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.SecurityToken;
 import org.apache.xml.security.stax.ext.XMLSecurityConstants;
+import org.apache.xml.security.stax.impl.securityToken.AbstractInboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
 import org.opensaml.common.SAMLVersion;
 
+import javax.security.auth.Subject;
 import java.security.Key;
 import java.security.Principal;
 import java.security.PublicKey;
@@ -37,18 +40,19 @@ import java.security.cert.CertificateExp
 import java.security.cert.CertificateNotYetValidException;
 import java.security.cert.X509Certificate;
 
-public class SAMLSecurityToken extends InboundSecurityTokenImpl {
+public class SamlSecurityTokenImpl extends AbstractInboundSecurityToken implements SamlSecurityToken {
 
     private final SamlAssertionWrapper samlAssertionWrapper;
-    private SecurityToken subjectSecurityToken;
+    private InboundSecurityToken subjectSecurityToken;
     private Crypto crypto;
     private WSSSecurityProperties securityProperties;
+    private Principal principal;
 
-    public SAMLSecurityToken(SamlAssertionWrapper samlAssertionWrapper, SecurityToken subjectSecurityToken,
-                             WSSecurityContext wsSecurityContext, Crypto crypto,
-                             String id, WSSConstants.KeyIdentifierType keyIdentifierType,
-                             WSSSecurityProperties securityProperties) {
-        super(wsSecurityContext, id, keyIdentifierType);
+    public SamlSecurityTokenImpl(SamlAssertionWrapper samlAssertionWrapper, InboundSecurityToken subjectSecurityToken,
+                                 WSInboundSecurityContext wsInboundSecurityContext, Crypto crypto,
+                                 WSSecurityTokenConstants.KeyIdentifier keyIdentifier,
+                                 WSSSecurityProperties securityProperties) {
+        super(wsInboundSecurityContext, samlAssertionWrapper.getId(), keyIdentifier);
         this.samlAssertionWrapper = samlAssertionWrapper;
         this.crypto = crypto;
         this.subjectSecurityToken = subjectSecurityToken;
@@ -64,19 +68,19 @@ public class SAMLSecurityToken extends I
     }
 
     @Override
-    protected Key getKey(String algorithmURI, XMLSecurityConstants.KeyUsage keyUsage, String correlationID) throws XMLSecurityException {
+    protected Key getKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algorithmUsage, String correlationID) throws XMLSecurityException {
         if (this.subjectSecurityToken != null) {
-            return subjectSecurityToken.getSecretKey(algorithmURI, keyUsage, correlationID);
+            return subjectSecurityToken.getSecretKey(algorithmURI, algorithmUsage, correlationID);
         }
-        return super.getKey(algorithmURI, keyUsage, correlationID);
+        return super.getKey(algorithmURI, algorithmUsage, correlationID);
     }
 
     @Override
-    protected PublicKey getPubKey(String algorithmURI, XMLSecurityConstants.KeyUsage keyUsage, String correlationID) throws XMLSecurityException {
+    protected PublicKey getPubKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algorithmUsage, String correlationID) throws XMLSecurityException {
         if (this.subjectSecurityToken != null) {
-            return subjectSecurityToken.getPublicKey(algorithmURI, keyUsage, correlationID);
+            return subjectSecurityToken.getPublicKey(algorithmURI, algorithmUsage, correlationID);
         }
-        return super.getPubKey(algorithmURI, keyUsage, correlationID);
+        return super.getPubKey(algorithmURI, algorithmUsage, correlationID);
     }
 
     @Override
@@ -95,10 +99,6 @@ public class SAMLSecurityToken extends I
         return super.getX509Certificates();
     }
 
-    public Crypto getCrypto() {
-        return crypto;
-    }
-
     @Override
     public void verify() throws XMLSecurityException {
         //todo revisit verify for every security token incl. public-key
@@ -112,11 +112,11 @@ public class SAMLSecurityToken extends I
                 if (securityProperties != null) {
                     enableRevocation = securityProperties.isEnableRevocation();
                 }
-                getCrypto().verifyTrust(x509Certificates, enableRevocation);
+                crypto.verifyTrust(x509Certificates, enableRevocation);
             }
             PublicKey publicKey = getPublicKey();
             if (publicKey != null) {
-                getCrypto().verifyTrust(publicKey);
+                crypto.verifyTrust(publicKey);
             }
         } catch (CertificateExpiredException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION, e);
@@ -126,32 +126,40 @@ public class SAMLSecurityToken extends I
     }
 
     @Override
-    public XMLSecurityConstants.TokenType getTokenType() {
+    public WSSecurityTokenConstants.TokenType getTokenType() {
         if (samlAssertionWrapper.getSamlVersion() == SAMLVersion.VERSION_10) {
-            return WSSConstants.Saml10Token;
+            return WSSecurityTokenConstants.Saml10Token;
         } else if (samlAssertionWrapper.getSamlVersion() == SAMLVersion.VERSION_11) {
-            return WSSConstants.Saml11Token;
+            return WSSecurityTokenConstants.Saml11Token;
         }
-        return WSSConstants.Saml20Token;
-    }
-
-    public SAMLVersion getSamlVersion() {
-        return samlAssertionWrapper.getSamlVersion();
+        return WSSecurityTokenConstants.Saml20Token;
     }
 
-    public String getIssuer() {
-        return samlAssertionWrapper.getIssuerString();
+    @Override
+    public Subject getSubject() throws WSSecurityException {
+        return null;
     }
 
-    public SamlAssertionWrapper getSamlAssertionWrapper() {
-        return samlAssertionWrapper;
-    }
-    
     @Override
-    public Principal getPrincipal() {
-        if (samlAssertionWrapper != null) {
-            return new SAMLTokenPrincipal(samlAssertionWrapper);
+    public Principal getPrincipal() throws WSSecurityException {
+        if (this.principal == null) {
+            this.principal = new SAMLTokenPrincipal() {
+                @Override
+                public SamlAssertionWrapper getToken() {
+                    return samlAssertionWrapper;
+                }
+
+                @Override
+                public String getName() {
+                    return samlAssertionWrapper.getSubjectName();
+                }
+
+                @Override
+                public String getId() {
+                    return samlAssertionWrapper.getId();
+                }
+            };
         }
-        return null;
+        return this.principal;
     }
 }

Copied: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityTokenImpl.java (from r1460765, webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityToken.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityTokenImpl.java?p2=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityTokenImpl.java&p1=webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityToken.java&r1=1460765&r2=1463136&rev=1463136&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityToken.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityTokenImpl.java Mon Apr  1 13:57:32 2013
@@ -18,22 +18,22 @@
  */
 package org.apache.wss4j.stax.impl.securityToken;
 
-import org.apache.wss4j.stax.ext.WSSConstants;
-import org.apache.wss4j.stax.ext.WSSecurityContext;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
+import org.apache.wss4j.stax.ext.WSInboundSecurityContext;
+import org.apache.wss4j.stax.securityToken.SecureConversationSecurityToken;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
+import org.apache.xml.security.stax.impl.securityToken.AbstractInboundSecurityToken;
 
 
-public class SecureConversationSecurityToken extends InboundSecurityTokenImpl {
-
-    //todo implement
-
-    public SecureConversationSecurityToken(WSSecurityContext wsSecurityContext, String id,
-                                           WSSConstants.KeyIdentifierType keyIdentifierType) {
-        super(wsSecurityContext, id, keyIdentifierType);
+public class SecureConversationSecurityTokenImpl
+        extends AbstractInboundSecurityToken implements SecureConversationSecurityToken {
+
+    public SecureConversationSecurityTokenImpl(WSInboundSecurityContext wsInboundSecurityContext, String id,
+                                               WSSecurityTokenConstants.KeyIdentifier keyIdentifier) {
+        super(wsInboundSecurityContext, id, keyIdentifier);
     }
 
     @Override
-    public XMLSecurityConstants.TokenType getTokenType() {
-        return WSSConstants.SecureConversationToken;
+    public WSSecurityTokenConstants.TokenType getTokenType() {
+        return WSSecurityTokenConstants.SecureConversationToken;
     }
 }



Mime
View raw message