public class TokenMgtUtil extends Object
| Constructor and Description |
|---|
TokenMgtUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addTokenToCache(String accessTokenIdentifier,
org.wso2.carbon.identity.oauth2.model.AccessTokenDO accessTokenDO)
Adds an access token and its associated information to the OAuth cache for efficient retrieval.
|
static org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser |
createFederatedAuthenticatedUser(String userId)
Create an authenticated user object for the given user ID from usersession store.
|
static org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser |
getAuthenticatedUser(com.nimbusds.jwt.JWTClaimsSet claimsSet)
Get authenticated user.
|
static Optional<org.wso2.carbon.identity.oauth.dao.OAuthAppDO> |
getOAuthApp(String clientId)
Get the OAuthAppDO for the provided client id.
|
static org.wso2.carbon.identity.oauth.cache.OAuthCacheKey |
getOAuthCacheKey(String accessTokenIdentifier)
Get OAuth cache key for access token identifier.
|
static String[] |
getScopes(Object scopes)
Get Scope array from the scopes string object.
|
static String |
getSigningTenantDomain(com.nimbusds.jwt.JWTClaimsSet claimsSet,
org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser authenticatedUser)
Retrieves the signing tenant domain from the given JWT claims set and AccessTokenDO, considering various sources
such as the 'realm' claim, the 'signing_tenant' claim, and the OAuth application associated with the AccessToken.
|
static String |
getTenantDomain()
Get tenant domain from thread local carbon context.
|
static Optional<org.wso2.carbon.identity.oauth2.model.AccessTokenDO> |
getTokenDOFromCache(String accessTokenIdentifier)
Get AccessTokenDO from cache.
|
static String |
getTokenId(com.nimbusds.jwt.JWTClaimsSet claimsSet)
Get token id from the JWT token.
|
static String |
getTokenIdentifier(com.nimbusds.jwt.JWTClaimsSet claimsSet)
Get token identifier (JTI) for JWT.
|
static com.nimbusds.jwt.JWTClaimsSet |
getTokenJWTClaims(com.nimbusds.jwt.SignedJWT signedJWT)
Get JWT Claim sets for the given access token.
|
static boolean |
isRefreshTokenType(com.nimbusds.jwt.JWTClaimsSet claimsSet)
Check if provided JWT token is a refresh token or not.
|
static boolean |
isTokenRevokedDirectly(String tokenIdentifier,
String consumerKey)
Check if token is directly revoked by calling revoked token endpoint.
|
static boolean |
isTokenRevokedIndirectly(com.nimbusds.jwt.JWTClaimsSet claimsSet,
org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser authenticatedUser)
Check if token is in-directly revoked through a user related or client application related change action.
|
static boolean |
isTokenRevokedIndirectlyFromApp(String consumerKey,
Date tokenIssuedTime)
Check if a token is in-directly revoked through a client application related change action.
|
static com.nimbusds.jwt.SignedJWT |
parseJWT(String accessToken)
Parse JWT Token.
|
static void |
validateJWTSignature(com.nimbusds.jwt.SignedJWT signedJWT,
com.nimbusds.jwt.JWTClaimsSet claimsSet,
org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser authenticatedUser)
Validate the JWT signature.
|
public static String getTokenIdentifier(com.nimbusds.jwt.JWTClaimsSet claimsSet) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
claimsSet - Claim Setorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - if JTI claim is not present in the JWTClaimSet of the access token.public static com.nimbusds.jwt.SignedJWT parseJWT(String accessToken) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
accessToken - Access Tokenorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If an error occurs while parsing the JWT tokenpublic static com.nimbusds.jwt.JWTClaimsSet getTokenJWTClaims(com.nimbusds.jwt.SignedJWT signedJWT)
throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
signedJWT - Signed JWTorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If an error occurs while getting the JWT claim setspublic static void validateJWTSignature(com.nimbusds.jwt.SignedJWT signedJWT,
com.nimbusds.jwt.JWTClaimsSet claimsSet,
org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser authenticatedUser)
throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
signedJWT - Signed JWTclaimsSet - JWT claims setauthenticatedUser - Authenticated userorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If signature verification fails or if an error occurs while
validating the JWT signature.public static String[] getScopes(Object scopes)
scopes - String object of scopes with delimiter space.public static org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser getAuthenticatedUser(com.nimbusds.jwt.JWTClaimsSet claimsSet)
throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
claimsSet - JWT claims setorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exceptionpublic static String getTenantDomain()
public static boolean isTokenRevokedIndirectly(com.nimbusds.jwt.JWTClaimsSet claimsSet,
org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser authenticatedUser)
throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
claimsSet - JWTClaimsSet of the parsed token.authenticatedUser - Authenticated Userorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If failed to check is token is in-directly revoked.public static boolean isTokenRevokedIndirectlyFromApp(String consumerKey, Date tokenIssuedTime) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
consumerKey - Consumer KeytokenIssuedTime - Token Issued Timeorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If failed to check is token is in-directly revoked.public static boolean isTokenRevokedDirectly(String tokenIdentifier, String consumerKey) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
tokenIdentifier - Token IdentifierconsumerKey - Consumer Keyorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If failed to check is token is directly revokedpublic static Optional<org.wso2.carbon.identity.oauth2.model.AccessTokenDO> getTokenDOFromCache(String accessTokenIdentifier)
accessTokenIdentifier - Identifierpublic static void addTokenToCache(String accessTokenIdentifier, org.wso2.carbon.identity.oauth2.model.AccessTokenDO accessTokenDO)
accessTokenIdentifier - The identifier of the access token to be cached.accessTokenDO - The AccessTokenDO (Access Token Data Object) containing information about the
access token.public static org.wso2.carbon.identity.oauth.cache.OAuthCacheKey getOAuthCacheKey(String accessTokenIdentifier)
accessTokenIdentifier - Access token IDpublic static boolean isRefreshTokenType(com.nimbusds.jwt.JWTClaimsSet claimsSet)
throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
claimsSet - JWTClaimsSet of the parsed token.org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If the token type is invalid.public static Optional<org.wso2.carbon.identity.oauth.dao.OAuthAppDO> getOAuthApp(String clientId) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
clientId - Client Idorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - Error while retrieving the OAuthAppDO.public static org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser createFederatedAuthenticatedUser(String userId) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
userId - User IDorg.wso2.carbon.identity.oauth2.IdentityOAuth2Exceptionpublic static String getTokenId(com.nimbusds.jwt.JWTClaimsSet claimsSet) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
claimsSet - JWTClaimsSet of the parsed token.org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If failed to get the token id.public static String getSigningTenantDomain(com.nimbusds.jwt.JWTClaimsSet claimsSet, org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser authenticatedUser) throws org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception
claimsSet - The JWTClaimsSet containing the claims of the JWT, including the 'realm' claim.authenticatedUser - Authenticated user.org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception - If an error occurs in OAuth2-related functionality.Copyright © 2024 WSO2. All rights reserved.