Search in sources :

Example 31 with SessionStore

use of org.pac4j.core.context.session.SessionStore in project pac4j by pac4j.

the class CsrfAuthorizerTests method testNoToken.

@Test
public void testNoToken() {
    final WebContext context = MockWebContext.create();
    final SessionStore sessionStore = new MockSessionStore();
    sessionStore.set(context, Pac4jConstants.CSRF_TOKEN, VALUE);
    sessionStore.set(context, Pac4jConstants.CSRF_TOKEN_EXPIRATION_DATE, expirationDate);
    Assert.assertFalse(authorizer.isAuthorized(context, sessionStore, null));
}
Also used : MockSessionStore(org.pac4j.core.context.session.MockSessionStore) SessionStore(org.pac4j.core.context.session.SessionStore) WebContext(org.pac4j.core.context.WebContext) MockWebContext(org.pac4j.core.context.MockWebContext) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) Test(org.junit.Test)

Example 32 with SessionStore

use of org.pac4j.core.context.session.SessionStore in project pac4j by pac4j.

the class RedirectSAML2ClientTests method testRelayState.

@Test
public void testRelayState() {
    final var client = getClient();
    final WebContext context = MockWebContext.create();
    final SessionStore sessionStore = new MockSessionStore();
    sessionStore.set(context, SAML2StateGenerator.SAML_RELAY_STATE_ATTRIBUTE, "relayState");
    final var action = (FoundAction) client.getRedirectionAction(context, sessionStore).get();
    assertTrue(action.getLocation().contains("RelayState=relayState"));
}
Also used : MockSessionStore(org.pac4j.core.context.session.MockSessionStore) SessionStore(org.pac4j.core.context.session.SessionStore) WebContext(org.pac4j.core.context.WebContext) MockWebContext(org.pac4j.core.context.MockWebContext) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) FoundAction(org.pac4j.core.exception.http.FoundAction) Test(org.junit.Test)

Aggregations

SessionStore (org.pac4j.core.context.session.SessionStore)32 MockSessionStore (org.pac4j.core.context.session.MockSessionStore)22 Test (org.junit.Test)20 WebContext (org.pac4j.core.context.WebContext)18 MockWebContext (org.pac4j.core.context.MockWebContext)13 FoundAction (org.pac4j.core.exception.http.FoundAction)6 CommonProfile (org.pac4j.core.profile.CommonProfile)5 Slf4j (lombok.extern.slf4j.Slf4j)3 lombok.val (lombok.val)3 Client (org.pac4j.core.client.Client)3 Date (java.util.Date)2 Optional (java.util.Optional)2 SneakyThrows (lombok.SneakyThrows)2 ServicesManager (org.apereo.cas.services.ServicesManager)2 Unchecked (org.jooq.lambda.Unchecked)2 HttpAction (org.pac4j.core.exception.http.HttpAction)2 Algorithm (com.nimbusds.jose.Algorithm)1 JWSAlgorithm (com.nimbusds.jose.JWSAlgorithm)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 MalformedURLException (java.net.MalformedURLException)1