Search in sources :

Example 31 with J2EContext

use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.

the class RedirectSAML2ClientTests method testAuthnContextClassRef.

@Test
public void testAuthnContextClassRef() {
    final SAML2Client client = getClient();
    client.getConfiguration().setComparisonType(AuthnContextComparisonTypeEnumeration.EXACT.toString());
    client.getConfiguration().setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
    final WebContext context = new J2EContext(new MockHttpServletRequest(), new MockHttpServletResponse());
    final RedirectAction action = client.getRedirectAction(context);
    final String checkClass = "<saml2p:RequestedAuthnContext Comparison=\"exact\"><saml2:AuthnContextClassRef " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\">" + "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>" + "</saml2p:RequestedAuthnContext>";
    assertTrue(getInflatedAuthnRequest(action.getLocation()).contains(checkClass));
}
Also used : WebContext(org.pac4j.core.context.WebContext) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) J2EContext(org.pac4j.core.context.J2EContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) RedirectAction(org.pac4j.core.redirect.RedirectAction) Test(org.junit.Test)

Example 32 with J2EContext

use of org.pac4j.core.context.J2EContext in project pac4j by pac4j.

the class DefaultCallbackLogicTests method setUp.

@Before
public void setUp() {
    logic = new DefaultCallbackLogic<>();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    context = new J2EContext(request, response);
    config = new Config();
    httpActionAdapter = (code, ctx) -> null;
    defaultUrl = null;
    renewSession = null;
    clientFinder = new DefaultCallbackClientFinder();
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Config(org.pac4j.core.config.Config) DefaultCallbackClientFinder(org.pac4j.core.client.finder.DefaultCallbackClientFinder) J2EContext(org.pac4j.core.context.J2EContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Aggregations

J2EContext (org.pac4j.core.context.J2EContext)32 RedirectAction (org.pac4j.core.redirect.RedirectAction)13 Test (org.junit.Test)11 WebContext (org.pac4j.core.context.WebContext)11 ProfileManager (org.pac4j.core.profile.ProfileManager)11 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)11 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)11 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)6 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)6 UserProfile (org.pac4j.core.profile.UserProfile)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 Service (org.apereo.cas.authentication.principal.Service)5 Authentication (org.apereo.cas.authentication.Authentication)4 AccessToken (org.apereo.cas.ticket.accesstoken.AccessToken)4 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)3 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)2 AuthenticationResult (org.apereo.cas.authentication.AuthenticationResult)2 PrincipalException (org.apereo.cas.authentication.PrincipalException)2