Moved issuer and destination into the response context.
authordfisher <dfisher@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 20 Apr 2007 16:06:09 +0000 (16:06 +0000)
committerdfisher <dfisher@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 20 Apr 2007 16:06:09 +0000 (16:06 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2181 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/idp/profile/saml2/AbstractAttributeQuery.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml2/HTTPSOAPAttributeQuery.java
src/edu/internet2/middleware/shibboleth/idp/profile/saml2/ProfileResponseContext.java

index c7740e8..f9b4c8a 100644 (file)
@@ -157,13 +157,10 @@ public abstract class AbstractAttributeQuery extends AbstractSAML2ProfileHandler
      * This builds the response for this SAML request.
      * 
      * @param responseContext <code>ProfileResponseContext</code>
-     * @param issuer <code>String</code>
-     * @param destination <code>String</code>
      * @return <code>Response</code>
      * @throws EncryptionException if an error occurs attempting to encrypt data
      */
-    protected Response buildResponse(ProfileResponseContext responseContext, String issuer, String destination)
-            throws EncryptionException {
+    protected Response buildResponse(ProfileResponseContext responseContext) throws EncryptionException {
         AttributeQueryConfiguration config = getAttributeQueryConfiguration(responseContext.getProviderId());
 
         /*
@@ -172,11 +169,11 @@ public abstract class AbstractAttributeQuery extends AbstractSAML2ProfileHandler
         Response response = responseBuilder.buildObject();
         response.setVersion(SAML_VERSION);
         response.setID(getIdGenerator().generateIdentifier());
-        response.setInResponseTo(issuer);
+        response.setInResponseTo(responseContext.getIssuer());
         response.setIssueInstant(responseContext.getIssueInstant());
-        response.setDestination(destination);
+        response.setDestination(responseContext.getDestination());
 
-        response.setIssuer(buildIssuer(responseContext.getProviderId()));
+        response.setIssuer(buildIssuer(responseContext));
 
         /*
          * Will be hard coded in the future: if (consent != null) { response.setConsent(consent); }
@@ -249,10 +246,10 @@ public abstract class AbstractAttributeQuery extends AbstractSAML2ProfileHandler
         assertion.setID(getIdGenerator().generateIdentifier());
         assertion.setIssueInstant(responseContext.getIssueInstant());
         assertion.setVersion(SAML_VERSION);
-        assertion.setIssuer(buildIssuer(responseContext.getProviderId()));
+        assertion.setIssuer(buildIssuer(responseContext));
 
         // build subject
-        assertion.setSubject(buildSubject(responseContext.getMessage().getSubject(), config.getEncryptNameID()));
+        assertion.setSubject(buildSubject(responseContext, config.getEncryptNameID()));
         // build conditions
         assertion.setConditions(buildConditions(responseContext));
         // build advice
@@ -265,11 +262,12 @@ public abstract class AbstractAttributeQuery extends AbstractSAML2ProfileHandler
     /**
      * This builds the issuer response for this SAML request.
      * 
-     * @param providerId <code>String</code>
+     * @param responseContext <code>ProfileResponseContext</code>
      * @return <code>Issuer</code>
      */
-    private Issuer buildIssuer(String providerId) {
-        RelyingPartyConfiguration relyingPartyConfiguration = getRelyingPartyConfiguration(providerId);
+    private Issuer buildIssuer(ProfileResponseContext responseContext) {
+        RelyingPartyConfiguration relyingPartyConfiguration = getRelyingPartyConfiguration(responseContext
+                .getProviderId());
         Issuer issuer = issuerBuilder.buildObject();
         issuer.setValue(relyingPartyConfiguration.getProviderId());
         return issuer;
@@ -278,19 +276,20 @@ public abstract class AbstractAttributeQuery extends AbstractSAML2ProfileHandler
     /**
      * This builds the subject for this SAML request.
      * 
-     * @param messageSubject <code>Subject</code>
+     * @param responseContext <code>ProfileResponseContext</code>
      * @param encryptNameId <code>boolean</code>
      * @return <code>Subject</code>
      * @throws EncryptionException if encryption of the name id fails
      */
-    private Subject buildSubject(Subject messageSubject, boolean encryptNameId) throws EncryptionException {
+    private Subject buildSubject(ProfileResponseContext responseContext, boolean encryptNameId)
+            throws EncryptionException {
         Subject subject = subjectBuilder.buildObject();
         if (encryptNameId) {
             // TODO load encryption parameters
             Encrypter encrypter = null;
-            subject.setEncryptedID(encrypter.encrypt(messageSubject.getNameID()));
+            subject.setEncryptedID(encrypter.encrypt(responseContext.getMessage().getSubject().getNameID()));
         } else {
-            subject.setNameID(messageSubject.getNameID());
+            subject.setNameID(responseContext.getMessage().getSubject().getNameID());
             // TODO when is subject.setBaseID(newBaseID) called, if ever?
         }
         return subject;
index b625dca..af0b0d9 100644 (file)
@@ -126,9 +126,10 @@ public class HTTPSOAPAttributeQuery extends AbstractAttributeQuery {
         Response samlResponse = null;
         try {
             ProfileResponseContext profileResponse = new ProfileResponseContext(request, message);
+            profileResponse.setIssuer(decoder.getSecurityPolicy().getIssuer().toString());
+            profileResponse.setDestination(request.getRawRequest().getRemoteHost());
             profileResponse.setAttributeStatement(statement);
-            samlResponse = buildResponse(profileResponse, decoder.getSecurityPolicy().getIssuer().toString(), request
-                    .getRawRequest().getRemoteHost());
+            samlResponse = buildResponse(profileResponse);
         } catch (EncryptionException e) {
             log.error("Error encrypting SAML response", e);
             throw new ProfileException("Error encrypting SAML response", e);
index cdcfca1..9bf6342 100644 (file)
@@ -17,8 +17,8 @@
 package edu.internet2.middleware.shibboleth.idp.profile.saml2;
 
 import org.joda.time.DateTime;
-import org.opensaml.saml2.core.SubjectQuery;
 import org.opensaml.saml2.core.AttributeStatement;
+import org.opensaml.saml2.core.SubjectQuery;
 
 import edu.internet2.middleware.shibboleth.common.profile.ProfileRequest;
 
@@ -33,9 +33,15 @@ public class ProfileResponseContext {
     /** Profile request message. */
     private SubjectQuery message;
 
+    /** Response issuer. */
+    private String issuer;
+
+    /** Response destination. */
+    private String destination;
+
     /** Provider id to retrieve relying party configuration. */
     private String providerId;
-    
+
     /** Issue instant for the response. */
     private DateTime issueInstant;
 
@@ -82,7 +88,7 @@ public class ProfileResponseContext {
     public String getProviderId() {
         return providerId;
     }
-    
+
     /**
      * Gets the issue instant for the response.
      * 
@@ -93,6 +99,42 @@ public class ProfileResponseContext {
     }
 
     /**
+     * Sets an issuer associated with this response.
+     * 
+     * @param i to set
+     */
+    public void setIssuer(String i) {
+        issuer = i;
+    }
+
+    /**
+     * Gets the issuer associated with this response.
+     * 
+     * @return issuer
+     */
+    public String getIssuer() {
+        return issuer;
+    }
+
+    /**
+     * Sets a destination associated with this response.
+     * 
+     * @param d to set
+     */
+    public void setDestination(String d) {
+        destination = d;
+    }
+
+    /**
+     * Gets the destination associated with this response.
+     * 
+     * @return destination
+     */
+    public String getDestination() {
+        return destination;
+    }
+
+    /**
      * Sets a attribute statement associated with this response.
      * 
      * @param s to sets