Package org.openmhealth.reference.domain

Examples of org.openmhealth.reference.domain.AuthorizationCodeResponse


                final ResultSet resultSet,
                final int rowNum)
                throws SQLException {
               
                return
                  new AuthorizationCodeResponse(
                    resultSet
                      .getString(
                        AuthorizationCode
                          .JSON_KEY_CODE),
                    resultSet
View Full Code Here


            .getLocationUri());
      return;
    }
   
    // Get the response if it already exists.
    AuthorizationCodeResponse codeResponse =
      AuthorizationCodeResponseBin.getInstance().getResponse(code);
   
    // If the response does not exist, attempt to create a new one and
    // save it.
    if(codeResponse == null) {
      // Create the new code.
      codeResponse =
        new AuthorizationCodeResponse(authCode, user, granted);
     
      // Store it.
      AuthorizationCodeResponseBin
        .getInstance().storeVerification(codeResponse);
    }
    // Make sure it is being verified by the same user.
    else if(
      ! user
        .getUsername().equals(codeResponse.getOwner().getUsername())) {
     
      response
        .sendRedirect(
          OAuthASResponse
            .errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
            .setError(CodeResponse.ACCESS_DENIED)
            .setErrorDescription(
              "The code has already been verified by another " +
                "user.")
            .location(
              authCode
                .getThirdParty().getRedirectUri().toString())
            .setState(authCode.getState())
            .buildQueryMessage()
            .getLocationUri());
    }
    // Make sure the same grant response is being made.
    else if(granted == codeResponse.getGranted()) {
      response
        .sendRedirect(
          OAuthASResponse
            .errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
            .setError(CodeResponse.ACCESS_DENIED)
View Full Code Here

        return oauthResponse.getBody();
      }
     
      // Use the code to lookup the response information and error out if
      // a user has not yet verified it.
      AuthorizationCodeResponse codeResponse =
        AuthorizationCodeResponseBin
          .getInstance().getResponse(code.getCode());
      if(codeResponse == null) {
        // Create the OAuth response.
        OAuthResponse oauthResponse =
          OAuthASResponse
            .errorResponse(HttpServletResponse.SC_BAD_REQUEST)
            .setError(TokenResponse.INVALID_REQUEST)
            .setErrorDescription(
              "A user has not yet verified the code: " +
                codeString)
            .buildJSONMessage();
       
        // Set the status and return the error message.
        response.setStatus(oauthResponse.getResponseStatus());
        return oauthResponse.getBody();
      }
     
      // Determine if the user granted access and, if not, error out.
      if(! codeResponse.getGranted()) {
        // Create the OAuth response.
        OAuthResponse oauthResponse =
          OAuthASResponse
            .errorResponse(HttpServletResponse.SC_BAD_REQUEST)
            .setError(TokenResponse.INVALID_REQUEST)
View Full Code Here

TOP

Related Classes of org.openmhealth.reference.domain.AuthorizationCodeResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.