use of org.pac4j.core.engine.DefaultCallbackLogic in project cas by apereo.
the class CasConsentReviewConfiguration method casConsentPac4jConfig.
@Bean
@RefreshScope
public Config casConsentPac4jConfig() {
final CasConfiguration conf = new CasConfiguration(casProperties.getServer().getLoginUrl());
final CasClient client = new CasClient(conf);
client.setName(CAS_CONSENT_CLIENT);
client.setCallbackUrl(casProperties.getServer().getPrefix().concat("/consentReview/callback"));
client.setAuthorizationGenerator(new DefaultCasAuthorizationGenerator<>());
final Clients clients = new Clients(client);
final Config config = new Config(clients);
config.setAuthorizer(new IsAuthenticatedAuthorizer());
config.setCallbackLogic(new DefaultCallbackLogic());
config.setLogoutLogic(new DefaultLogoutLogic());
// get role authorizer from admin pages for smooth integration
final Map<String, Authorizer> adminAuthorizers = casAdminPagesPac4jConfig.getAuthorizers();
final String auth = RequireAnyRoleAuthorizer.class.getSimpleName();
if (adminAuthorizers.containsKey(auth)) {
config.addAuthorizer(auth, adminAuthorizers.get(auth));
final BaseClient adminClient = casAdminPagesPac4jConfig.getClients().findClient(DirectCasClient.class);
client.addAuthorizationGenerators(adminClient.getAuthorizationGenerators());
}
return config;
}
use of org.pac4j.core.engine.DefaultCallbackLogic in project cas by apereo.
the class OAuth20CallbackAuthorizeEndpointController method handleRequest.
/**
* Handle request.
*
* @param request the request
* @param response the response
* @return the model and view
*/
@GetMapping(path = OAuth20Constants.BASE_OAUTH20_URL + '/' + OAuth20Constants.CALLBACK_AUTHORIZE_URL)
public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) {
final J2EContext context = new J2EContext(request, response, this.oauthConfig.getSessionStore());
final DefaultCallbackLogic callback = new DefaultCallbackLogic();
callback.perform(context, oauthConfig, J2ENopHttpActionAdapter.INSTANCE, null, true, false, false, Authenticators.CAS_OAUTH_CLIENT);
final String url = StringUtils.remove(response.getHeader("Location"), "redirect:");
final ProfileManager manager = Pac4jUtils.getPac4jProfileManager(request, response);
return oAuth20CallbackAuthorizeViewResolver.resolve(context, manager, url);
}
Aggregations