Search in sources :

Example 1 with AuthorizationDecisionHandlerSpi

use of com.authlete.jaxrs.spi.AuthorizationDecisionHandlerSpi in project java-oauth-server by authlete.

the class AuthorizationDecisionEndpoint method post.

/**
 * Process a request from the form in the authorization page.
 *
 * <p>
 * NOTE:
 * A better implementation would re-display the authorization page
 * when the pair of login ID and password is wrong, but this
 * implementation does not do it for brevity. A much better
 * implementation would check the login credentials by Ajax.
 * </p>
 *
 * @param request
 *         A request from the form in the authorization page.
 *
 * @param parameters
 *         Request parameters.
 *
 * @return
 *         A response to the user agent. Basically, the response
 *         will trigger redirection to the client's redirect
 *         endpoint.
 */
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response post(@Context HttpServletRequest request, MultivaluedMap<String, String> parameters) {
    // Get the existing session.
    HttpSession session = getSession(request);
    // Retrieve some variables from the session. See the implementation
    // of AuthorizationRequestHandlerSpiImpl.getAuthorizationPage().
    Params params = (Params) takeAttribute(session, "params");
    String[] acrs = (String[]) takeAttribute(session, "acrs");
    Client client = (Client) takeAttribute(session, "client");
    User user = getUser(session, parameters);
    Date authTime = (Date) session.getAttribute("authTime");
    // Implementation of AuthorizationDecisionHandlerSpi.
    AuthorizationDecisionHandlerSpi spi = new AuthorizationDecisionHandlerSpiImpl(parameters, user, authTime, params.getIdTokenClaims(), acrs, client);
    // Handle the end-user's decision.
    return handle(AuthleteApiFactory.getDefaultApi(), spi, params);
}
Also used : User(com.authlete.common.types.User) HttpSession(javax.servlet.http.HttpSession) Params(com.authlete.jaxrs.AuthorizationDecisionHandler.Params) AuthorizationDecisionHandlerSpi(com.authlete.jaxrs.spi.AuthorizationDecisionHandlerSpi) Client(com.authlete.common.dto.Client) Date(java.util.Date) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

Client (com.authlete.common.dto.Client)1 User (com.authlete.common.types.User)1 Params (com.authlete.jaxrs.AuthorizationDecisionHandler.Params)1 AuthorizationDecisionHandlerSpi (com.authlete.jaxrs.spi.AuthorizationDecisionHandlerSpi)1 Date (java.util.Date)1 HttpSession (javax.servlet.http.HttpSession)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1