use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcAuthenticationAuthorizeSecurityLogicTests method verifyLoadNoProfileWhenNoTgtAvailable.
@Test
public void verifyLoadNoProfileWhenNoTgtAvailable() {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
val profileManager = new ProfileManager(context, JEESessionStore.INSTANCE);
profileManager.save(true, new BasicUserProfile(), false);
val logic = new OidcAuthenticationAuthorizeSecurityLogic(ticketGrantingTicketCookieGenerator, ticketRegistry, centralAuthenticationService);
assertTrue(logic.loadProfiles(profileManager, context, JEESessionStore.INSTANCE, List.of()).isEmpty());
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcCallbackAuthorizeViewResolverTests method verifyPromptNoneWithoutProfileWithRedirectParam.
@Test
public void verifyPromptNoneWithoutProfileWithRedirectParam() {
val request = new MockHttpServletRequest();
request.addParameter(OAuth20Constants.REDIRECT_URI, "https://google.com");
val url = "https://cas.org/something?" + OidcConstants.PROMPT + "=none";
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
val manager = new ProfileManager(context, JEESessionStore.INSTANCE);
val mv = callbackAuthorizeViewResolver.resolve(context, manager, url);
assertNotNull(mv);
assertEquals(mv.getModel().get(OAuth20Constants.ERROR), OidcConstants.LOGIN_REQUIRED);
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcCallbackAuthorizeViewResolverTests method verifyPromptLogin.
@Test
public void verifyPromptLogin() {
val request = new MockHttpServletRequest();
val url = "https://cas.org/something?" + OidcConstants.PROMPT + "=login";
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
val manager = new ProfileManager(context, JEESessionStore.INSTANCE);
val mv = callbackAuthorizeViewResolver.resolve(context, manager, url);
assertNotNull(mv);
assertTrue(mv.getView() instanceof RedirectView);
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcCallbackAuthorizeViewResolverTests method verifyRedirect.
@Test
public void verifyRedirect() {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val context = new JEEContext(request, response);
val manager = new ProfileManager(context, JEESessionStore.INSTANCE);
val profile = new CommonProfile();
profile.setClientName(Authenticators.CAS_OAUTH_CLIENT_BASIC_AUTHN);
profile.setId("casuser");
manager.save(true, profile, false);
val mv = callbackAuthorizeViewResolver.resolve(context, manager, "https://github.com");
assertNotNull(mv);
assertTrue(mv.getView() instanceof RedirectView);
}
use of org.pac4j.core.context.JEEContext in project cas by apereo.
the class OidcCasCallbackUrlResolverTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
request.addParameter(OAuth20Constants.CLIENT_ID, UUID.randomUUID().toString());
request.addParameter(OAuth20Constants.STATE, UUID.randomUUID().toString());
request.addParameter(OidcConstants.UI_LOCALES, "de");
request.addParameter(OidcConstants.MAX_AGE, "100");
request.addParameter(OidcConstants.REQUEST_URI, UUID.randomUUID().toString());
val output = casCallbackUrlResolver.compute(OAuth20Utils.casOAuthCallbackUrl(casProperties.getServer().getPrefix()), new JEEContext(request, response));
assertNotNull(output);
val uri = new URIBuilder(output);
assertTrue(uri.getQueryParams().stream().anyMatch(p -> p.getName().equalsIgnoreCase(OAuth20Constants.CLIENT_ID)));
assertTrue(uri.getQueryParams().stream().anyMatch(p -> p.getName().equalsIgnoreCase(OAuth20Constants.STATE)));
assertTrue(uri.getQueryParams().stream().anyMatch(p -> p.getName().equalsIgnoreCase(OidcConstants.UI_LOCALES)));
assertTrue(uri.getQueryParams().stream().anyMatch(p -> p.getName().equalsIgnoreCase(OidcConstants.MAX_AGE)));
assertTrue(uri.getQueryParams().stream().anyMatch(p -> p.getName().equalsIgnoreCase(OidcConstants.REQUEST_URI)));
}
Aggregations