2 * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package edu.internet2.middleware.shibboleth.idp.profile.saml1;
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.List;
24 import javax.servlet.ServletRequest;
25 import javax.servlet.ServletResponse;
27 import org.apache.log4j.Logger;
28 import org.joda.time.DateTime;
29 import org.opensaml.common.SAMLObject;
30 import org.opensaml.common.SAMLObjectBuilder;
31 import org.opensaml.common.SAMLVersion;
32 import org.opensaml.common.impl.SAMLObjectContentReference;
33 import org.opensaml.common.xml.SAMLConstants;
34 import org.opensaml.saml1.core.Assertion;
35 import org.opensaml.saml1.core.Audience;
36 import org.opensaml.saml1.core.AudienceRestrictionCondition;
37 import org.opensaml.saml1.core.Conditions;
38 import org.opensaml.saml1.core.ConfirmationMethod;
39 import org.opensaml.saml1.core.NameIdentifier;
40 import org.opensaml.saml1.core.RequestAbstractType;
41 import org.opensaml.saml1.core.Response;
42 import org.opensaml.saml1.core.ResponseAbstractType;
43 import org.opensaml.saml1.core.Statement;
44 import org.opensaml.saml1.core.Status;
45 import org.opensaml.saml1.core.StatusCode;
46 import org.opensaml.saml1.core.StatusMessage;
47 import org.opensaml.saml1.core.Subject;
48 import org.opensaml.saml1.core.SubjectConfirmation;
49 import org.opensaml.saml2.metadata.AttributeAuthorityDescriptor;
50 import org.opensaml.saml2.metadata.AuthnAuthorityDescriptor;
51 import org.opensaml.saml2.metadata.NameIDFormat;
52 import org.opensaml.saml2.metadata.PDPDescriptor;
53 import org.opensaml.saml2.metadata.RoleDescriptor;
54 import org.opensaml.saml2.metadata.SPSSODescriptor;
55 import org.opensaml.saml2.metadata.SSODescriptor;
56 import org.opensaml.saml2.metadata.provider.MetadataProviderException;
57 import org.opensaml.xml.XMLObjectBuilder;
58 import org.opensaml.xml.security.credential.Credential;
59 import org.opensaml.xml.signature.Signature;
60 import org.opensaml.xml.signature.Signer;
61 import org.opensaml.xml.util.DatatypeHelper;
63 import edu.internet2.middleware.shibboleth.common.attribute.AttributeRequestException;
64 import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
65 import edu.internet2.middleware.shibboleth.common.attribute.encoding.AttributeEncoder;
66 import edu.internet2.middleware.shibboleth.common.attribute.encoding.AttributeEncodingException;
67 import edu.internet2.middleware.shibboleth.common.profile.ProfileException;
68 import edu.internet2.middleware.shibboleth.common.profile.ProfileRequest;
69 import edu.internet2.middleware.shibboleth.common.profile.ProfileResponse;
70 import edu.internet2.middleware.shibboleth.common.relyingparty.provider.saml1.AbstractSAML1ProfileConfiguration;
71 import edu.internet2.middleware.shibboleth.idp.profile.AbstractSAMLProfileHandler;
74 * Common implementation details for profile handlers.
76 public abstract class AbstractSAML1ProfileHandler extends AbstractSAMLProfileHandler {
78 /** SAML Version for this profile handler. */
79 public static final SAMLVersion SAML_VERSION = SAMLVersion.VERSION_11;
82 private static Logger log = Logger.getLogger(AbstractSAML1ProfileHandler.class);
84 /** Builder of Response objects. */
85 private SAMLObjectBuilder<Response> responseBuilder;
87 /** Builder of Assertion objects. */
88 private SAMLObjectBuilder<Assertion> assertionBuilder;
90 /** Builder of Conditions objects. */
91 private SAMLObjectBuilder<Conditions> conditionsBuilder;
93 /** Builder of AudienceRestrictionCondition objects. */
94 private SAMLObjectBuilder<AudienceRestrictionCondition> audienceRestrictionConditionBuilder;
96 /** Builder of AudienceRestrictionCondition objects. */
97 private SAMLObjectBuilder<Audience> audienceBuilder;
99 /** Builder of NameIdentifier objects. */
100 private SAMLObjectBuilder<NameIdentifier> nameIdBuilder;
102 /** Builder of SubjectConfirmation objects. */
103 private SAMLObjectBuilder<SubjectConfirmation> subjectConfirmationBuilder;
105 /** Builder of ConfirmationMethod objects. */
106 private SAMLObjectBuilder<ConfirmationMethod> confirmationMethodBuilder;
108 /** Builder of Subject objects. */
109 private SAMLObjectBuilder<Subject> subjectBuilder;
111 /** Builder for Status objects. */
112 private SAMLObjectBuilder<Status> statusBuilder;
114 /** Builder for StatusCode objects. */
115 private SAMLObjectBuilder<StatusCode> statusCodeBuilder;
117 /** Builder for StatusMessage objects. */
118 private SAMLObjectBuilder<StatusMessage> statusMessageBuilder;
120 /** For building signature. */
121 private XMLObjectBuilder<Signature> signatureBuilder;
124 * Default constructor.
126 @SuppressWarnings("unchecked")
127 public AbstractSAML1ProfileHandler() {
129 responseBuilder = (SAMLObjectBuilder<Response>) getBuilderFactory().getBuilder(Response.DEFAULT_ELEMENT_NAME);
130 assertionBuilder = (SAMLObjectBuilder<Assertion>) getBuilderFactory()
131 .getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
132 conditionsBuilder = (SAMLObjectBuilder<Conditions>) getBuilderFactory().getBuilder(
133 Conditions.DEFAULT_ELEMENT_NAME);
134 audienceRestrictionConditionBuilder = (SAMLObjectBuilder<AudienceRestrictionCondition>) getBuilderFactory()
135 .getBuilder(AudienceRestrictionCondition.DEFAULT_ELEMENT_NAME);
136 audienceBuilder = (SAMLObjectBuilder<Audience>) getBuilderFactory().getBuilder(Audience.DEFAULT_ELEMENT_NAME);
137 nameIdBuilder = (SAMLObjectBuilder<NameIdentifier>) getBuilderFactory().getBuilder(
138 NameIdentifier.DEFAULT_ELEMENT_NAME);
139 subjectConfirmationBuilder = (SAMLObjectBuilder<SubjectConfirmation>) getBuilderFactory().getBuilder(
140 SubjectConfirmation.DEFAULT_ELEMENT_NAME);
141 confirmationMethodBuilder = (SAMLObjectBuilder<ConfirmationMethod>) getBuilderFactory().getBuilder(
142 ConfirmationMethod.DEFAULT_ELEMENT_NAME);
143 subjectBuilder = (SAMLObjectBuilder<Subject>) getBuilderFactory().getBuilder(Subject.DEFAULT_ELEMENT_NAME);
144 statusBuilder = (SAMLObjectBuilder<Status>) getBuilderFactory().getBuilder(Status.DEFAULT_ELEMENT_NAME);
145 statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) getBuilderFactory().getBuilder(
146 StatusCode.DEFAULT_ELEMENT_NAME);
147 statusMessageBuilder = (SAMLObjectBuilder<StatusMessage>) getBuilderFactory().getBuilder(
148 StatusMessage.DEFAULT_ELEMENT_NAME);
149 signatureBuilder = (XMLObjectBuilder<Signature>) getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME);
153 * Convenience method for getting the SAML 1 Response builder.
155 * @return SAML 1 Response builder
157 public SAMLObjectBuilder<Response> getResponseBuilder() {
158 return responseBuilder;
162 * Convenience method for getting the SAML 1 Assertion builder.
164 * @return SAML 1 Assertion builder
166 public SAMLObjectBuilder<Assertion> getAssertionBuilder() {
167 return assertionBuilder;
171 * Convenience method for getting the SAML 1 Conditions builder.
173 * @return SAML 1 Conditions builder
175 public SAMLObjectBuilder<Conditions> getConditionsBuilder() {
176 return conditionsBuilder;
180 * Convenience method for getting the SAML 1 AudienceRestrictionCondition builder.
182 * @return SAML 1 AudienceRestrictionCondition builder
184 public SAMLObjectBuilder<AudienceRestrictionCondition> getAudienceRestrictionConditionBuilder() {
185 return audienceRestrictionConditionBuilder;
189 * Convenience method for getting the SAML 1 Audience builder.
191 * @return SAML 1 Audience builder
193 public SAMLObjectBuilder<Audience> getAudienceBuilder() {
194 return audienceBuilder;
198 * Convenience method for getting the SAML 1 NameIdentifier builder.
200 * @return SAML 1 NameIdentifier builder
202 public SAMLObjectBuilder<NameIdentifier> getNameIdentifierBuilder() {
203 return nameIdBuilder;
207 * Convenience method for getting the SAML 1 SubjectConfirmation builder.
209 * @return SAML 1 SubjectConfirmation builder
211 public SAMLObjectBuilder<SubjectConfirmation> getSubjectConfirmationBuilder() {
212 return subjectConfirmationBuilder;
216 * Convenience method for getting the SAML 1 ConfirmationMethod builder.
218 * @return SAML 1 ConfirmationMethod builder
220 public SAMLObjectBuilder<ConfirmationMethod> getConfirmationMethodBuilder() {
221 return confirmationMethodBuilder;
225 * Convenience method for getting the SAML 1 Subject builder.
227 * @return SAML 1 Subject builder
229 public SAMLObjectBuilder<Subject> getSubjectBuilder() {
230 return subjectBuilder;
234 * Convenience method for getting the SAML 1 Status builder.
236 * @return SAML 1 Status builder
238 public SAMLObjectBuilder<Status> getStatusBuilder() {
239 return statusBuilder;
243 * Convenience method for getting the SAML 1 StatusCode builder.
245 * @return SAML 2 StatusCode builder
247 public SAMLObjectBuilder<StatusCode> getStatusCodeBuilder() {
248 return statusCodeBuilder;
252 * Convenience method for getting the SAML 1 StatusMessage builder.
254 * @return SAML StatusMessage builder
256 public SAMLObjectBuilder<StatusMessage> getStatusMessageBuilder() {
257 return statusMessageBuilder;
261 * Builds a response to the attribute query within the request context.
263 * @param requestContext current request context
264 * @param statements the statements to include in the response
266 * @return the built response
268 * @throws ProfileException thrown if there is a problem creating the SAML response
269 * @throws AttributeRequestException thrown if there is a problem resolving attributes
271 protected Response buildResponse(SAML1ProfileRequestContext requestContext, List<Statement> statements)
272 throws ProfileException, AttributeRequestException {
274 DateTime issueInstant = new DateTime();
276 // create the assertion and add the attribute statement
277 Assertion assertion = buildAssertion(requestContext, issueInstant);
278 if (statements != null) {
279 assertion.getStatements().addAll(statements);
282 // create the SAML response and add the assertion
283 Response samlResponse = getResponseBuilder().buildObject();
284 samlResponse.setIssueInstant(issueInstant);
285 populateStatusResponse(requestContext, samlResponse);
287 samlResponse.getAssertions().add(assertion);
289 // sign the assertion if it should be signed
290 signAssertion(requestContext, assertion);
292 Status status = buildStatus(StatusCode.SUCCESS, null, null);
293 samlResponse.setStatus(status);
299 * Builds a basic assertion with its id, issue instant, SAML version, issuer, subject, and conditions populated.
301 * @param requestContext current request context
302 * @param issueInstant time to use as assertion issue instant
304 * @return the built assertion
306 protected Assertion buildAssertion(SAML1ProfileRequestContext requestContext, DateTime issueInstant) {
307 Assertion assertion = getAssertionBuilder().buildObject();
308 assertion.setID(getIdGenerator().generateIdentifier());
309 assertion.setIssueInstant(issueInstant);
310 assertion.setVersion(SAMLVersion.VERSION_11);
311 assertion.setIssuer(requestContext.getAssertingPartyId());
313 Conditions conditions = buildConditions(requestContext, issueInstant);
314 assertion.setConditions(conditions);
320 * Builds a SAML assertion condition set. The following fields are set; not before, not on or after, audience
321 * restrictions, and proxy restrictions.
323 * @param requestContext current request context
324 * @param issueInstant timestamp the assertion was created
326 * @return constructed conditions
328 protected Conditions buildConditions(SAML1ProfileRequestContext requestContext, DateTime issueInstant) {
329 AbstractSAML1ProfileConfiguration profileConfig = requestContext.getProfileConfiguration();
331 Conditions conditions = getConditionsBuilder().buildObject();
332 conditions.setNotBefore(issueInstant);
333 conditions.setNotOnOrAfter(issueInstant.plus(profileConfig.getAssertionLifetime()));
335 Collection<String> audiences;
337 // add audience restrictions
338 audiences = profileConfig.getAssertionAudiences();
339 if (audiences != null && audiences.size() > 0) {
340 AudienceRestrictionCondition audienceRestriction = getAudienceRestrictionConditionBuilder().buildObject();
341 for (String audienceUri : audiences) {
342 Audience audience = getAudienceBuilder().buildObject();
343 audience.setUri(audienceUri);
344 audienceRestriction.getAudiences().add(audience);
346 conditions.getAudienceRestrictionConditions().add(audienceRestriction);
353 * Builds the SAML subject for the user for the service provider.
355 * @param requestContext current request context
356 * @param confirmationMethod subject confirmation method used for the subject
358 * @return SAML subject for the user for the service provider
360 * @throws ProfileException thrown if a NameID can not be created either because there was a problem encoding the
361 * name ID attribute or because there are no supported name formats
363 protected Subject buildSubject(SAML1ProfileRequestContext requestContext, String confirmationMethod)
364 throws ProfileException {
365 NameIdentifier nameID = buildNameId(requestContext);
366 requestContext.setSubjectNameID(nameID);
368 ConfirmationMethod method = getConfirmationMethodBuilder().buildObject();
369 method.setConfirmationMethod(confirmationMethod);
371 SubjectConfirmation subjectConfirmation = getSubjectConfirmationBuilder().buildObject();
372 subjectConfirmation.getConfirmationMethods().add(method);
374 Subject subject = getSubjectBuilder().buildObject();
375 subject.setNameIdentifier(nameID);
376 subject.setSubjectConfirmation(subjectConfirmation);
382 * Builds a NameIdentifier appropriate for this request. NameIdentifier are built by inspecting the SAML request and
383 * metadata, picking a name format that was requested by the relying party or is mutually supported by both the
384 * relying party and asserting party as described in their metadata entries. Once a set of supported name formats is
385 * determined the principals attributes are inspected for an attribtue supported an attribute encoder whose category
386 * is one of the supported name formats.
388 * @param requestContext current request context
390 * @return the NameIdentifier appropriate for this request
392 * @throws ProfileException thrown if a NameIdentifier can not be created either because there was a problem
393 * encoding the name ID attribute or because there are no supported name formats
395 protected NameIdentifier buildNameId(SAML1ProfileRequestContext requestContext) throws ProfileException {
396 if (log.isDebugEnabled()) {
397 log.debug("Building assertion NameIdentifier to relying party " + requestContext.getRelyingPartyId()
398 + " for principal " + requestContext.getPrincipalName());
400 Map<String, BaseAttribute> principalAttributes = requestContext.getPrincipalAttributes();
401 List<String> supportedNameFormats = getNameFormats(requestContext);
403 if (log.isDebugEnabled()) {
404 log.debug("Supported name formats: " + supportedNameFormats);
407 if (principalAttributes != null && supportedNameFormats != null) {
409 AttributeEncoder<NameIdentifier> nameIdEncoder = null;
410 for (BaseAttribute attribute : principalAttributes.values()) {
411 for (String nameFormat : supportedNameFormats) {
412 nameIdEncoder = attribute.getEncoderByCategory(nameFormat);
413 if (nameIdEncoder != null) {
414 if (log.isDebugEnabled()) {
415 log.debug("Using attribute " + attribute.getId() + " suppoting name format "
416 + nameFormat + " to create the NameIdentifier for principal "
417 + requestContext.getPrincipalName());
419 return nameIdEncoder.encode(attribute);
423 } catch (AttributeEncodingException e) {
424 throw new ProfileException("Unable to encode NameIdentifier attribute", e);
428 throw new ProfileException("No principal attributes support NameIdentifier construction");
432 * Gets the NameIdentifier format to use when creating NameIdentifiers for the relying party.
434 * @param requestContext current request context
436 * @return list of formats that may be used with the relying party
438 * @throws ProfileException thrown if there is a problem determing the NameIdentifier format to use
440 protected List<String> getNameFormats(SAML1ProfileRequestContext requestContext) throws ProfileException {
441 ArrayList<String> nameFormats = new ArrayList<String>();
444 RoleDescriptor assertingPartyRole = getMetadataProvider().getRole(requestContext.getAssertingPartyId(),
445 requestContext.getAssertingPartyRole(), SAMLConstants.SAML1P_NS);
446 List<String> assertingPartySupportedFormats = getEntitySupportedFormats(assertingPartyRole);
448 if (nameFormats.isEmpty()) {
449 RoleDescriptor relyingPartyRole = getMetadataProvider().getRole(requestContext.getRelyingPartyId(),
450 requestContext.getRelyingPartyRole(), SAMLConstants.SAML1P_NS);
451 List<String> relyingPartySupportedFormats = getEntitySupportedFormats(relyingPartyRole);
453 assertingPartySupportedFormats.retainAll(relyingPartySupportedFormats);
454 nameFormats.addAll(assertingPartySupportedFormats);
456 if (nameFormats.isEmpty()) {
457 nameFormats.add("urn:oasis:names:tc:SAML:1.0:nameid-format:unspecified");
462 } catch (MetadataProviderException e) {
463 throw new ProfileException("Unable to determine lookup entity metadata", e);
468 * Gets the list of NameIdentifier formats supported for a given role.
470 * @param role the role to get the list of supported NameIdentifier formats
472 * @return list of supported NameIdentifier formats
474 protected List<String> getEntitySupportedFormats(RoleDescriptor role) {
475 List<NameIDFormat> nameIDFormats = null;
477 if (role instanceof SSODescriptor) {
478 nameIDFormats = ((SSODescriptor) role).getNameIDFormats();
479 } else if (role instanceof AuthnAuthorityDescriptor) {
480 nameIDFormats = ((AuthnAuthorityDescriptor) role).getNameIDFormats();
481 } else if (role instanceof PDPDescriptor) {
482 nameIDFormats = ((PDPDescriptor) role).getNameIDFormats();
483 } else if (role instanceof AttributeAuthorityDescriptor) {
484 nameIDFormats = ((AttributeAuthorityDescriptor) role).getNameIDFormats();
487 ArrayList<String> supportedFormats = new ArrayList<String>();
488 if (nameIDFormats != null) {
489 for (NameIDFormat format : nameIDFormats) {
490 supportedFormats.add(format.getFormat());
494 return supportedFormats;
498 * Constructs an SAML response message carrying a request error.
500 * @param requestContext current request context
501 * @param topLevelCode top-level status code
502 * @param secondLevelCode second-level status code
503 * @param failureMessage An optional second-level failure message
505 * @return the constructed error response
507 protected Response buildErrorResponse(SAML1ProfileRequestContext requestContext, String topLevelCode,
508 String secondLevelCode, String failureMessage) {
509 Response samlResponse = getResponseBuilder().buildObject();
510 samlResponse.setIssueInstant(new DateTime());
511 populateStatusResponse(requestContext, samlResponse);
513 Status status = buildStatus(topLevelCode, secondLevelCode, failureMessage);
514 samlResponse.setStatus(status);
520 * Populates the response's id, in response to, issue instant, version, and issuer properties.
522 * @param requestContext current request context
523 * @param response the response to populate
525 protected void populateStatusResponse(SAML1ProfileRequestContext requestContext, ResponseAbstractType response) {
526 response.setID(getIdGenerator().generateIdentifier());
528 SAMLObject samlMessage = requestContext.getSamlRequest();
529 if (samlMessage != null && samlMessage instanceof RequestAbstractType) {
530 response.setInResponseTo(((RequestAbstractType) samlMessage).getID());
532 response.setVersion(SAMLVersion.VERSION_11);
536 * Build a status message, with an optional second-level failure message.
538 * @param topLevelCode top-level status code
539 * @param secondLevelCode second-level status code
540 * @param failureMessage An optional second-level failure message
542 * @return a Status object.
544 protected Status buildStatus(String topLevelCode, String secondLevelCode, String failureMessage) {
545 Status status = getStatusBuilder().buildObject();
547 StatusCode statusCode = getStatusCodeBuilder().buildObject();
548 statusCode.setValue(DatatypeHelper.safeTrimOrNullString(topLevelCode));
549 status.setStatusCode(statusCode);
551 if (secondLevelCode != null) {
552 StatusCode secondLevelStatusCode = getStatusCodeBuilder().buildObject();
553 secondLevelStatusCode.setValue(DatatypeHelper.safeTrimOrNullString(secondLevelCode));
554 statusCode.setStatusCode(secondLevelStatusCode);
557 if (failureMessage != null) {
558 StatusMessage msg = getStatusMessageBuilder().buildObject();
559 msg.setMessage(failureMessage);
560 status.setStatusMessage(msg);
567 * Signs the given assertion if either the current profile configuration or the relying party configuration contains
568 * signing credentials.
570 * @param requestContext current request context
571 * @param assertion assertion to sign
573 * @throws ProfileException thrown if the metadata can not be located for the relying party or, if signing is
574 * required, if a signing credential is not configured
576 protected void signAssertion(SAML1ProfileRequestContext requestContext, Assertion assertion)
577 throws ProfileException {
578 if (log.isDebugEnabled()) {
579 log.debug("Determining if SAML assertion to relying party " + requestContext.getRelyingPartyId()
580 + " should be signed");
583 boolean signAssertion = false;
585 RoleDescriptor relyingPartyRole;
587 relyingPartyRole = getMetadataProvider().getRole(requestContext.getRelyingPartyId(),
588 requestContext.getRelyingPartyRole(), SAMLConstants.SAML20P_NS);
589 } catch (MetadataProviderException e) {
590 throw new ProfileException("Unable to lookup entity metadata for relying party "
591 + requestContext.getRelyingPartyId());
593 AbstractSAML1ProfileConfiguration profileConfig = requestContext.getProfileConfiguration();
595 if (relyingPartyRole instanceof SPSSODescriptor) {
596 SPSSODescriptor ssoDescriptor = (SPSSODescriptor) relyingPartyRole;
597 if (ssoDescriptor.getWantAssertionsSigned() != null) {
598 signAssertion = ssoDescriptor.getWantAssertionsSigned().booleanValue();
599 if (log.isDebugEnabled()) {
600 log.debug("Entity metadata for relying party " + requestContext.getRelyingPartyId()
601 + " indicates to sign assertions: " + signAssertion);
604 } else if (profileConfig.getSignAssertions()) {
605 signAssertion = true;
606 log.debug("IdP relying party configuration "
607 + requestContext.getRelyingPartyConfiguration().getRelyingPartyId()
608 + " indicates to sign assertions: " + signAssertion);
611 if (!signAssertion) {
615 if (log.isDebugEnabled()) {
616 log.debug("Determining signing credntial for assertion to relying party "
617 + requestContext.getRelyingPartyId());
619 Credential signatureCredential = profileConfig.getSigningCredential();
620 if (signatureCredential == null) {
621 signatureCredential = requestContext.getRelyingPartyConfiguration().getDefaultSigningCredential();
624 if (signatureCredential == null) {
625 throw new ProfileException("No signing credential is specified for relying party configuration "
626 + requestContext.getRelyingPartyConfiguration().getProviderId()
627 + " or it's SAML2 attribute query profile configuration");
630 if (log.isDebugEnabled()) {
631 log.debug("Signing assertion to relying party " + requestContext.getRelyingPartyId());
633 SAMLObjectContentReference contentRef = new SAMLObjectContentReference(assertion);
634 Signature signature = signatureBuilder.buildObject(Signature.DEFAULT_ELEMENT_NAME);
635 signature.getContentReferences().add(contentRef);
636 assertion.setSignature(signature);
638 Signer.signObject(signature);
642 * Contextual object used to accumlate information as profile requests are being processed.
644 * @param <RequestType> type of SAML 1 request
645 * @param <ResponseType> type of SAML 1 response
646 * @param <ProfileConfigurationType> configuration type for this profile
648 protected class SAML1ProfileRequestContext<RequestType extends SAMLObject, ResponseType extends ResponseAbstractType, ProfileConfigurationType extends AbstractSAML1ProfileConfiguration>
649 extends SAMLProfileRequestContext {
651 /** SAML request message. */
652 private RequestType samlRequest;
654 /** SAML response message. */
655 private ResponseType samlResponse;
657 /** Request profile configuration. */
658 private ProfileConfigurationType profileConfiguration;
660 /** The NameIdentifier of the subject of this request. */
661 private NameIdentifier subjectNameIdentifier;
666 * @param request current profile request
667 * @param response current profile response
669 public SAML1ProfileRequestContext(ProfileRequest<ServletRequest> request,
670 ProfileResponse<ServletResponse> response) {
671 super(request, response);
675 * Gets the NameIdentifier of the subject of this request.
677 * @return NameIdentifier of the subject of this request
679 public NameIdentifier getSubjectNameID() {
680 return subjectNameIdentifier;
684 * Sets the NameIdentifier of the subject of this request.
686 * @param id NameIdentifier of the subject of this request
688 public void setSubjectNameID(NameIdentifier id) {
689 subjectNameIdentifier = id;
693 * Gets the profile configuration for this request.
695 * @return profile configuration for this request
697 public ProfileConfigurationType getProfileConfiguration() {
698 return profileConfiguration;
702 * Sets the profile configuration for this request.
704 * @param configuration profile configuration for this request
706 public void setProfileConfiguration(ProfileConfigurationType configuration) {
707 profileConfiguration = configuration;
711 * Gets the SAML request message.
713 * @return SAML request message
715 public RequestType getSamlRequest() {
720 * Sets the SAML request message.
722 * @param request SAML request message
724 public void setSamlRequest(RequestType request) {
725 samlRequest = request;
729 * Gets the SAML response message.
731 * @return SAML response message
733 public ResponseType getSamlResponse() {
738 * Sets the SAML response message.
740 * @param response SAML response message
742 public void setSamlResponse(ResponseType response) {
743 samlResponse = response;