ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1333877 - in /webservices/wss4j/trunk/src/main/java/org/apache/ws/security: components/crypto/ conversation/ message/token/ saml/ saml/ext/ saml/ext/builder/ transform/ validate/
Date Fri, 04 May 2012 11:06:15 GMT
Author: coheigea
Date: Fri May  4 11:06:15 2012
New Revision: 1333877

URL: http://svn.apache.org/viewvc?rev=1333877&view=rev
Log:
More cleanup

Modified:
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Merlin.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/conversation/ConversationException.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityTokenReference.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/AssertionWrapper.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML1ComponentBuilder.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML2ComponentBuilder.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Merlin.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Merlin.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Merlin.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/components/crypto/Merlin.java
Fri May  4 11:06:15 2012
@@ -1349,7 +1349,7 @@ public class Merlin extends CryptoBase {
                 if (!(retrievedCert instanceof X509Certificate)) {
                     continue;
                 }
-                if (retrievedCert != null && retrievedCert.equals(cert)) {
+                if (retrievedCert.equals(cert)) {
                     return alias;
                 }
             }

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/conversation/ConversationException.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/conversation/ConversationException.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/conversation/ConversationException.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/conversation/ConversationException.java
Fri May  4 11:06:15 2012
@@ -96,7 +96,7 @@ public class ConversationException exten
         } catch (MissingResourceException e) {
             throw new RuntimeException("Undefined '" + faultCode + "' resource property",
e);
         }
