Search in sources :

Example 6 with OkAction

use of org.pac4j.core.exception.http.OkAction in project pac4j by pac4j.

the class PostSAML2ClientTests method testSetComparisonTypeWithPostBinding.

@Test
public void testSetComparisonTypeWithPostBinding() {
    final var client = getClient();
    client.getConfiguration().setComparisonType(AuthnContextComparisonTypeEnumeration.EXACT.toString());
    final var action = (OkAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
    assertTrue(getDecodedAuthnRequest(action.getContent()).contains("Comparison=\"exact\""));
}
Also used : MockSessionStore(org.pac4j.core.context.session.MockSessionStore) OkAction(org.pac4j.core.exception.http.OkAction) Test(org.junit.Test)

Example 7 with OkAction

use of org.pac4j.core.exception.http.OkAction in project pac4j by pac4j.

the class PostSAML2ClientTests method testStandardSpEntityIdForPostBinding.

@Test
public void testStandardSpEntityIdForPostBinding() {
    final var client = getClient();
    client.getConfiguration().setServiceProviderEntityId("http://localhost:8080/cb");
    final var action = (OkAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
    final var issuerJdk11 = "<saml2:Issuer " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" " + "Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\">http://localhost:8080/cb</saml2:Issuer>";
    final var decodedAuthnRequest = getDecodedAuthnRequest(action.getContent());
    assertTrue(decodedAuthnRequest.contains(issuerJdk11));
}
Also used : MockSessionStore(org.pac4j.core.context.session.MockSessionStore) OkAction(org.pac4j.core.exception.http.OkAction) Test(org.junit.Test)

Example 8 with OkAction

use of org.pac4j.core.exception.http.OkAction in project pac4j by pac4j.

the class SAML2LogoutMessageReceiverTest method shouldAcceptLogoutResponseWithNoRedirect.

@Test
public void shouldAcceptLogoutResponseWithNoRedirect() {
    var webContext = getMockWebContext();
    var context = getSaml2MessageContext(webContext);
    SAML2ResponseValidator validator = getLogoutValidator("");
    var unit = new SAML2LogoutMessageReceiver(validator, context.getSAML2Configuration());
    try {
        unit.receiveMessage(context);
        fail("Should have thrown a FoundAction");
    } catch (SAMLException e) {
        fail(e.getMessage());
    } catch (OkAction e) {
        assertTrue("SAML2LogoutMessageReceiver processed the logout message successfully", true);
        MatcherAssert.assertThat(e.getContent(), is(""));
    }
}
Also used : SAML2ResponseValidator(org.pac4j.saml.profile.api.SAML2ResponseValidator) SAMLException(org.pac4j.saml.exceptions.SAMLException) OkAction(org.pac4j.core.exception.http.OkAction) Test(org.junit.Test)

Aggregations

OkAction (org.pac4j.core.exception.http.OkAction)8 Test (org.junit.Test)7 MockSessionStore (org.pac4j.core.context.session.MockSessionStore)5 WebContext (org.pac4j.core.context.WebContext)2 ParseException (com.nimbusds.oauth2.sdk.ParseException)1 State (com.nimbusds.oauth2.sdk.id.State)1 AuthenticationErrorResponse (com.nimbusds.openid.connect.sdk.AuthenticationErrorResponse)1 AuthenticationResponse (com.nimbusds.openid.connect.sdk.AuthenticationResponse)1 AuthenticationSuccessResponse (com.nimbusds.openid.connect.sdk.AuthenticationSuccessResponse)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 MockWebContext (org.pac4j.core.context.MockWebContext)1 SessionStore (org.pac4j.core.context.session.SessionStore)1 TechnicalException (org.pac4j.core.exception.TechnicalException)1 OidcCredentials (org.pac4j.oidc.credentials.OidcCredentials)1 SAMLException (org.pac4j.saml.exceptions.SAMLException)1 SAML2MetadataContactPerson (org.pac4j.saml.metadata.SAML2MetadataContactPerson)1 SAML2MetadataUIInfo (org.pac4j.saml.metadata.SAML2MetadataUIInfo)1 SAML2ResponseValidator (org.pac4j.saml.profile.api.SAML2ResponseValidator)1