Search in sources :

Example 11 with User

use of com.authlete.common.types.User in project java-oauth-server by authlete.

the class DeviceVerificationRequestHandlerSpiImpl method onNotExist.

@Override
public Response onNotExist() {
    // Urge the user to re-input a valid user code.
    // The user.
    User user = (User) mSession.getAttribute("user");
    // The model for rendering the verification page.
    DeviceVerificationPageModel model = new DeviceVerificationPageModel().setUserCode(mUserCode).setUser(user).setNotification("The user code does not exist.");
    // urge the user to re-input a valid user code.
    return notFound(new Viewable(VERIFICATION_PAGE_TEMPLATE, model));
}
Also used : User(com.authlete.common.types.User) DeviceVerificationPageModel(com.authlete.jaxrs.DeviceVerificationPageModel) Viewable(org.glassfish.jersey.server.mvc.Viewable)

Example 12 with User

use of com.authlete.common.types.User in project java-oauth-server by authlete.

the class BackchannelAuthenticationCallbackEndpoint method doProcess.

private Response doProcess(AsyncAuthenticationCallbackRequest request) {
    // Get the result of end-user authentication and authorization.
    Result result = getResult(request);
    // Get the ID of the request that this authorization server made to the
    // authentication device in AsyncAuthenticationDeviceProcessor.
    String requestId = getRequestId(request);
    // Retrieve information that was stored in AsyncAuthenticationDeviceProcessor.
    AuthInfo authInfo = getAuthInfo(requestId);
    // Get some variables from the stored information.
    String ticket = authInfo.getTicket();
    User user = authInfo.getUser();
    String[] claimNames = authInfo.getClaimNames();
    String[] acrs = authInfo.getAcrs();
    Date authTime = (result == Result.AUTHORIZED) ? new Date() : null;
    String errorDescription = determineErrorDescription(request);
    // Complete the authentication and authorization process.
    new BackchannelAuthenticationCompleteRequestHandler(AuthleteApiFactory.getDefaultApi(), new BackchannelAuthenticationCompleteHandlerSpiImpl(result, user, authTime, acrs, errorDescription, null)).handle(ticket, claimNames);
    // Delete the stored information.
    removeAuthInfo(requestId);
    // 204 No Content.
    return noContent();
}
Also used : User(com.authlete.common.types.User) Date(java.util.Date) Result(com.authlete.common.dto.BackchannelAuthenticationCompleteRequest.Result) BackchannelAuthenticationCompleteRequestHandler(com.authlete.jaxrs.BackchannelAuthenticationCompleteRequestHandler)

Example 13 with User

use of com.authlete.common.types.User in project java-oauth-server by authlete.

the class DeviceCompleteEndpoint method post.

/**
 * Process a request from the form in the authorization page in OAuth 2.0
 * Device Authorization Grant (Device Flow).
 */
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response post(@Context HttpServletRequest request, MultivaluedMap<String, String> parameters) {
    // Get the existing session.
    HttpSession session = getSession(request);
    // Get the information from the session.
    String userCode = getUserCode(session);
    User user = getUser(session);
    Date authTime = (Date) session.getAttribute("authTime");
    String[] claimNames = (String[]) takeAttribute(session, "claimNames");
    String[] acrs = (String[]) takeAttribute(session, "acrs");
    // Handle the device complete request.
    return handle(parameters, user, authTime, acrs, userCode, claimNames);
}
Also used : User(com.authlete.common.types.User) HttpSession(javax.servlet.http.HttpSession) Date(java.util.Date) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

User (com.authlete.common.types.User)13 Date (java.util.Date)6 HttpSession (javax.servlet.http.HttpSession)5 Viewable (org.glassfish.jersey.server.mvc.Viewable)4 DeviceVerificationPageModel (com.authlete.jaxrs.DeviceVerificationPageModel)3 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 Result (com.authlete.common.dto.BackchannelAuthenticationCompleteRequest.Result)1 Client (com.authlete.common.dto.Client)1 Params (com.authlete.jaxrs.AuthorizationDecisionHandler.Params)1 BackchannelAuthenticationCompleteRequestHandler (com.authlete.jaxrs.BackchannelAuthenticationCompleteRequestHandler)1 Federation (com.authlete.jaxrs.server.federation.Federation)1 AuthorizationDecisionHandlerSpi (com.authlete.jaxrs.spi.AuthorizationDecisionHandlerSpi)1 UserInfo (com.nimbusds.openid.connect.sdk.claims.UserInfo)1 URI (java.net.URI)1 Path (javax.ws.rs.Path)1