Search in sources :

Example 1 with CheckedFunction

use of org.jooq.lambda.fi.util.function.CheckedFunction in project cas by apereo.

the class OAuth20AuthorizationCodeAuthorizationResponseBuilder method build.

@Audit(action = AuditableActions.OAUTH2_CODE_RESPONSE, actionResolverName = AuditActionResolvers.OAUTH2_CODE_RESPONSE_ACTION_RESOLVER, resourceResolverName = AuditResourceResolvers.OAUTH2_CODE_RESPONSE_RESOURCE_RESOLVER)
@Override
public ModelAndView build(final AccessTokenRequestContext holder) throws Exception {
    val authentication = holder.getAuthentication();
    val factory = (OAuth20CodeFactory) configurationContext.getTicketFactory().get(OAuth20Code.class);
    val code = factory.create(holder.getService(), authentication, holder.getTicketGrantingTicket(), holder.getScopes(), holder.getCodeChallenge(), holder.getCodeChallengeMethod(), holder.getClientId(), holder.getClaims(), holder.getResponseType(), holder.getGrantType());
    LOGGER.debug("Generated OAuth code: [{}]", code);
    configurationContext.getCentralAuthenticationService().addTicket(code);
    val ticketGrantingTicket = holder.getTicketGrantingTicket();
    Optional.ofNullable(ticketGrantingTicket).ifPresent(tgt -> {
        FunctionUtils.doAndHandle(ticket -> {
            configurationContext.getCentralAuthenticationService().updateTicket(ticket);
        }, (CheckedFunction<Throwable, TicketGrantingTicket>) throwable -> {
            LOGGER.error("Unable to update ticket-granting-ticket [{}]", ticketGrantingTicket, throwable);
            return null;
        }).accept(tgt);
    });
    return buildCallbackViewViaRedirectUri(holder, code);
}
Also used : lombok.val(lombok.val) OAuth20Constants(org.apereo.cas.support.oauth.OAuth20Constants) OAuth20ResponseTypes(org.apereo.cas.support.oauth.OAuth20ResponseTypes) OAuth20Utils(org.apereo.cas.support.oauth.util.OAuth20Utils) OAuth20ConfigurationContext(org.apereo.cas.support.oauth.web.endpoints.OAuth20ConfigurationContext) CheckedFunction(org.jooq.lambda.fi.util.function.CheckedFunction) Audit(org.apereo.inspektr.audit.annotation.Audit) OAuth20CodeFactory(org.apereo.cas.ticket.code.OAuth20CodeFactory) lombok.val(lombok.val) StringUtils(org.apache.commons.lang3.StringUtils) AuditActionResolvers(org.apereo.cas.audit.AuditActionResolvers) LinkedHashMap(java.util.LinkedHashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) AccessTokenRequestContext(org.apereo.cas.support.oauth.web.response.accesstoken.ext.AccessTokenRequestContext) FunctionUtils(org.apereo.cas.util.function.FunctionUtils) Slf4j(lombok.extern.slf4j.Slf4j) OAuth20AuthorizationRequest(org.apereo.cas.support.oauth.web.response.OAuth20AuthorizationRequest) AuditResourceResolvers(org.apereo.cas.audit.AuditResourceResolvers) AuditableActions(org.apereo.cas.audit.AuditableActions) Optional(java.util.Optional) OAuth20Code(org.apereo.cas.ticket.code.OAuth20Code) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) OAuth20Code(org.apereo.cas.ticket.code.OAuth20Code) OAuth20CodeFactory(org.apereo.cas.ticket.code.OAuth20CodeFactory) CheckedFunction(org.jooq.lambda.fi.util.function.CheckedFunction) Audit(org.apereo.inspektr.audit.annotation.Audit)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 Optional (java.util.Optional)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1 StringUtils (org.apache.commons.lang3.StringUtils)1 AuditActionResolvers (org.apereo.cas.audit.AuditActionResolvers)1 AuditResourceResolvers (org.apereo.cas.audit.AuditResourceResolvers)1 AuditableActions (org.apereo.cas.audit.AuditableActions)1 OAuth20Constants (org.apereo.cas.support.oauth.OAuth20Constants)1 OAuth20ResponseTypes (org.apereo.cas.support.oauth.OAuth20ResponseTypes)1 OAuth20Utils (org.apereo.cas.support.oauth.util.OAuth20Utils)1 OAuth20ConfigurationContext (org.apereo.cas.support.oauth.web.endpoints.OAuth20ConfigurationContext)1 OAuth20AuthorizationRequest (org.apereo.cas.support.oauth.web.response.OAuth20AuthorizationRequest)1 AccessTokenRequestContext (org.apereo.cas.support.oauth.web.response.accesstoken.ext.AccessTokenRequestContext)1 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)1 OAuth20Code (org.apereo.cas.ticket.code.OAuth20Code)1 OAuth20CodeFactory (org.apereo.cas.ticket.code.OAuth20CodeFactory)1 FunctionUtils (org.apereo.cas.util.function.FunctionUtils)1 Audit (org.apereo.inspektr.audit.annotation.Audit)1 CheckedFunction (org.jooq.lambda.fi.util.function.CheckedFunction)1