Class GrouperOAuthStore

java.lang.Object
edu.internet2.middleware.grouper.authentication.GrouperOAuthStore

public class GrouperOAuthStore extends Object
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 Details

    • GrouperOAuthStore

      public GrouperOAuthStore()
  • Method Details

    • storePendingRequest

      public static void storePendingRequest(GrouperOAuthPendingRequest pendingRequest)
      store a pending authorization request in the database
      Parameters:
      pendingRequest -
    • retrievePendingRequest

      public static GrouperOAuthPendingRequest retrievePendingRequest(String requestId)
      retrieve a pending authorization request by request ID
      Parameters:
      requestId -
      Returns:
      the pending request or null if expired/not found
    • removePendingRequest

      public static void removePendingRequest(String requestId)
      remove a pending request from the database
      Parameters:
      requestId -
    • storeAuthorizationCode

      public static void storeAuthorizationCode(GrouperOAuthCode authCode)
      store an authorization code in the database
      Parameters:
      authCode -
    • retrieveAuthorizationCode

      public static GrouperOAuthCode retrieveAuthorizationCode(String code)
      retrieve an authorization code from the database
      Parameters:
      code -
      Returns:
      the auth code or null if expired/not found
    • removeAuthorizationCode

      public static void removeAuthorizationCode(String code)
      remove an authorization code from the database (after use)
      Parameters:
      code -
    • registerClient

      public static void registerClient(GrouperOAuthClient client)
      register a client in the database. The client secret will be encrypted via Morph.encrypt() before storing.
      Parameters:
      client -
    • retrieveClient

      public static GrouperOAuthClient retrieveClient(String clientId)
      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

      public static GrouperOAuthClient retrieveClientByInternalId(long internalId)
      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

      public static String validateRedirectUriAllowed(String redirectUri)
      Validate that a single redirect URI matches at least one configured grouper.oauth.redrectUri.<configId>.regex pattern. 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

      public static String validateRedirectUrisAllowed(Set<String> redirectUris)
      Validate that all redirect URIs in a set match at least one configured grouper.oauth.redrectUri.<configId>.regex pattern.
      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

      public static String 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