/** * Remove cookie. * * @param webContext the web context */ public void removeCookie(final J2EContext webContext) { cookieGenerator.removeCookie(webContext.getResponse()); }
@RequestMapping("/centralLogout") @ResponseBody public void centralLogout() { logoutController.logout(webContext.getRequest(), webContext.getResponse()); }
/** * Store. * * @param webContext the web context */ public void store(final J2EContext webContext) { val session = Maps.<String, Object>newLinkedHashMap(); val webSession = (HttpSession) webContext.getSessionStore().getTrackableSession(webContext); val names = webSession.getAttributeNames(); while (names.hasMoreElements()) { val name = names.nextElement(); val value = webSession.getAttribute(name); session.put(name, value); } val cookieValue = serializeSessionValues(session); cookieGenerator.addCookie(webContext.getRequest(), webContext.getResponse(), cookieValue); }
@Override public boolean validate(final J2EContext context) { val request = context.getRequest(); val response = context.getResponse(); val grantType = request.getParameter(OAuth20Constants.GRANT_TYPE); if (!isGrantTypeSupported(grantType, OAuth20GrantTypes.values())) { LOGGER.warn("Grant type is not supported: [{}]", grantType); return false; } val manager = Pac4jUtils.getPac4jProfileManager(request, response); val profile = (Optional<CommonProfile>) manager.get(true); if (profile.isEmpty()) { LOGGER.warn("Could not locate authenticated profile for this request. Request is not authenticated"); return false; } val uProfile = profile.get(); return validateInternal(context, grantType, manager, uProfile); }
@Override public View build(final J2EContext context, final String clientId, final AccessTokenRequestDataHolder holder) { val accessTokenResult = accessTokenGenerator.generate(holder); val result = OAuth20AccessTokenResponseResult.builder() .registeredService(holder.getRegisteredService()) .service(holder.getService()) .accessTokenTimeout(accessTokenExpirationPolicy.getTimeToLive()) .responseType(OAuth20Utils.getResponseType(context)) .casProperties(casProperties) .generatedToken(accessTokenResult) .build(); accessTokenResponseGenerator.generate(context.getRequest(), context.getResponse(), result); return null; }