use of org.pac4j.saml.context.SAML2MessageContext in project pac4j by pac4j.
the class SAML2DefaultResponseValidatorTests method testWantsAssertionsSignedWithValidSPSSODescriptor.
@Test
public void testWantsAssertionsSignedWithValidSPSSODescriptor() {
SAML2DefaultResponseValidator validator = createResponseValidatorWithSigningValidationOf(true);
SAML2MessageContext context = new SAML2MessageContext();
SAMLMetadataContext samlSelfMetadataContext = context.getSAMLSelfMetadataContext();
SPSSODescriptor roleDescriptor = mock(SPSSODescriptor.class);
when(roleDescriptor.getWantAssertionsSigned()).thenReturn(true);
samlSelfMetadataContext.setRoleDescriptor(roleDescriptor);
assertNotNull("Expected SPSSODescriptor to not be null", context.getSPSSODescriptor());
assertTrue("Expected wantAssertionsSigned == true", validator.wantsAssertionsSigned(context));
}
use of org.pac4j.saml.context.SAML2MessageContext in project pac4j by pac4j.
the class SAML2DefaultResponseValidatorTests method testDoesNotWantAssertionsSignedWithValidSPSSODescriptor.
@Test
public void testDoesNotWantAssertionsSignedWithValidSPSSODescriptor() {
SAML2DefaultResponseValidator validator = createResponseValidatorWithSigningValidationOf(false);
SAML2MessageContext context = new SAML2MessageContext();
SAMLMetadataContext samlSelfMetadataContext = context.getSAMLSelfMetadataContext();
SPSSODescriptor roleDescriptor = mock(SPSSODescriptor.class);
when(roleDescriptor.getWantAssertionsSigned()).thenReturn(false);
samlSelfMetadataContext.setRoleDescriptor(roleDescriptor);
assertNotNull("Expected SPSSODescriptor to not be null", context.getSPSSODescriptor());
assertFalse("Expected wantAssertionsSigned == false", validator.wantsAssertionsSigned(context));
}
use of org.pac4j.saml.context.SAML2MessageContext in project pac4j by pac4j.
the class SAML2DefaultResponseValidatorTests method testDoesNotWantAssertionsSignedWithNullSPSSODescriptor.
@Test
public void testDoesNotWantAssertionsSignedWithNullSPSSODescriptor() {
SAML2DefaultResponseValidator validator = createResponseValidatorWithSigningValidationOf(false);
SAML2MessageContext context = new SAML2MessageContext();
assertNull("Expected SPSSODescriptor to be null", context.getSPSSODescriptor());
assertFalse("Expected wantAssertionsSigned == false", validator.wantsAssertionsSigned(context));
}
use of org.pac4j.saml.context.SAML2MessageContext in project pac4j by pac4j.
the class SAML2DefaultResponseValidatorTests method testWantsAssertionsSignedWithNullSPSSODescriptor.
@Test
public void testWantsAssertionsSignedWithNullSPSSODescriptor() {
SAML2DefaultResponseValidator validator = createResponseValidatorWithSigningValidationOf(true);
SAML2MessageContext context = new SAML2MessageContext();
assertNull("Expected SPSSODescriptor to be null", context.getSPSSODescriptor());
assertTrue("Expected wantAssertionsSigned == true", validator.wantsAssertionsSigned(context));
}
use of org.pac4j.saml.context.SAML2MessageContext in project pac4j by pac4j.
the class SAML2Client method clientInit.
@Override
protected void clientInit() {
CommonHelper.assertNotNull("configuration", this.configuration);
// First of all, initialize the configuration. It may dynamically load some properties, if it is not a static one.
this.configuration.init(getName());
initCredentialProvider();
initDecrypter();
initSignatureSigningParametersProvider();
final MetadataResolver metadataManager = initChainingMetadataResolver(initIdentityProviderMetadataResolver(), initServiceProviderMetadataResolver());
initSAMLContextProvider(metadataManager);
initSignatureTrustEngineProvider(metadataManager);
initSAMLResponseValidator();
initSAMLProfileHandler();
defaultRedirectActionBuilder(new SAML2RedirectActionBuilder(this));
defaultCredentialsExtractor(ctx -> {
final SAML2MessageContext samlContext = this.contextProvider.buildContext(ctx);
final SAML2Credentials credentials = (SAML2Credentials) this.profileHandler.receive(samlContext);
return credentials;
});
defaultAuthenticator(new SAML2Authenticator());
defaultLogoutActionBuilder(new SAML2LogoutActionBuilder<>(this));
}
Aggregations