Search in sources :

Example 6 with AuthnRequestBuilder

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

the class AuthnRequestFromRelyingPartyUnmarshallerTest method fromSamlMessage_shouldNotComplainWhenExceptionDuringDecryption.

@Test
public void fromSamlMessage_shouldNotComplainWhenExceptionDuringDecryption() throws Exception {
    AuthnRequest authnRequest = new AuthnRequestBuilder().buildObject();
    authnRequest.setIssuer(new IssuerBuilder().buildObject());
    authnRequest.setDestination("http://example.com");
    authnRequest.setExtensions(createApplicationVersionExtensions(null));
    AuthnRequestFromRelyingParty authnRequestFromRelyingParty = unmarshaller.fromSamlMessage(authnRequest);
    assertThat(authnRequestFromRelyingParty.getVerifyServiceProviderVersion()).isEqualTo(Optional.empty());
}
Also used : AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) AuthnRequestFromRelyingParty(uk.gov.ida.saml.hub.domain.AuthnRequestFromRelyingParty) AuthnRequestBuilder(org.opensaml.saml.saml2.core.impl.AuthnRequestBuilder) IssuerBuilder(org.opensaml.saml.saml2.core.impl.IssuerBuilder) Test(org.junit.jupiter.api.Test)

Example 7 with AuthnRequestBuilder

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

the class SamlpRequestComponentBuilder method createAuthnRequest.

@SuppressWarnings("unchecked")
public static // CHECKSTYLE:OFF
AuthnRequest createAuthnRequest(String serviceURL, boolean forceAuthn, boolean isPassive, String protocolBinding, SAMLVersion version, Issuer issuer, NameIDPolicy nameIDPolicy, RequestedAuthnContext requestedAuthnCtx) {
    // CHECKSTYLE:ON
    if (authnRequestBuilder == null) {
        authnRequestBuilder = (SAMLObjectBuilder<AuthnRequest>) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
    }
    AuthnRequest authnRequest = authnRequestBuilder.buildObject();
    authnRequest.setAssertionConsumerServiceURL(serviceURL);
    authnRequest.setForceAuthn(forceAuthn);
    authnRequest.setID("_" + UUID.randomUUID());
    authnRequest.setIsPassive(isPassive);
    authnRequest.setIssueInstant(new DateTime());
    authnRequest.setProtocolBinding(protocolBinding);
    authnRequest.setVersion(version);
    authnRequest.setIssuer(issuer);
    authnRequest.setNameIDPolicy(nameIDPolicy);
    authnRequest.setRequestedAuthnContext(requestedAuthnCtx);
    return authnRequest;
}
Also used : AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) DateTime(org.joda.time.DateTime)

Example 8 with AuthnRequestBuilder

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

the class AuthnRequestBuilderTest method testAuthnRequestBuilder.

@org.junit.Test
public void testAuthnRequestBuilder() throws Exception {
    Document doc = DOMUtils.createDocument();
    AuthnRequestBuilder authnRequestBuilder = new DefaultAuthnRequestBuilder();
    Message message = new MessageImpl();
    AuthnRequest authnRequest = authnRequestBuilder.createAuthnRequest(message, "http://localhost:9001/app", "http://localhost:9001/sso");
    Element policyElement = OpenSAMLUtil.toDom(authnRequest, doc);
    doc.appendChild(policyElement);
    // String outputString = DOM2Writer.nodeToString(policyElement);
    assertNotNull(policyElement);
}
Also used : Message(org.apache.cxf.message.Message) AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) MessageImpl(org.apache.cxf.message.MessageImpl)

Example 9 with AuthnRequestBuilder

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

the class AuthnRequestFromRelyingPartyUnmarshallerTest method fromSamlMessage_shouldMapAuthnRequestToAuthnRequestFromRelyingParty.

@Test
public void fromSamlMessage_shouldMapAuthnRequestToAuthnRequestFromRelyingParty() throws Exception {
    DateTime issueInstant = new DateTime();
    SignatureImpl signature = new SignatureBuilder().buildObject();
    AuthnRequest authnRequest = new AuthnRequestBuilder().buildObject();
    authnRequest.setID("some-id");
    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue("some-service-entity-id");
    authnRequest.setIssuer(issuer);
    authnRequest.setIssueInstant(issueInstant);
    authnRequest.setDestination("http://example.com");
    authnRequest.setForceAuthn(true);
    authnRequest.setAssertionConsumerServiceURL("some-url");
    authnRequest.setAssertionConsumerServiceIndex(5);
    authnRequest.setSignature(signature);
    authnRequest.setExtensions(createApplicationVersionExtensions("some-version"));
    AuthnRequestFromRelyingParty authnRequestFromRelyingParty = unmarshaller.fromSamlMessage(authnRequest);
    AuthnRequestFromRelyingParty expected = new AuthnRequestFromRelyingParty("some-id", "some-service-entity-id", issueInstant, URI.create("http://example.com"), Optional.of(true), Optional.of(URI.create("some-url")), Optional.of(5), Optional.of(signature), Optional.of("some-version"));
    assertThat(authnRequestFromRelyingParty).isEqualTo(expected);
}
Also used : SignatureBuilder(org.opensaml.xmlsec.signature.impl.SignatureBuilder) AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) Issuer(org.opensaml.saml.saml2.core.Issuer) AuthnRequestFromRelyingParty(uk.gov.ida.saml.hub.domain.AuthnRequestFromRelyingParty) AuthnRequestBuilder(org.opensaml.saml.saml2.core.impl.AuthnRequestBuilder) IssuerBuilder(org.opensaml.saml.saml2.core.impl.IssuerBuilder) SignatureImpl(org.opensaml.xmlsec.signature.impl.SignatureImpl) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Aggregations

AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)7 AuthnRequestBuilder (org.opensaml.saml.saml2.core.impl.AuthnRequestBuilder)5 DateTime (org.joda.time.DateTime)4 IssuerBuilder (org.opensaml.saml.saml2.core.impl.IssuerBuilder)4 Test (org.junit.jupiter.api.Test)3 AuthnRequestFromRelyingParty (uk.gov.ida.saml.hub.domain.AuthnRequestFromRelyingParty)3 MessageImpl (org.apache.cxf.message.MessageImpl)2 Issuer (org.opensaml.saml.saml2.core.Issuer)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 lombok.val (lombok.val)1 Message (org.apache.cxf.message.Message)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 SAML2RequestTO (org.apache.syncope.common.lib.to.SAML2RequestTO)1 SAML2IdPEntity (org.apache.syncope.core.logic.saml2.SAML2IdPEntity)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 SAML2IdP (org.apache.syncope.core.persistence.api.entity.SAML2IdP)1 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)1 XMLObject (org.opensaml.core.xml.XMLObject)1