ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1659609 - /webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java
Date Fri, 13 Feb 2015 17:11:25 GMT
Author: coheigea
Date: Fri Feb 13 17:11:25 2015
New Revision: 1659609

URL: http://svn.apache.org/r1659609
Log:
Fixing KeyInfo generation for PublicKeys

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java?rev=1659609&r1=1659608&r2=1659609&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java
Fri Feb 13 17:11:25 2015
@@ -65,6 +65,7 @@ import org.opensaml.saml.saml1.core.Subj
 import org.opensaml.saml.saml1.core.SubjectLocality;
 import org.opensaml.security.credential.BasicCredential;
 import org.opensaml.security.x509.BasicX509Credential;
+import org.opensaml.xmlsec.keyinfo.impl.BasicKeyInfoGeneratorFactory;
 import org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory;
 import org.opensaml.xmlsec.signature.KeyInfo;
 import org.w3c.dom.Element;
@@ -215,31 +216,36 @@ public final class SAML1ComponentBuilder
             return (KeyInfo)OpenSAMLUtil.fromDom(keyInfo.getElement());
         } else {
             // Set the certificate or public key
-            BasicCredential keyInfoCredential = null;
             if (keyInfo.getCertificate() != null) {
-                keyInfoCredential = new BasicX509Credential(keyInfo.getCertificate());
-            } else if (keyInfo.getPublicKey() != null) {
-                keyInfoCredential = new BasicCredential(keyInfo.getPublicKey());
-            }
-            
-            // Configure how to emit the certificate
-            X509KeyInfoGeneratorFactory kiFactory = new X509KeyInfoGeneratorFactory();
-            KeyInfoBean.CERT_IDENTIFIER certIdentifier = keyInfo.getCertIdentifer();
-            switch (certIdentifier) {
-                case X509_CERT: {
-                    kiFactory.setEmitEntityCertificate(true);
-                    break;
-                }
-                case KEY_VALUE: {
-                    kiFactory.setEmitPublicKeyValue(true);
-                    break;
-                }
-                case X509_ISSUER_SERIAL: {
-                    kiFactory.setEmitX509IssuerSerial(true);
+                BasicCredential keyInfoCredential = new BasicX509Credential(keyInfo.getCertificate());
+                
+                // Configure how to emit the certificate
+                X509KeyInfoGeneratorFactory kiFactory = new X509KeyInfoGeneratorFactory();
+                KeyInfoBean.CERT_IDENTIFIER certIdentifier = keyInfo.getCertIdentifer();
+                switch (certIdentifier) {
+                    case X509_CERT: {
+                        kiFactory.setEmitEntityCertificate(true);
+                        break;
+                    }
+                    case KEY_VALUE: {
+                        kiFactory.setEmitPublicKeyValue(true);
+                        break;
+                    }
+                    case X509_ISSUER_SERIAL: {
+                        kiFactory.setEmitX509IssuerSerial(true);
+                    }
                 }
+                return kiFactory.newInstance().generate(keyInfoCredential);
+
+            } else if (keyInfo.getPublicKey() != null) {
+                BasicCredential keyInfoCredential = new BasicCredential(keyInfo.getPublicKey());
+                BasicKeyInfoGeneratorFactory kiFactory = new BasicKeyInfoGeneratorFactory();
+                kiFactory.setEmitPublicKeyValue(true);
+                return kiFactory.newInstance().generate(keyInfoCredential);
             }
-            return kiFactory.newInstance().generate(keyInfoCredential);
         }
+        
+        return null;
     }
 
     /**



Mime
View raw message