-        if(msg != null) {
+        if (msg != null) {
             return msg;
         } else {
             return faultCode;

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityTokenReference.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityTokenReference.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityTokenReference.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityTokenReference.java
Fri May  4 11:06:15 2012
@@ -65,7 +65,6 @@ public class SecurityTokenReference {
     protected Element element = null;
     private DOMX509IssuerSerial issuerSerial = null;
     private byte[] skiBytes = null;
-    private static boolean doDebug = false;
     private Reference reference = null;
 
     /**
@@ -87,7 +86,6 @@ public class SecurityTokenReference {
      * @throws WSSecurityException
      */
     public SecurityTokenReference(Element elem, boolean bspCompliant) throws WSSecurityException
{
-        doDebug = log.isDebugEnabled();
         element = elem;
         QName el = new QName(element.getNamespaceURI(), element.getLocalName());
         if (!STR_QNAME.equals(el)) {
@@ -116,7 +114,6 @@ public class SecurityTokenReference {
      * @param doc The Document
      */
     public SecurityTokenReference(Document doc) {
-        doDebug = log.isDebugEnabled();
         element = doc.createElementNS(WSConstants.WSSE_NS, "wsse:SecurityTokenReference");
     }
     
@@ -217,7 +214,7 @@ public class SecurityTokenReference {
             uri = getKeyIdentifierValue();
             valueType = getKeyIdentifierValueType();
         }
-        if (doDebug) {
+        if (log.isDebugEnabled()) {
             log.debug("Token reference uri: " + uri);
         }
         

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/WSSecSignatureSAML.java
Fri May  4 11:06:15 2012
@@ -279,6 +279,10 @@ public class WSSecSignatureSAML extends 
                 key = certs[0].getPublicKey();
             } else if (publicKey != null) {
                 key = publicKey;
+            } else {
+                throw new WSSecurityException(
+                    WSSecurityException.FAILURE, "unknownSignatureAlgorithm"
+                );
             }
             
             String pubKeyAlgo = key.getAlgorithm();

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/AssertionWrapper.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/AssertionWrapper.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/AssertionWrapper.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/AssertionWrapper.java
Fri May  4 11:06:15 2012
@@ -191,7 +191,7 @@ public class AssertionWrapper {
         } else {
             log.error(
                 "AssertionWrapper: found unexpected type " 
-                + (xmlObject != null ? xmlObject.getClass().getName() : xmlObject)
+                + (xmlObject != null ? xmlObject.getClass().getName() : null)
             );
         }
     }
@@ -214,12 +214,8 @@ public class AssertionWrapper {
 
         try {
             // Get the SAML source data using the currently configured callback implementation.
-            if (samlCallbackHandler == null) {
-                samlCallbackHandler = parms.getCallbackHandler();
-            }
-
+            samlCallbackHandler = parms.getCallbackHandler();
             samlCallbackHandler.handle(samlCallbacks);
-
         } catch (IOException e) {
             throw new IllegalStateException(
                 "IOException while creating SAML assertion wrapper", e

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML1ComponentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML1ComponentBuilder.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML1ComponentBuilder.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML1ComponentBuilder.java
Fri May  4 11:06:15 2012
@@ -74,40 +74,40 @@ import java.util.List;
  */
 public class SAML1ComponentBuilder {
     
-    private static SAMLObjectBuilder<Assertion> assertionV1Builder;
+    private static volatile SAMLObjectBuilder<Assertion> assertionV1Builder;
     
-    private static SAMLObjectBuilder<Conditions> conditionsV1Builder;
+    private static volatile SAMLObjectBuilder<Conditions> conditionsV1Builder;
     
-    private static SAMLObjectBuilder<AudienceRestrictionCondition> audienceRestrictionV1Builder;
+    private static volatile SAMLObjectBuilder<AudienceRestrictionCondition> audienceRestrictionV1Builder;
     
-    private static SAMLObjectBuilder<Audience> audienceV1Builder;
+    private static volatile SAMLObjectBuilder<Audience> audienceV1Builder;
     
-    private static SAMLObjectBuilder<AuthenticationStatement> authenticationStatementV1Builder;
+    private static volatile SAMLObjectBuilder<AuthenticationStatement> authenticationStatementV1Builder;
     
-    private static SAMLObjectBuilder<Subject> subjectV1Builder;
+    private static volatile SAMLObjectBuilder<Subject> subjectV1Builder;
     
-    private static SAMLObjectBuilder<NameIdentifier> nameIdentifierV1Builder;
+    private static volatile SAMLObjectBuilder<NameIdentifier> nameIdentifierV1Builder;
     
-    private static SAMLObjectBuilder<SubjectConfirmation> 
+    private static volatile SAMLObjectBuilder<SubjectConfirmation> 
         subjectConfirmationV1Builder;
     
-    private static SAMLObjectBuilder<ConfirmationMethod> confirmationMethodV1Builder;
+    private static volatile SAMLObjectBuilder<ConfirmationMethod> confirmationMethodV1Builder;
     
-    private static SAMLObjectBuilder<AttributeStatement> 
+    private static volatile SAMLObjectBuilder<AttributeStatement> 
         attributeStatementV1Builder;
     
-    private static SAMLObjectBuilder<Attribute> attributeV1Builder;
+    private static volatile SAMLObjectBuilder<Attribute> attributeV1Builder;
     
-    private static XSStringBuilder stringBuilder;
+    private static volatile XSStringBuilder stringBuilder;
     
-    private static SAMLObjectBuilder<AuthorizationDecisionStatement> 
+    private static volatile SAMLObjectBuilder<AuthorizationDecisionStatement> 
         authorizationDecisionStatementV1Builder;
     
-    private static SAMLObjectBuilder<Action> actionElementV1Builder;
+    private static volatile SAMLObjectBuilder<Action> actionElementV1Builder;
     
-    private static XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
+    private static volatile XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
     
-    private static SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
+    private static volatile SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
 
     /**
      * Create a new SAML 1.1 assertion

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML2ComponentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML2ComponentBuilder.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML2ComponentBuilder.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/ext/builder/SAML2ComponentBuilder.java
Fri May  4 11:06:15 2012
@@ -76,45 +76,45 @@ import java.util.List;
  * Created on May 18, 2009
  */
 public class SAML2ComponentBuilder {
-    private static SAMLObjectBuilder<Assertion> assertionBuilder;
+    private static volatile SAMLObjectBuilder<Assertion> assertionBuilder;
     
-    private static SAMLObjectBuilder<Issuer> issuerBuilder;
+    private static volatile SAMLObjectBuilder<Issuer> issuerBuilder;
     
-    private static SAMLObjectBuilder<Subject> subjectBuilder;
+    private static volatile SAMLObjectBuilder<Subject> subjectBuilder;
     
-    private static SAMLObjectBuilder<NameID> nameIdBuilder;
+    private static volatile SAMLObjectBuilder<NameID> nameIdBuilder;
     
-    private static SAMLObjectBuilder<SubjectConfirmation> subjectConfirmationBuilder;
+    private static volatile SAMLObjectBuilder<SubjectConfirmation> subjectConfirmationBuilder;
     
-    private static SAMLObjectBuilder<Conditions> conditionsBuilder;
+    private static volatile SAMLObjectBuilder<Conditions> conditionsBuilder;
     
-    private static SAMLObjectBuilder<SubjectConfirmationData> subjectConfirmationDataBuilder;
+    private static volatile SAMLObjectBuilder<SubjectConfirmationData> subjectConfirmationDataBuilder;
     
-    private static SAMLObjectBuilder<KeyInfoConfirmationDataType> keyInfoConfirmationDataBuilder;
+    private static volatile SAMLObjectBuilder<KeyInfoConfirmationDataType> keyInfoConfirmationDataBuilder;
     
-    private static SAMLObjectBuilder<AuthnStatement> authnStatementBuilder;
+    private static volatile SAMLObjectBuilder<AuthnStatement> authnStatementBuilder;
     
-    private static SAMLObjectBuilder<AuthnContext> authnContextBuilder;
+    private static volatile SAMLObjectBuilder<AuthnContext> authnContextBuilder;
     
-    private static SAMLObjectBuilder<AuthnContextClassRef> authnContextClassRefBuilder;
+    private static volatile SAMLObjectBuilder<AuthnContextClassRef> authnContextClassRefBuilder;
     
-    private static SAMLObjectBuilder<AttributeStatement> attributeStatementBuilder;
+    private static volatile SAMLObjectBuilder<AttributeStatement> attributeStatementBuilder;
     
-    private static SAMLObjectBuilder<Attribute> attributeBuilder;
+    private static volatile SAMLObjectBuilder<Attribute> attributeBuilder;
     
-    private static XSStringBuilder stringBuilder;
+    private static volatile XSStringBuilder stringBuilder;
     
-    private static SAMLObjectBuilder<AudienceRestriction> audienceRestrictionBuilder;
+    private static volatile SAMLObjectBuilder<AudienceRestriction> audienceRestrictionBuilder;
     
-    private static SAMLObjectBuilder<Audience> audienceBuilder;
+    private static volatile SAMLObjectBuilder<Audience> audienceBuilder;
     
-    private static SAMLObjectBuilder<AuthzDecisionStatement> authorizationDecisionStatementBuilder;
+    private static volatile SAMLObjectBuilder<AuthzDecisionStatement> authorizationDecisionStatementBuilder;
     
-    private static SAMLObjectBuilder<Action> actionElementBuilder;
+    private static volatile SAMLObjectBuilder<Action> actionElementBuilder;
     
-    private static XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
+    private static volatile XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
     
-    private static SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
+    private static volatile SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
 
     /**
      * Create a SAML 2 assertion

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/transform/STRTransform.java
Fri May  4 11:06:15 2012
@@ -85,6 +85,9 @@ public class STRTransform extends Transf
             throw new ClassCastException
                 ("context must be of type DOMCryptoContext");
         }
+        if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
+            throw new ClassCastException("parent must be of type DOMStructure");
+        }
         transformElement = (Element) 
             ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
     }
@@ -95,6 +98,9 @@ public class STRTransform extends Transf
             throw new ClassCastException
                 ("context must be of type DOMCryptoContext");
         }
+        if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
+            throw new ClassCastException("parent must be of type DOMStructure");
+        }
         Element transformElement2 = (Element) 
             ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
         appendChild(transformElement2, transformElement);

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java?rev=1333877&r1=1333876&r2=1333877&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java
(original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java
Fri May  4 11:06:15 2012
@@ -302,13 +302,16 @@ public class SignatureTrustValidator imp
         Crypto crypto,
         boolean enableRevocation
     ) throws WSSecurityException {
+        if (certificates == null || certificates.length < 2) {
+            return false;
+        }
+        
         String subjectString = certificates[0].getSubjectX500Principal().getName();
         //
         // Use the validation method from the crypto to check whether the subjects' 
         // certificate was really signed by the issuer stated in the certificate
         //
-        if (certificates != null && certificates.length > 1
-            && crypto.verifyTrust(certificates, enableRevocation)) {
+        if (crypto.verifyTrust(certificates, enableRevocation)) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug(
                     "Certificate path has been verified for certificate with subject " 



Mime
View raw message