Author: coheigea
Date: Thu Feb  8 16:51:51 2018
New Revision: 1823583

URL: http://svn.apache.org/viewvc?rev=1823583&view=rev
Log:
WSS4J WSS-622 from SAMLCallback no possible setting SAML2 
SubjectConfirmation.NameID

Signed-off-by: Colm O hEigeartaigh <cohei...@apache.org>

This closes #9

Modified:
    
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/SubjectBean.java
    
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java

Modified: 
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/SubjectBean.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/SubjectBean.java?rev=1823583&r1=1823582&r2=1823583&view=diff
==============================================================================
--- 
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/SubjectBean.java
 (original)
+++ 
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/SubjectBean.java
 Thu Feb  8 16:51:51 2018
@@ -28,6 +28,7 @@ public class SubjectBean {
     private String subjectConfirmationMethod;
     private KeyInfoBean keyInfo;
     private SubjectConfirmationDataBean subjectConfirmationData;
+    private NameIDBean subjectConfirmationNameID;
 
     /**
      * Constructor SubjectBean creates a new SubjectBean instance.
@@ -212,6 +213,22 @@ public class SubjectBean {
     }
 
     /**
+     * Get the NameId of the SubjectConfirmation object
+     * @return the NameId of the SubjectConfirmation object
+     */
+    public NameIDBean getSubjectConfirmationNameID() {
+        return subjectConfirmationNameID;
+    }
+
+    /**
+     * Set the NameID of the SubjectConfirmation object
+     * @param subjectConfirmationNameID the NameID of the SubjectConfirmation 
object
+     */
+    public void setSubjectConfirmationNameID(NameIDBean 
subjectConfirmationNameID) {
+        this.subjectConfirmationNameID = subjectConfirmationNameID;
+    }
+
+    /**
      * Method equals ...
      *
      * @param o of type Object

Modified: 
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java?rev=1823583&r1=1823582&r2=1823583&view=diff
==============================================================================
--- 
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java
 (original)
+++ 
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java
 Thu Feb  8 16:51:51 2018
@@ -19,9 +19,6 @@
 
 package org.apache.wss4j.common.saml.builder;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.saml.OpenSAMLUtil;
 import org.apache.wss4j.common.saml.bean.ActionBean;
@@ -41,6 +38,11 @@ import org.apache.wss4j.common.saml.bean
 import org.apache.wss4j.common.saml.bean.SubjectLocalityBean;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
 import org.joda.time.DateTime;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.XMLObjectBuilderFactory;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+import org.opensaml.core.xml.schema.XSString;
+import org.opensaml.core.xml.schema.impl.XSStringBuilder;
 import org.opensaml.saml.common.SAMLObjectBuilder;
 import org.opensaml.saml.common.SAMLVersion;
 import org.opensaml.saml.ext.saml2delrestrict.Delegate;
@@ -71,14 +73,12 @@ import org.opensaml.saml.saml2.core.Subj
 import org.opensaml.saml.saml2.core.SubjectConfirmation;
 import org.opensaml.saml.saml2.core.SubjectConfirmationData;
 import org.opensaml.saml.saml2.core.SubjectLocality;
-import org.opensaml.core.xml.XMLObject;
-import org.opensaml.core.xml.XMLObjectBuilderFactory;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.core.xml.schema.impl.XSStringBuilder;
 import org.opensaml.xmlsec.signature.KeyInfo;
 import org.w3c.dom.Element;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Class SAML2ComponentBuilder provides builder methods that can be used
  * to construct SAML v2.0 statements using the OpenSaml library.
@@ -606,13 +606,18 @@ public final class SAML2ComponentBuilder
                 );
         }
 
+        NameID subjectConfNameId = null;
+        if (subjectBean.getSubjectConfirmationNameID() != null) {
+            subjectConfNameId = 
SAML2ComponentBuilder.createNameID(subjectBean.getSubjectConfirmationNameID());
+        }
+
         String confirmationMethodStr = 
subjectBean.getSubjectConfirmationMethod();
         if (confirmationMethodStr == null) {
             confirmationMethodStr = SAML2Constants.CONF_SENDER_VOUCHES;
         }
         SubjectConfirmation subjectConfirmation =
             SAML2ComponentBuilder.createSubjectConfirmation(
-                confirmationMethodStr, subjectConfData
+                confirmationMethodStr, subjectConfData, subjectConfNameId
             );
 
         subject.getSubjectConfirmations().add(subjectConfirmation);
@@ -684,7 +689,8 @@ public final class SAML2ComponentBuilder
     @SuppressWarnings("unchecked")
     public static SubjectConfirmation createSubjectConfirmation(
         String method,
-        SubjectConfirmationData subjectConfirmationData
+        SubjectConfirmationData subjectConfirmationData,
+        NameID subjectConfirmationNameId
     ) {
         if (subjectConfirmationBuilder == null) {
             subjectConfirmationBuilder = 
(SAMLObjectBuilder<SubjectConfirmation>)
@@ -694,6 +700,7 @@ public final class SAML2ComponentBuilder
         SubjectConfirmation subjectConfirmation = 
subjectConfirmationBuilder.buildObject();
         subjectConfirmation.setMethod(method);
         
subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
+        subjectConfirmation.setNameID(subjectConfirmationNameId);
         return subjectConfirmation;
     }
 


Reply via email to