Package x.oauth
Class OAuthMain
java.lang.Object
x.oauth.OAuthMain
OAuth 2.0 Main Services.
- Author:
- sakdsitt
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static AuthorizationServerstatic final Longstatic final Longprotected static org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<ApplicationInfo> filterClientApps(javax.servlet.http.HttpServletRequest req, List<ApplicationInfo> apps) static StringhandleAuthorize(javax.servlet.http.HttpServletRequest req) 1.static StringhandleDeleteScope(javax.servlet.http.HttpServletRequest req) 5.static StringhandleGetAccessTokens(javax.servlet.http.HttpServletRequest req) 2.static StringhandleGetAllClientApplications(javax.servlet.http.HttpServletRequest req) 9.static StringhandleGetAllScopes(javax.servlet.http.HttpServletRequest req) 2.static StringhandleGetClientApplication(javax.servlet.http.HttpServletRequest req) Get info about a client application by clientIdstatic StringhandleGetScope(javax.servlet.http.HttpServletRequest req) 3.static StringhandleRegister(javax.servlet.http.HttpServletRequest req) 6.static StringhandleRegisterScope(javax.servlet.http.HttpServletRequest req) 1.static StringhandleToken(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.static StringhandleTokenRevoke(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" }static StringhandleTokenValidate(javax.servlet.http.HttpServletRequest req) Access token validation GET /oauth20/tokens/validate?static StringhandleUpdateClientApplication(javax.servlet.http.HttpServletRequest req) 7.static StringhandleUpdateScope(javax.servlet.http.HttpServletRequest req) 4.
-
Field Details
-
log
protected static org.slf4j.Logger log -
auth
-
DEFAULT_PASSWORD_EXPIRES_IN
-
DEFAULT_CC_EXPIRES_IN
-
-
Constructor Details
-
OAuthMain
public OAuthMain()
-
-
Method Details
-
handleRegisterScope
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
2. List all registered scopes GET http://127.0.0.1:8080/oauth20/scopes -
handleGetScope
3. Get details about a scope GET /oauth20/scopes/[scope] GET http://127.0.0.1:8080/oauth20/scopes/extended -
handleUpdateScope
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
5. Delete a scope DELETE /oauth20/scopes/[scope] -
handleRegister
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
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
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
Get info about a client application by clientId -
handleAuthorize
1. Authorization code flow first step, obtaining an authorization code -
handleToken
The second step to issue an access token is to use the authorization code returned in the response of the step 1. -
handleGetAccessTokens
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
Access token validation GET /oauth20/tokens/validate?token=[access_token] GET http://127.0.0.1:8080/oauth20/tokens/validate?token=f48db3829c71b9dc4957e3bb7b804bd0d44db10a2b9e30346796c2d9e9f44722 -
handleTokenRevoke
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" }
-