Search in sources :

Example 1 with MatchingServiceAuthnStatement

use of uk.gov.ida.saml.core.domain.MatchingServiceAuthnStatement in project verify-hub by alphagov.

the class MatchingServiceAssertionToAssertionTransformer method transform.

public Assertion transform(MatchingServiceAssertion originalAssertion) {
    Assertion transformedAssertion = openSamlXmlObjectFactory.createAssertion();
    transformedAssertion.setIssueInstant(originalAssertion.getIssueInstant());
    Issuer transformedIssuer = openSamlXmlObjectFactory.createIssuer(originalAssertion.getIssuerId());
    transformedAssertion.setIssuer(transformedIssuer);
    transformedAssertion.setID(originalAssertion.getId());
    Subject subject = outboundAssertionToSubjectTransformer.transform(originalAssertion);
    transformedAssertion.setSubject(subject);
    MatchingServiceAuthnStatement authnStatement = originalAssertion.getAuthnStatement();
    transformedAssertion.getAuthnStatements().add(matchingServiceAuthnStatementToAuthnStatementTransformer.transform(authnStatement));
    Conditions conditions = openSamlXmlObjectFactory.createConditions();
    AudienceRestriction audienceRestriction = openSamlXmlObjectFactory.createAudienceRestriction(originalAssertion.getAudience());
    conditions.getAudienceRestrictions().add(audienceRestriction);
    transformedAssertion.setConditions(conditions);
    List<Attribute> userAttributesForAccountCreation = originalAssertion.getUserAttributesForAccountCreation();
    if (!userAttributesForAccountCreation.isEmpty()) {
        addAttributes(transformedAssertion, userAttributesForAccountCreation);
    }
    return transformedAssertion;
}
Also used : AudienceRestriction(org.opensaml.saml.saml2.core.AudienceRestriction) Issuer(org.opensaml.saml.saml2.core.Issuer) Attribute(org.opensaml.saml.saml2.core.Attribute) MatchingServiceAssertion(uk.gov.ida.saml.msa.test.domain.MatchingServiceAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) MatchingServiceAuthnStatement(uk.gov.ida.saml.core.domain.MatchingServiceAuthnStatement) Subject(org.opensaml.saml.saml2.core.Subject) Conditions(org.opensaml.saml.saml2.core.Conditions)

Example 2 with MatchingServiceAuthnStatement

use of uk.gov.ida.saml.core.domain.MatchingServiceAuthnStatement in project verify-hub by alphagov.

the class MatchingServiceAuthnStatementToAuthnStatementTransformer method transform.

public AuthnStatement transform(MatchingServiceAuthnStatement idaAuthnStatement) {
    AuthnStatement authnStatement = openSamlXmlObjectFactory.createAuthnStatement();
    AuthnContext authnContext = openSamlXmlObjectFactory.createAuthnContext();
    authnContext.setAuthnContextClassRef(openSamlXmlObjectFactory.createAuthnContextClassReference(idaAuthnStatement.getAuthnContext().getUri()));
    authnStatement.setAuthnContext(authnContext);
    authnStatement.setAuthnInstant(DateTime.now());
    return authnStatement;
}
Also used : AuthnStatement(org.opensaml.saml.saml2.core.AuthnStatement) MatchingServiceAuthnStatement(uk.gov.ida.saml.core.domain.MatchingServiceAuthnStatement) AuthnContext(org.opensaml.saml.saml2.core.AuthnContext)

Aggregations

MatchingServiceAuthnStatement (uk.gov.ida.saml.core.domain.MatchingServiceAuthnStatement)2 Assertion (org.opensaml.saml.saml2.core.Assertion)1 Attribute (org.opensaml.saml.saml2.core.Attribute)1 AudienceRestriction (org.opensaml.saml.saml2.core.AudienceRestriction)1 AuthnContext (org.opensaml.saml.saml2.core.AuthnContext)1 AuthnStatement (org.opensaml.saml.saml2.core.AuthnStatement)1 Conditions (org.opensaml.saml.saml2.core.Conditions)1 Issuer (org.opensaml.saml.saml2.core.Issuer)1 Subject (org.opensaml.saml.saml2.core.Subject)1 MatchingServiceAssertion (uk.gov.ida.saml.msa.test.domain.MatchingServiceAssertion)1