use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcConsentApprovalViewResolverTests method verifyBypassedBySession.
@Test
public void verifyBypassedBySession() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
JEESessionStore.INSTANCE.set(context, OAuth20Constants.BYPASS_APPROVAL_PROMPT, "true");
val service = getOAuthRegisteredService(UUID.randomUUID().toString(), "https://google.com");
assertFalse(consentApprovalViewResolver.resolve(context, service).hasView());
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcConsentApprovalViewResolverTests method verifyBypassedByPrompt.
@Test
public void verifyBypassedByPrompt() throws Exception {
val request = new MockHttpServletRequest();
request.setRequestURI("https://cas.org/something");
request.setQueryString(OidcConstants.PROMPT + '=' + OidcConstants.PROMPT_CONSENT);
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
val service = getOidcRegisteredService(UUID.randomUUID().toString());
val mv = consentApprovalViewResolver.resolve(context, service);
assertTrue(mv.hasView());
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcPushedAuthorizationRequestValidatorTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val registeredService = getOidcRegisteredService();
val profile = new CommonProfile();
profile.setId("casTest");
val holder = AccessTokenRequestContext.builder().clientId(registeredService.getClientId()).service(RegisteredServiceTestUtils.getService()).authentication(RegisteredServiceTestUtils.getAuthentication()).registeredService(registeredService).grantType(OAuth20GrantTypes.AUTHORIZATION_CODE).responseType(OAuth20ResponseTypes.CODE).userProfile(profile).build();
val factory = (OidcPushedAuthorizationRequestFactory) defaultTicketFactory.get(OidcPushedAuthorizationRequest.class);
val ticket = factory.create(holder);
assertNotNull(ticket);
ticketRegistry.addTicket(ticket);
val request = new MockHttpServletRequest();
request.addParameter(OAuth20Constants.CLIENT_ID, holder.getClientId());
request.addParameter(OidcConstants.REQUEST_URI, ticket.getId());
val context = new JEEContext(request, new MockHttpServletResponse());
assertTrue(oidcPushedAuthorizationRequestValidator.supports(context));
assertTrue(oidcPushedAuthorizationRequestValidator.validate(context));
assertEquals(0, oidcPushedAuthorizationRequestValidator.getOrder());
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcRequestSupportTests method verifyAuthnProfile.
@Test
public void verifyAuthnProfile() {
val request = new MockHttpServletRequest();
request.setRequestURI("https://www.example.org");
request.setQueryString("param=value");
val context = new JEEContext(request, new MockHttpServletResponse());
val profile = new CommonProfile();
context.setRequestAttribute(Pac4jConstants.USER_PROFILES, CollectionUtils.wrapLinkedHashMap(profile.getClientName(), profile));
assertTrue(OidcRequestSupport.isAuthenticationProfileAvailable(context, JEESessionStore.INSTANCE).isPresent());
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcRequestSupportTests method getContextForEndpoint.
protected static JEEContext getContextForEndpoint(final String endpoint) {
val request = new MockHttpServletRequest();
request.setScheme("https");
request.setServerName("sso.example.org");
request.setServerPort(8443);
request.setRequestURI("/cas/oidc/" + endpoint);
val response = new MockHttpServletResponse();
return new JEEContext(request, response);
}
Aggregations