Package x.oauth

Class OAuthMain

java.lang.Object
x.oauth.OAuthMain

public class OAuthMain extends Object
OAuth 2.0 Main Services.
Author:
sakdsitt
  • Field Details

    • log

      protected static org.slf4j.Logger log
    • auth

      protected static AuthorizationServer auth
    • DEFAULT_PASSWORD_EXPIRES_IN

      public static final Long DEFAULT_PASSWORD_EXPIRES_IN
    • DEFAULT_CC_EXPIRES_IN

      public static final Long DEFAULT_CC_EXPIRES_IN
  • Constructor Details

    • OAuthMain

      public OAuthMain()
  • Method Details

    • handleRegisterScope

      public static String handleRegisterScope(javax.servlet.http.HttpServletRequest req)
      1. Register a new scope (restricted access recommended) POST /oauth20/scopes Content-Type: application/json {"scope":[scope name],"description":[description],"cc_expires_in":[client credentials tokens expiration time in seconds], "pass_expires_in":[password tokens expiration time in seconds], "refresh_expires_in":[refresh tokens expiration time in second]} POST http://127.0.0.1:8080/oauth20/scopes Content-Type: application/json { "scope": "basic", "description": "basic scope", "cc_expires_in": 1800, "pass_expires_in": 900, "refresh_expires_in": 3600 }
    • handleGetAllScopes

      public static String handleGetAllScopes(javax.servlet.http.HttpServletRequest req)
      2. List all registered scopes GET http://127.0.0.1:8080/oauth20/scopes
    • handleGetScope

      public static String handleGetScope(javax.servlet.http.HttpServletRequest req)
      3. Get details about a scope GET /oauth20/scopes/[scope] GET http://127.0.0.1:8080/oauth20/scopes/extended
    • handleUpdateScope

      public static String handleUpdateScope(javax.servlet.http.HttpServletRequest req)
      4. Update a scope PUT /oauth20/scopes/[scope] Content-Type: application/json {"description":[description],"cc_expires_in":[client credentials tokens expiration time in seconds], "pass_expires_in":[password tokens expiration time in seconds], "refresh_expires_in":[refresh tokens expiration time in second]} PUT http://127.0.0.1:8080/oauth20/scopes Content-Type: application/json {"description":"new basic scope description"}
    • handleDeleteScope

      public static String handleDeleteScope(javax.servlet.http.HttpServletRequest req)
      5. Delete a scope DELETE /oauth20/scopes/[scope]
    • handleRegister

      public static String handleRegister(javax.servlet.http.HttpServletRequest req)
      6. Register a client application POST /oauth20/applications Content-Type: application/json {"name":[client application name],"description":[description],"scope":[scope], "redirect_uri":[redirect uri], "details":[refresh tokens expiration time in second],"client_id":[client id],"client_secret":[client secret]} POST http://127.0.0.1:8080/oauth20/applications Content-Type: application/json { "name": "test_app", "description": "test client app", "scope": "test_scope", "redirect_uri": "http://127.0.0.1:8080" }
    • handleUpdateClientApplication

      public static String handleUpdateClientApplication(javax.servlet.http.HttpServletRequest req)
      7. Update a client application PUT /oauth20/applications/[client_ id] PUT http://127.0.0.1:8080/oauth20/applications/b9db6d84dc98a895035e68f972e30503d3c724c8 Content-Type: application/json { "description": "updated description", "scope": "test_scope", "application_details": { "division": "IT", "organization": "MM" } } 8. Activate/Deactivate a client application PUT /oauth20/applications/[client_ id] PUT http://127.0.0.1:8080/oauth20/applications/b9db6d84dc98a895035e68f972e30503d3c724c8 Content-Type: application/json {"status":1}
    • handleGetAllClientApplications

      public static String handleGetAllClientApplications(javax.servlet.http.HttpServletRequest req)
      9. Get all client application GET http://127.0.0.1:8080/oauth20/applications 10. List all active/inactive client applications GET http://127.0.0.1:8080/oauth20/applications?status=1
    • filterClientApps

      public static List<ApplicationInfo> filterClientApps(javax.servlet.http.HttpServletRequest req, List<ApplicationInfo> apps)
    • handleGetClientApplication

      public static String handleGetClientApplication(javax.servlet.http.HttpServletRequest req)
      Get info about a client application by clientId
    • handleAuthorize

      public static String handleAuthorize(javax.servlet.http.HttpServletRequest req)
      1. Authorization code flow first step, obtaining an authorization code
    • handleToken

      public static String handleToken(javax.servlet.http.HttpServletRequest request)
      The second step to issue an access token is to use the authorization code returned in the response of the step 1.
    • handleGetAccessTokens

      public static String handleGetAccessTokens(javax.servlet.http.HttpServletRequest req)
      2. Client credentials grant type Access tokens with grant type client credentials are obtained by posting a request to /oauth20/tokens with grant_type=client_credentials. Here is an example request: 3. Resource owner password credentials grant Access tokens with grant type client credentials are obtained by posting a request to /oauth20/tokens with grant_type=password. Here is an example request: 4. Refresh token grant type Access tokens with grant type client credentials are obtained by posting a request to /oauth20/tokens with grant_type=refresh_token. Here is an example request:
    • handleTokenValidate

      public static String handleTokenValidate(javax.servlet.http.HttpServletRequest req)
      Access token validation GET /oauth20/tokens/validate?token=[access_token] GET http://127.0.0.1:8080/oauth20/tokens/validate?token=f48db3829c71b9dc4957e3bb7b804bd0d44db10a2b9e30346796c2d9e9f44722
    • handleTokenRevoke

      public static String handleTokenRevoke(javax.servlet.http.HttpServletRequest req)
      Access token revocation POST /oauth20/tokens/revoke Content-Type: application/json {"access_token":[access_token],"client_id":[client_id]} POST http://127.0.0.1:8080/oauth20/tokens/revoke Content-Type: application/json { "access_token": "f48db3829c71b9dc4957e3bb7b804bd0d44db10a2b9e30346796c2d9e9f44722", "client_id": "b9db6d84dc98a895035e68f972e30503d3c724c8" }