Search in sources :

Example 11 with NameIDPolicy

use of org.opensaml.saml.saml2.core.NameIDPolicy in project cxf by apache.

the class SamlpRequestComponentBuilder method createNameIDPolicy.

@SuppressWarnings("unchecked")
public static NameIDPolicy createNameIDPolicy(boolean allowCreate, String format, String spNameQualifier) {
    if (nameIDBuilder == null) {
        nameIDBuilder = (SAMLObjectBuilder<NameIDPolicy>) builderFactory.getBuilder(NameIDPolicy.DEFAULT_ELEMENT_NAME);
    }
    NameIDPolicy nameId = nameIDBuilder.buildObject();
    nameId.setAllowCreate(allowCreate);
    nameId.setFormat(format);
    nameId.setSPNameQualifier(spNameQualifier);
    return nameId;
}
Also used : NameIDPolicy(org.opensaml.saml.saml2.core.NameIDPolicy)

Example 12 with NameIDPolicy

use of org.opensaml.saml.saml2.core.NameIDPolicy in project verify-hub by alphagov.

the class IdaAuthnRequestFromHubToAuthnRequestTransformer method supplementAuthnRequestWithDetails.

protected void supplementAuthnRequestWithDetails(IdaAuthnRequestFromHub originalRequestFromHub, AuthnRequest authnRequest) {
    Conditions conditions = getSamlObjectFactory().createConditions();
    conditions.setNotOnOrAfter(originalRequestFromHub.getSessionExpiryTimestamp());
    authnRequest.setConditions(conditions);
    Scoping scoping = getSamlObjectFactory().createScoping();
    scoping.setProxyCount(0);
    authnRequest.setScoping(scoping);
    AuthnContextComparisonTypeEnumeration comparisonType = originalRequestFromHub.getComparisonType();
    RequestedAuthnContext requestedAuthnContext = getSamlObjectFactory().createRequestedAuthnContext(comparisonType);
    originalRequestFromHub.getLevelsOfAssurance().stream().map(AuthnContext::getUri).map(uri -> getSamlObjectFactory().createAuthnContextClassReference(uri)).forEach(ref -> requestedAuthnContext.getAuthnContextClassRefs().add(ref));
    NameIDPolicy nameIdPolicy = getSamlObjectFactory().createNameIdPolicy();
    nameIdPolicy.setFormat(NameIDType.PERSISTENT);
    nameIdPolicy.setSPNameQualifier(HubConstants.SP_NAME_QUALIFIER);
    nameIdPolicy.setAllowCreate(true);
    authnRequest.setNameIDPolicy(nameIdPolicy);
    authnRequest.setRequestedAuthnContext(requestedAuthnContext);
    if (originalRequestFromHub.getForceAuthentication().isPresent()) {
        authnRequest.setForceAuthn(originalRequestFromHub.getForceAuthentication().get());
    }
}
Also used : AuthnContextComparisonTypeEnumeration(org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration) IdaAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub) HubConstants(uk.gov.ida.saml.hub.HubConstants) Inject(com.google.inject.Inject) NameIDType(org.opensaml.saml.saml2.core.NameIDType) RequestedAuthnContext(org.opensaml.saml.saml2.core.RequestedAuthnContext) AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) NameIDPolicy(org.opensaml.saml.saml2.core.NameIDPolicy) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext) Scoping(org.opensaml.saml.saml2.core.Scoping) Conditions(org.opensaml.saml.saml2.core.Conditions) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) RequestedAuthnContext(org.opensaml.saml.saml2.core.RequestedAuthnContext) Scoping(org.opensaml.saml.saml2.core.Scoping) NameIDPolicy(org.opensaml.saml.saml2.core.NameIDPolicy) AuthnContextComparisonTypeEnumeration(org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration) Conditions(org.opensaml.saml.saml2.core.Conditions) RequestedAuthnContext(org.opensaml.saml.saml2.core.RequestedAuthnContext) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext)

Aggregations

NameIDPolicy (org.opensaml.saml.saml2.core.NameIDPolicy)11 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)8 Issuer (org.opensaml.saml.saml2.core.Issuer)5 RequestedAuthnContext (org.opensaml.saml.saml2.core.RequestedAuthnContext)5 AuthnContextClassRef (org.opensaml.saml.saml2.core.AuthnContextClassRef)4 DateTime (org.joda.time.DateTime)3 SAMLObjectBuilder (org.opensaml.saml.common.SAMLObjectBuilder)3 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)2 MessageContext (org.opensaml.messaging.context.MessageContext)2 MessageDecodingException (org.opensaml.messaging.decoder.MessageDecodingException)2 AuthnContextClassRefBuilder (org.opensaml.saml.saml2.core.impl.AuthnContextClassRefBuilder)2 NameIDPolicyBuilder (org.opensaml.saml.saml2.core.impl.NameIDPolicyBuilder)2 RequestedAuthnContextBuilder (org.opensaml.saml.saml2.core.impl.RequestedAuthnContextBuilder)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 IdaAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub)2 Inject (com.google.inject.Inject)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 NonNull (lombok.NonNull)1 lombok.val (lombok.val)1