public class ModelUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ModelUtils.GcubeJacksonDeserializer |
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
ModelUtils() |
| Modifier and Type | Method and Description |
|---|---|
static PublicKey |
createPublicKey(String publicKeyPem,
String algorithm)
Creates a
PublicKey instance from its string PEM representation |
static RSAPublicKey |
createRSAPublicKey(String publicKeyPem)
Creates a
RSAPublicKey instance from its string PEM representation |
static AccessToken |
getAccessTokenFrom(String authorizationHeaderOrBase64EncodedJWT) |
static AccessToken |
getAccessTokenFrom(TokenResponse tokenResponse) |
static String |
getAccessTokenPayloadJSONStringFrom(TokenResponse tokenResponse) |
static String |
getAccessTokenPayloadJSONStringFrom(TokenResponse tokenResponse,
boolean prettyPrint) |
protected static byte[] |
getBase64Decoded(String string) |
static String |
getClientIdFromToken(AccessToken accessToken) |
static byte[] |
getDecodedHeader(String value) |
static byte[] |
getDecodedPayload(String value) |
static byte[] |
getDecodedSignature(String value) |
static String |
getEncodedHeader(String encodedJWT) |
static String |
getEncodedPayload(String encodedJWT) |
static String |
getEncodedSignature(String encodedJWT) |
static RefreshToken |
getRefreshTokenFrom(String base64EncodedJWT) |
static RefreshToken |
getRefreshTokenFrom(TokenResponse tokenResponse) |
static String |
getRefreshTokenPayloadStringFrom(TokenResponse tokenResponse) |
static String |
getRefreshTokenPayloadStringFrom(TokenResponse tokenResponse,
boolean prettyPrint) |
static boolean |
isValid(String token,
PublicKey publicKey)
Verifies the token validity
|
static boolean |
isValid(String token,
PublicKey publicKey,
boolean checkExpiration)
Verifies the token validity
|
protected static String |
splitAndGet(String encodedJWT,
int index) |
static String |
toJSONString(Object object) |
static String |
toJSONString(Object object,
boolean prettyPrint) |
static void |
verify(String token,
PublicKey publicKey)
Verifies the token signature and expiration
|
public static RSAPublicKey createRSAPublicKey(String publicKeyPem) throws Exception
RSAPublicKey instance from its string PEM representationpublicKeyPem - the public key PEM stringException - if it's not possible to create the RSA public key from the
PEM stringpublic static PublicKey createPublicKey(String publicKeyPem, String algorithm) throws Exception
PublicKey instance from its string PEM representationpublicKeyPem - the public key PEM stringalgorithm - the key type (e.g. RSA)Exception - if it's not possible to create the public key from the PEM
stringpublic static boolean isValid(String token, PublicKey publicKey) throws Exception
token - the base64 JWT token stringpublicKey - the realm's public key on servertrue if the token is valid, false otherwiseException - if an error occurs constructing the verifierpublic static boolean isValid(String token, PublicKey publicKey, boolean checkExpiration) throws Exception
token - the base64 JWT token stringpublicKey - the public key to use for verificationcheckExpiration - if false token expiration check is
disabledtrue if the token is valid, false otherwiseException - if an unexpected error occurs (e.g. constructing the
verifier)public static void verify(String token, PublicKey publicKey) throws org.gcube.io.jsonwebtoken.security.SignatureException, org.gcube.io.jsonwebtoken.ExpiredJwtException, org.gcube.io.jsonwebtoken.JwtException, Exception
token - the base64 JWT token stringpublicKey - the public key to use for verificationorg.gcube.io.jsonwebtoken.security.SignatureException - if the token signature is invalidorg.gcube.io.jsonwebtoken.ExpiredJwtException - if the token is expiredorg.gcube.io.jsonwebtoken.JwtException - if a JWT related problem is foundException - if an unexpected error occurs (e.g. constructing
the verifier)public static String getAccessTokenPayloadJSONStringFrom(TokenResponse tokenResponse) throws Exception
Exceptionpublic static String getAccessTokenPayloadJSONStringFrom(TokenResponse tokenResponse, boolean prettyPrint) throws Exception
Exceptionpublic static AccessToken getAccessTokenFrom(TokenResponse tokenResponse) throws Exception
Exceptionpublic static AccessToken getAccessTokenFrom(String authorizationHeaderOrBase64EncodedJWT) throws Exception
Exceptionpublic static String getRefreshTokenPayloadStringFrom(TokenResponse tokenResponse) throws Exception
Exceptionpublic static String getRefreshTokenPayloadStringFrom(TokenResponse tokenResponse, boolean prettyPrint) throws Exception
Exceptionpublic static RefreshToken getRefreshTokenFrom(TokenResponse tokenResponse) throws Exception
Exceptionpublic static RefreshToken getRefreshTokenFrom(String base64EncodedJWT) throws Exception
Exceptionprotected static byte[] getBase64Decoded(String string)
public static byte[] getDecodedHeader(String value)
public static byte[] getDecodedPayload(String value)
public static byte[] getDecodedSignature(String value)
public static String getClientIdFromToken(AccessToken accessToken)
Copyright © 2026. All rights reserved.