@Override public WebApplicationService createService(final String id) { return newWebApplicationService(HttpRequestUtils.getHttpServletRequestFromRequestAttributes(), id); }
/** * Gets pac4j context. * * @param sessionStore the session store * @return the pac4j context */ public static J2EContext getPac4jJ2EContext(final SessionStore sessionStore) { return getPac4jJ2EContext(HttpRequestUtils.getHttpServletRequestFromRequestAttributes(), HttpRequestUtils.getHttpServletResponseFromRequestAttributes(), sessionStore); }
/** * Gets pac4j context. * * @return the pac4j context */ public static J2EContext getPac4jJ2EContext() { return getPac4jJ2EContext(HttpRequestUtils.getHttpServletRequestFromRequestAttributes(), HttpRequestUtils.getHttpServletResponseFromRequestAttributes(), new J2ESessionStore()); } }
@Override public Service resolveServiceFrom(final Service service) { val clientId = resolveClientIdFromService(service); val redirectUri = resolveRedirectUri(service); val grantType = resolveGrantType(service); if (clientId.isPresent()) { if (redirectUri.isPresent()) { return this.webApplicationServiceFactory.createService(redirectUri.get().getValue()); } if (grantType.isPresent()) { var id = StringUtils.EMPTY; val grantValue = grantType.get().getValue(); if (OAuth20Utils.isGrantType(grantValue, OAuth20GrantTypes.CLIENT_CREDENTIALS)) { LOGGER.debug("Located grant type [{}]; checking for service headers", grantValue); val request = HttpRequestUtils.getHttpServletRequestFromRequestAttributes(); id = OAuth20Utils.getServiceRequestHeaderIfAny(request); } if (StringUtils.isBlank(id)) { id = clientId.get().getValue(); } LOGGER.debug("Built web application service based on identifier [{}]", id); return this.webApplicationServiceFactory.createService(id); } } return service; }
/** * Determine response type response. * * @param finalService the final service * @return the response type */ protected Response.ResponseType getWebApplicationServiceResponseType(final WebApplicationService finalService) { val request = HttpRequestUtils.getHttpServletRequestFromRequestAttributes(); val methodRequest = request != null ? request.getParameter(CasProtocolConstants.PARAMETER_METHOD) : null; final Function<String, String> func = FunctionUtils.doIf(StringUtils::isBlank, t -> { val registeredService = this.servicesManager.findServiceBy(finalService); if (registeredService != null) { return registeredService.getResponseType(); } return null; }, f -> methodRequest); val method = func.apply(methodRequest); if (StringUtils.isBlank(method)) { return Response.ResponseType.REDIRECT; } return Response.ResponseType.valueOf(method.toUpperCase()); } }
/** * Return the username of the authenticated user (based on pac4j security). * * @return the authenticated username. */ public static String getPac4jAuthenticatedUsername() { val request = HttpRequestUtils.getHttpServletRequestFromRequestAttributes(); val response = HttpRequestUtils.getHttpServletResponseFromRequestAttributes(); if (request != null && response != null) { val manager = getPac4jProfileManager(request, response); val profile = (Optional<CommonProfile>) manager.get(true); if (profile != null && profile.isPresent()) { val id = profile.get().getId(); if (id != null) { return id; } } } return PrincipalResolver.UNKNOWN_USER; }
val parameterList = new ParameterList(HttpRequestUtils.getHttpServletRequestFromRequestAttributes().getParameterMap());
@Override public void put(final String artifact, final String relyingPartyId, final String issuerId, final SAMLObject samlMessage) throws IOException { super.put(artifact, relyingPartyId, issuerId, samlMessage); val request = HttpRequestUtils.getHttpServletRequestFromRequestAttributes(); val ticketGrantingTicket = CookieUtils.getTicketGrantingTicketFromRequest( ticketGrantingTicketCookieGenerator, this.ticketRegistry, request); val ticket = samlArtifactTicketFactory.create(artifact, ticketGrantingTicket.getAuthentication(), ticketGrantingTicket, issuerId, relyingPartyId, samlMessage); this.ticketRegistry.addTicket(ticket); } }
val adaptorRes = SamlRegisteredServiceServiceProviderMetadataFacade.get(samlRegisteredServiceCachingMetadataResolver, samlService, serviceId); val adaptor = adaptorRes.orElseThrow(() -> new IllegalArgumentException("Unable to find metadata for saml service " + serviceId)); val httpRequest = HttpRequestUtils.getHttpServletRequestFromRequestAttributes(); val httpResponse = HttpRequestUtils.getHttpServletResponseFromRequestAttributes(); samlObjectSigner.encode(samlLogoutRequest, samlService, adaptor, httpResponse, httpRequest, binding, samlLogoutRequest);