use of org.opensaml.saml.saml2.core.SubjectConfirmationData in project OpenAttestation by OpenAttestation.
the class SamlGenerator method createSubjectConfirmationData.
/**
*
* The SubjectConfirmationData element may be extended with custom information that we want to include, both as attributes or as child elements.
*
* See also section 2.4.1.2 Element <SubjectConfirmationData> of http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf
*
* @param host
* @return
* @throws ConfigurationException
* @throws UnknownHostException
*/
private SubjectConfirmationData createSubjectConfirmationData(TxtHost host) throws ConfigurationException, UnknownHostException {
SAMLObjectBuilder confirmationMethodBuilder = (SAMLObjectBuilder) builderFactory.getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
SubjectConfirmationData confirmationMethod = (SubjectConfirmationData) confirmationMethodBuilder.buildObject();
DateTime now = new DateTime();
// Required to add to cache
samlAssertion.created_ts = now.toDate();
confirmationMethod.setNotBefore(now);
if (validitySeconds != null) {
confirmationMethod.setNotOnOrAfter(now.plusSeconds(validitySeconds));
// Required to add to cache
samlAssertion.expiry_ts = confirmationMethod.getNotOnOrAfter().toDate();
}
InetAddress localhost = InetAddress.getLocalHost();
// NOTE: This is the ATTESTATION SERVICE IP ADDRESS, **NOT** THE HOST ADDRESS
confirmationMethod.setAddress(localhost.getHostAddress());
return confirmationMethod;
}
use of org.opensaml.saml.saml2.core.SubjectConfirmationData in project cas by apereo.
the class AbstractSaml20ObjectBuilder method newSubject.
/**
* New subject element.
*
* @param nameIdFormat the name id format
* @param nameIdValue the name id value
* @param recipient the recipient
* @param notOnOrAfter the not on or after
* @param inResponseTo the in response to
* @return the subject
*/
public Subject newSubject(final String nameIdFormat, final String nameIdValue, final String recipient, final ZonedDateTime notOnOrAfter, final String inResponseTo) {
final SubjectConfirmation confirmation = newSamlObject(SubjectConfirmation.class);
confirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
final SubjectConfirmationData data = newSamlObject(SubjectConfirmationData.class);
data.setRecipient(recipient);
data.setNotOnOrAfter(DateTimeUtils.dateTimeOf(notOnOrAfter));
data.setInResponseTo(inResponseTo);
confirmation.setSubjectConfirmationData(data);
final Subject subject = newSamlObject(Subject.class);
subject.setNameID(getNameID(nameIdFormat, nameIdValue));
subject.getSubjectConfirmations().add(confirmation);
return subject;
}
Aggregations