Search in sources :

Example 1 with SignatureBuilder

use of org.opensaml.xmlsec.signature.impl.SignatureBuilder 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

DateTime (org.joda.time.DateTime)1 Test (org.junit.jupiter.api.Test)1 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)1 Issuer (org.opensaml.saml.saml2.core.Issuer)1 AuthnRequestBuilder (org.opensaml.saml.saml2.core.impl.AuthnRequestBuilder)1 IssuerBuilder (org.opensaml.saml.saml2.core.impl.IssuerBuilder)1 SignatureBuilder (org.opensaml.xmlsec.signature.impl.SignatureBuilder)1 SignatureImpl (org.opensaml.xmlsec.signature.impl.SignatureImpl)1 AuthnRequestFromRelyingParty (uk.gov.ida.saml.hub.domain.AuthnRequestFromRelyingParty)1