Search in sources :

Example 1 with AuthnContextComparisonTypeEnumeration

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

the class SamlpRequestComponentBuilder method createRequestedAuthnCtxPolicy.

@SuppressWarnings("unchecked")
public static RequestedAuthnContext createRequestedAuthnCtxPolicy(AuthnContextComparisonTypeEnumeration comparison, List<AuthnContextClassRef> authnCtxClassRefList, List<AuthnContextDeclRef> authnCtxDeclRefList) {
    if (requestedAuthnCtxBuilder == null) {
        requestedAuthnCtxBuilder = (SAMLObjectBuilder<RequestedAuthnContext>) builderFactory.getBuilder(RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
    }
    RequestedAuthnContext authnCtx = requestedAuthnCtxBuilder.buildObject();
    authnCtx.setComparison(comparison);
    if (authnCtxClassRefList != null) {
        List<AuthnContextClassRef> classRefList = authnCtx.getAuthnContextClassRefs();
        classRefList.addAll(authnCtxClassRefList);
    }
    if (authnCtxDeclRefList != null) {
        List<AuthnContextDeclRef> declRefList = authnCtx.getAuthnContextDeclRefs();
        declRefList.addAll(authnCtxDeclRefList);
    }
    return authnCtx;
}
Also used : RequestedAuthnContext(org.opensaml.saml.saml2.core.RequestedAuthnContext) AuthnContextClassRef(org.opensaml.saml.saml2.core.AuthnContextClassRef) AuthnContextDeclRef(org.opensaml.saml.saml2.core.AuthnContextDeclRef)

Example 2 with AuthnContextComparisonTypeEnumeration

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

the class IdaAuthnRequestTranslator method getIdaAuthnRequestFromHub.

public IdaAuthnRequestFromHub getIdaAuthnRequestFromHub(IdaAuthnRequestFromHubDto idaAuthnRequestFromHubDto, URI ssoUri, String hubEntityId) {
    List<AuthnContext> levelsOfAssurance = idaAuthnRequestFromHubDto.getLevelsOfAssurance();
    AuthnContextComparisonTypeEnumeration comparisonType;
    if (idaAuthnRequestFromHubDto.getUseExactComparisonType()) {
        comparisonType = EXACT;
    } else {
        comparisonType = MINIMUM;
        if (levelsOfAssurance.size() == 1) {
            levelsOfAssurance = Arrays.asList(levelsOfAssurance.get(0), levelsOfAssurance.get(0));
        }
    }
    return createRequestToSendFromHub(idaAuthnRequestFromHubDto.getId(), levelsOfAssurance, idaAuthnRequestFromHubDto.getForceAuthentication(), idaAuthnRequestFromHubDto.getSessionExpiryTimestamp(), ssoUri, comparisonType, hubEntityId);
}
Also used : AuthnContextComparisonTypeEnumeration(org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext)

Example 3 with AuthnContextComparisonTypeEnumeration

use of org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration 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

AuthnContextComparisonTypeEnumeration (org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration)2 RequestedAuthnContext (org.opensaml.saml.saml2.core.RequestedAuthnContext)2 AuthnContext (uk.gov.ida.saml.core.domain.AuthnContext)2 Inject (com.google.inject.Inject)1 AuthnContextClassRef (org.opensaml.saml.saml2.core.AuthnContextClassRef)1 AuthnContextDeclRef (org.opensaml.saml.saml2.core.AuthnContextDeclRef)1 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)1 Conditions (org.opensaml.saml.saml2.core.Conditions)1 NameIDPolicy (org.opensaml.saml.saml2.core.NameIDPolicy)1 NameIDType (org.opensaml.saml.saml2.core.NameIDType)1 Scoping (org.opensaml.saml.saml2.core.Scoping)1 OpenSamlXmlObjectFactory (uk.gov.ida.saml.core.OpenSamlXmlObjectFactory)1 HubConstants (uk.gov.ida.saml.hub.HubConstants)1 IdaAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub)1