Class GrouperOAuthSigningKey
java.lang.Object
edu.internet2.middleware.grouper.authentication.GrouperOAuthSigningKey
Manages the server RSA key pair for signing and verifying OAuth JWT access tokens.
Key pair is stored in grouper.properties (database-backed config).
The private key is auto-encrypted by the config framework because the key name
contains "private" (see GrouperConfigHibernate.isPasswordHelper()).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateSignedJwt(String issuer, String subjectId, String subjectSourceId, String clientId, String consentDetails) Create a signed JWT access tokenstatic RSAPublicKeyGet the public key (for JWKS endpoint, etc.)static voidforce re-read of keys from config on next accessstatic com.auth0.jwt.interfaces.DecodedJWTverifyAndDecodeJwt(String jwt) Verify and decode a JWT access tokenstatic booleanVerify that the public and private keys in config form a valid pair by signing and verifying a test JWT.
-
Constructor Details
-
GrouperOAuthSigningKey
public GrouperOAuthSigningKey()
-
-
Method Details
-
getPublicKey
Get the public key (for JWKS endpoint, etc.)- Returns:
- the RSA public key
-
initializeIfNeeded
public static void initializeIfNeeded()force re-read of keys from config on next access -
createSignedJwt
public static String createSignedJwt(String issuer, String subjectId, String subjectSourceId, String clientId, String consentDetails) Create a signed JWT access token- Parameters:
issuer- the issuer URLsubjectId- the Grouper subject IDsubjectSourceId- the Grouper subject source IDclientId- the OAuth client IDconsentDetails- JSON string with granted scopes from consent, or null- Returns:
- the signed JWT string
-
verifyKeyPair
public static boolean verifyKeyPair()Verify that the public and private keys in config form a valid pair by signing and verifying a test JWT. Call from GSH to diagnose MCP authentication issues. Prints results to stdout for easy use in GSH.- Returns:
- true if the keys match
-
verifyAndDecodeJwt
Verify and decode a JWT access token- Parameters:
jwt- the JWT string- Returns:
- the decoded JWT, or null if invalid
-