use of org.opensaml.saml2.core.AuthnContextClassRef in project cxf by apache.
the class SamlpRequestComponentBuilder method createAuthnCtxClassRef.
@SuppressWarnings("unchecked")
public static AuthnContextClassRef createAuthnCtxClassRef(String authnCtxClassRefValue) {
if (requestedAuthnCtxClassRefBuilder == null) {
requestedAuthnCtxClassRefBuilder = (SAMLObjectBuilder<AuthnContextClassRef>) builderFactory.getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
}
AuthnContextClassRef authnCtxClassRef = requestedAuthnCtxClassRefBuilder.buildObject();
authnCtxClassRef.setAuthnContextClassRef(authnCtxClassRefValue);
return authnCtxClassRef;
}
use of org.opensaml.saml2.core.AuthnContextClassRef in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldNotSetFraudlentFlagForNotFraudulentEvent.
@Test
public void transform_shouldNotSetFraudlentFlagForNotFraudulentEvent() {
final AuthnContextClassRef authnContextClassRef = anAuthnContextClassRef().withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_3_AUTHN_CTX).build();
Assertion theAssertion = anAssertion().addAuthnStatement(anAuthnStatement().withAuthnContext(anAuthnContext().withAuthnContextClassRef(authnContextClassRef).build()).build()).buildUnencrypted();
when(authnContextFactory.authnContextForLevelOfAssurance(IdaAuthnContext.LEVEL_3_AUTHN_CTX)).thenReturn(AuthnContext.LEVEL_3);
when(assertionStringTransformer.apply(theAssertion)).thenReturn("AUTHN_ASSERTION");
PassthroughAssertion authnStatementAssertion = unmarshaller.fromAssertion(theAssertion);
assertThat(authnStatementAssertion.isFraudulent()).isEqualTo(false);
assertThat(authnStatementAssertion.getFraudDetectedDetails().isPresent()).isEqualTo(false);
}
use of org.opensaml.saml2.core.AuthnContextClassRef in project ddf by codice.
the class IdpHandler method createAndSignAuthnRequest.
private String createAndSignAuthnRequest(boolean isPost, boolean wantSigned) throws AuthenticationFailureException {
String spIssuerId = getSpIssuerId();
String spAssertionConsumerServiceUrl = getSpAssertionConsumerServiceUrl(spIssuerId);
AuthnRequest authnRequest = authnRequestBuilder.buildObject();
Issuer issuer = issuerBuilder.buildObject();
issuer.setValue(spIssuerId);
authnRequest.setIssuer(issuer);
authnRequest.setAssertionConsumerServiceURL(spAssertionConsumerServiceUrl);
authnRequest.setID("_" + UUID.randomUUID().toString());
authnRequest.setVersion(SAMLVersion.VERSION_20);
authnRequest.setIssueInstant(new DateTime());
authnRequest.setDestination(idpMetadata.getSingleSignOnLocation());
authnRequest.setProtocolBinding(SamlProtocol.POST_BINDING);
authnRequest.setNameIDPolicy(SamlpRequestComponentBuilder.createNameIDPolicy(true, SAML2Constants.NAMEID_FORMAT_PERSISTENT, spIssuerId));
RequestedAuthnContextBuilder requestedAuthnContextBuilder = new RequestedAuthnContextBuilder();
RequestedAuthnContext requestedAuthnContext = requestedAuthnContextBuilder.buildObject();
AuthnContextClassRefBuilder authnContextClassRefBuilder = new AuthnContextClassRefBuilder();
for (String authContextClass : authContextClasses) {
if (StringUtils.isNotEmpty(authContextClass)) {
AuthnContextClassRef authnContextClassRef = authnContextClassRefBuilder.buildObject();
authnContextClassRef.setAuthnContextClassRef(authContextClass);
requestedAuthnContext.getAuthnContextClassRefs().add(authnContextClassRef);
}
}
authnRequest.setRequestedAuthnContext(requestedAuthnContext);
return serializeAndSign(isPost, wantSigned, authnRequest);
}
Aggregations