Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5774A1017C for ; Mon, 9 Dec 2013 17:00:39 +0000 (UTC) Received: (qmail 36744 invoked by uid 500); 9 Dec 2013 17:00:38 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 36677 invoked by uid 500); 9 Dec 2013 17:00:37 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 36670 invoked by uid 99); 9 Dec 2013 17:00:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Dec 2013 17:00:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Dec 2013 17:00:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 947252388B71; Mon, 9 Dec 2013 17:00:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1549617 - in /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers: AbstractStaxBindingHandler.java StaxAsymmetricBindingHandler.java StaxSymmetricBindingHandler.java Date: Mon, 09 Dec 2013 17:00:12 -0000 To: commits@cxf.apache.org From: coheigea@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131209170012.947252388B71@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: coheigea Date: Mon Dec 9 17:00:12 2013 New Revision: 1549617 URL: http://svn.apache.org/r1549617 Log: Minor refactor Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxAsymmetricBindingHandler.java cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxSymmetricBindingHandler.java Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java?rev=1549617&r1=1549616&r2=1549617&view=diff ============================================================================== --- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java (original) +++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractStaxBindingHandler.java Mon Dec 9 17:00:12 2013 @@ -86,7 +86,6 @@ import org.apache.wss4j.policy.model.X50 import org.apache.wss4j.policy.model.X509Token.TokenType; import org.apache.wss4j.policy.model.XPath; import org.apache.wss4j.policy.stax.PolicyUtils; -import org.apache.wss4j.stax.ConfigurationConverter; import org.apache.wss4j.stax.ext.WSSConstants; import org.apache.wss4j.stax.ext.WSSConstants.UsernameTokenPasswordType; import org.apache.wss4j.stax.ext.WSSSecurityProperties; @@ -142,8 +141,7 @@ public abstract class AbstractStaxBindin } // Action - WSSConstants.Action actionToPerform = WSSConstants.USERNAMETOKEN; - properties.addAction(actionToPerform); + properties.addAction(WSSConstants.USERNAMETOKEN); // Password Type PasswordType passwordType = usernameToken.getPasswordType(); @@ -254,8 +252,7 @@ public abstract class AbstractStaxBindin } // Action - WSSConstants.Action actionToPerform = WSSConstants.KERBEROS_TOKEN; - properties.addAction(actionToPerform); + properties.addAction(WSSConstants.KERBEROS_TOKEN); /* if (endorsing) { @@ -510,8 +507,7 @@ public abstract class AbstractStaxBindin } } - properties.setSignatureKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier(getKeyIdentifierType(wrapper, token))); + properties.setSignatureKeyIdentifier(getKeyIdentifierType(wrapper, token)); // Find out do we also need to include the token as per the Inclusion requirement WSSecurityTokenConstants.KeyIdentifier keyIdentifier = properties.getSignatureKeyIdentifier(); @@ -549,20 +545,21 @@ public abstract class AbstractStaxBindin } - protected String getKeyIdentifierType(AbstractTokenWrapper wrapper, AbstractToken token) { - - String identifier = null; + protected WSSecurityTokenConstants.KeyIdentifier getKeyIdentifierType( + AbstractTokenWrapper wrapper, AbstractToken token + ) { + WSSecurityTokenConstants.KeyIdentifier identifier = null; if (token instanceof X509Token) { X509Token x509Token = (X509Token)token; if (x509Token.isRequireIssuerSerialReference()) { - identifier = "IssuerSerial"; + identifier = WSSecurityTokenConstants.KeyIdentifier_IssuerSerial; } else if (x509Token.isRequireKeyIdentifierReference()) { - identifier = "SKIKeyIdentifier"; + identifier = WSSecurityTokenConstants.KeyIdentifier_SkiKeyIdentifier; } else if (x509Token.isRequireThumbprintReference()) { - identifier = "Thumbprint"; + identifier = WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier; } } else if (token instanceof KeyValueToken) { - identifier = "KeyValue"; + identifier = WSSecurityTokenConstants.KeyIdentifier_KeyValue; } if (identifier != null) { @@ -572,18 +569,18 @@ public abstract class AbstractStaxBindin if (token.getIncludeTokenType() == IncludeTokenType.INCLUDE_TOKEN_NEVER) { Wss10 wss = getWss10(); if (wss == null || wss.isMustSupportRefKeyIdentifier()) { - return "SKIKeyIdentifier"; + return WSSecurityTokenConstants.KeyIdentifier_SkiKeyIdentifier; } else if (wss.isMustSupportRefIssuerSerial()) { - return "IssuerSerial"; + return WSSecurityTokenConstants.KeyIdentifier_IssuerSerial; } else if (wss instanceof Wss11 && ((Wss11) wss).isMustSupportRefThumbprint()) { - return "Thumbprint"; + return WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier; } } else { - return "DirectReference"; + return WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference; } - return "IssuerSerial"; + return WSSecurityTokenConstants.KeyIdentifier_IssuerSerial; } protected Map handleSupportingTokens( Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxAsymmetricBindingHandler.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxAsymmetricBindingHandler.java?rev=1549617&r1=1549616&r2=1549617&view=diff ============================================================================== --- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxAsymmetricBindingHandler.java (original) +++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxAsymmetricBindingHandler.java Mon Dec 9 17:00:12 2013 @@ -51,7 +51,6 @@ import org.apache.wss4j.policy.model.Sec import org.apache.wss4j.policy.model.SecurityContextToken; import org.apache.wss4j.policy.model.SpnegoContextToken; import org.apache.wss4j.policy.model.X509Token; -import org.apache.wss4j.stax.ConfigurationConverter; import org.apache.wss4j.stax.ext.WSSConstants; import org.apache.wss4j.stax.ext.WSSSecurityProperties; import org.apache.xml.security.stax.ext.SecurePart; @@ -358,8 +357,7 @@ public class StaxAsymmetricBindingHandle properties.addEncryptionPart(encPart); } - properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier(getKeyIdentifierType(recToken, encrToken))); + properties.setEncryptionKeyIdentifier(getKeyIdentifierType(recToken, encrToken)); properties.setEncryptionKeyTransportAlgorithm( algorithmSuite.getAlgorithmSuiteType().getAsymmetricKeyWrap()); Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxSymmetricBindingHandler.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxSymmetricBindingHandler.java?rev=1549617&r1=1549616&r2=1549617&view=diff ============================================================================== --- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxSymmetricBindingHandler.java (original) +++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/StaxSymmetricBindingHandler.java Mon Dec 9 17:00:12 2013 @@ -57,10 +57,10 @@ import org.apache.wss4j.policy.model.Spn import org.apache.wss4j.policy.model.SymmetricBinding; import org.apache.wss4j.policy.model.UsernameToken; import org.apache.wss4j.policy.model.X509Token; -import org.apache.wss4j.stax.ConfigurationConverter; import org.apache.wss4j.stax.ext.WSSConstants; import org.apache.wss4j.stax.ext.WSSSecurityProperties; import org.apache.wss4j.stax.securityEvent.WSSecurityEventConstants; +import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants; import org.apache.xml.security.algorithms.JCEMapper; import org.apache.xml.security.exceptions.XMLSecurityException; import org.apache.xml.security.stax.ext.SecurePart; @@ -398,10 +398,10 @@ public class StaxSymmetricBindingHandler actionToPerform = WSSConstants.ENCRYPT_WITH_DERIVED_KEY; if (MessageUtils.isRequestor(message) && recToken.getToken() instanceof X509Token) { properties.setDerivedKeyTokenReference( - ConfigurationConverter.convertDerivedReference("EncryptedKey")); + WSSConstants.DerivedKeyTokenReference.EncryptedKey); } else { properties.setDerivedKeyTokenReference( - ConfigurationConverter.convertDerivedReference("DirectReference")); + WSSConstants.DerivedKeyTokenReference.DirectReference); } AlgorithmSuiteType algSuiteType = sbinding.getAlgorithmSuite().getAlgorithmSuiteType(); properties.setDerivedEncryptionKeyLength( @@ -419,33 +419,31 @@ public class StaxSymmetricBindingHandler properties.addAction(actionToPerform); if (isRequestor()) { - properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier( - getKeyIdentifierType(recToken, encrToken))); + properties.setEncryptionKeyIdentifier(getKeyIdentifierType(recToken, encrToken)); properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } else if (recToken.getToken() instanceof KerberosToken && !isRequestor()) { properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("KerberosSHA1")); + WSSecurityTokenConstants.KeyIdentifier_KerberosSha1Identifier); properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("KerberosSHA1")); + WSSecurityTokenConstants.KeyIdentifier_KerberosSha1Identifier); if (recToken.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) { properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } } else if ((recToken.getToken() instanceof IssuedToken || recToken.getToken() instanceof SecureConversationToken || recToken.getToken() instanceof SpnegoContextToken) && !isRequestor()) { properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } else { properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("EncryptedKeySHA1")); + WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier); if (recToken.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) { properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("EncryptedKeySHA1")); + WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier); properties.setEncryptionKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); properties.setEncryptSymmetricEncryptionKey(false); } } @@ -485,10 +483,10 @@ public class StaxSymmetricBindingHandler actionToPerform = WSSConstants.SIGNATURE_WITH_DERIVED_KEY; if (MessageUtils.isRequestor(message) && policyToken instanceof X509Token) { properties.setDerivedKeyTokenReference( - ConfigurationConverter.convertDerivedReference("EncryptedKey")); + WSSConstants.DerivedKeyTokenReference.EncryptedKey); } else { properties.setDerivedKeyTokenReference( - ConfigurationConverter.convertDerivedReference("DirectReference")); + WSSConstants.DerivedKeyTokenReference.DirectReference); } AlgorithmSuiteType algSuiteType = sbinding.getAlgorithmSuite().getAlgorithmSuiteType(); properties.setDerivedSignatureKeyLength( @@ -532,31 +530,31 @@ public class StaxSymmetricBindingHandler properties.setIncludeSignatureToken(false); if (isRequestor()) { properties.setSignatureKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("EncryptedKey")); + WSSecurityTokenConstants.KeyIdentifier_EncryptedKey); } else { properties.setSignatureKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("EncryptedKeySHA1")); + WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier); if (wrapper.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) { properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("EncryptedKeySHA1")); + WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier); properties.setSignatureKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } } } else if (policyToken instanceof KerberosToken) { if (isRequestor()) { properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } else { if (wrapper.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) { properties.setSignatureKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } else { properties.setSignatureKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("KerberosSHA1")); + WSSecurityTokenConstants.KeyIdentifier_KerberosSha1Identifier); } properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("KerberosSHA1")); + WSSecurityTokenConstants.KeyIdentifier_KerberosSha1Identifier); } } else if (policyToken instanceof IssuedToken || policyToken instanceof SecurityContextToken || policyToken instanceof SecureConversationToken || policyToken instanceof SpnegoContextToken) { @@ -566,7 +564,7 @@ public class StaxSymmetricBindingHandler properties.setIncludeSignatureToken(true); } properties.setDerivedKeyKeyIdentifier( - ConfigurationConverter.convertKeyIdentifier("DirectReference")); + WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference); } if (sigToken.getDerivedKeys() == DerivedKeys.RequireDerivedKeys) {