Class GrouperOAuthStore
java.lang.Object
edu.internet2.middleware.grouper.authentication.GrouperOAuthStore
Store for OAuth pending requests, authorization codes, and registered clients.
All data is persisted via GcDbAccess to the OAuth tables (grouper_oauth_client,
grouper_oauth_code, grouper_oauth_pend_authz_req).
This supports load-balanced deployments where UI and WS run in separate containers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intclean up expired OAuth entries from the databasestatic Stringgenerate a unique IDstatic voidregisterClient(GrouperOAuthClient client) register a client in the database.static voidremove an authorization code from the database (after use)static voidremovePendingRequest(String requestId) remove a pending request from the databasestatic GrouperOAuthCoderetrieve an authorization code from the databasestatic GrouperOAuthClientretrieveClient(String clientId) retrieve a registered client from the database.static GrouperOAuthClientretrieveClientByInternalId(long internalId) retrieve a registered client from the database by internal id.static GrouperOAuthPendingRequestretrievePendingRequest(String requestId) retrieve a pending authorization request by request IDstatic voidstoreAuthorizationCode(GrouperOAuthCode authCode) store an authorization code in the databasestatic voidstorePendingRequest(GrouperOAuthPendingRequest pendingRequest) store a pending authorization request in the databasestatic StringvalidateRedirectUriAllowed(String redirectUri) Validate that a single redirect URI matches at least one configuredgrouper.oauth.redrectUri.<configId>.regexpattern.static StringvalidateRedirectUrisAllowed(Set<String> redirectUris) Validate that all redirect URIs in a set match at least one configuredgrouper.oauth.redrectUri.<configId>.regexpattern.
-
Constructor Details
-
GrouperOAuthStore
public GrouperOAuthStore()
-
-
Method Details
-
storePendingRequest
store a pending authorization request in the database- Parameters:
pendingRequest-
-
retrievePendingRequest
retrieve a pending authorization request by request ID- Parameters:
requestId-- Returns:
- the pending request or null if expired/not found
-
removePendingRequest
remove a pending request from the database- Parameters:
requestId-
-
storeAuthorizationCode
store an authorization code in the database- Parameters:
authCode-
-
retrieveAuthorizationCode
retrieve an authorization code from the database- Parameters:
code-- Returns:
- the auth code or null if expired/not found
-
removeAuthorizationCode
remove an authorization code from the database (after use)- Parameters:
code-
-
registerClient
register a client in the database. The client secret will be encrypted via Morph.encrypt() before storing.- Parameters:
client-
-
retrieveClient
retrieve a registered client from the database. The client secret will be decrypted via Morph.decrypt() after loading.- Parameters:
clientId-- Returns:
- the client or null if not found
-
retrieveClientByInternalId
retrieve a registered client from the database by internal id. The client secret will be decrypted via Morph.decrypt() after loading.- Parameters:
internalId-- Returns:
- the client or null if not found
-
validateRedirectUriAllowed
Validate that a single redirect URI matches at least one configuredgrouper.oauth.redrectUri.<configId>.regexpattern. If no regex patterns are configured, all redirect URIs are rejected (secure-by-default).- Parameters:
redirectUri- the redirect URI to validate- Returns:
- null if the URI is allowed, or a descriptive error message if not
-
validateRedirectUrisAllowed
Validate that all redirect URIs in a set match at least one configuredgrouper.oauth.redrectUri.<configId>.regexpattern.- Parameters:
redirectUris- the redirect URIs to validate- Returns:
- null if all URIs are allowed, or a descriptive error message for the first disallowed URI
-
generateId
generate a unique ID- Returns:
- uuid string
-
cleanupExpiredEntries
public static int cleanupExpiredEntries()clean up expired OAuth entries from the database- Returns:
- number of rows deleted
-