Package com.networknt.security
Class JwtHelper
- java.lang.Object
-
- com.networknt.security.JwtHelper
-
@Deprecated public class JwtHelper extends Object
Deprecated.JWT token helper utility that use by different framework to verify JWT tokens.- Author:
- Steve Hu
-
-
Field Summary
Fields Modifier and Type Field Description static StringENABLE_VERIFY_JWTDeprecated.static StringJWT_CERTIFICATEDeprecated.static StringJWT_CLOCK_SKEW_IN_SECONDSDeprecated.static StringJWT_CONFIGDeprecated.static StringJWT_KEY_RESOLVERDeprecated.static StringJWT_KEY_RESOLVER_JWKSDeprecated.static StringJWT_KEY_RESOLVER_X509CERTDeprecated.static StringKIDDeprecated.static StringSECURITY_CONFIGDeprecated.
-
Constructor Summary
Constructors Constructor Description JwtHelper()Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static X509CertificategetCertForSign(String kid)Deprecated.static X509CertificategetCertForToken(String kid)Deprecated.static ListgetFingerPrints()Deprecated.Get a list of certificate fingerprints for server info endpoint so that certification process in light-portal can detect if your service still use the default public key certificates provided by the light-4j framework.static StringgetJwtFromAuthorization(String authorization)Deprecated.Parse the jwt token from Authorization header.static X509CertificatereadCertificate(String filename)Deprecated.Read certificate from a file and convert it into X509Certificate objectstatic org.jose4j.jwt.JwtClaimsverifyJwt(String jwt, boolean ignoreExpiry)Deprecated.Use verifyToken instead.static org.jose4j.jwt.JwtClaimsverifyJwt(String jwt, boolean ignoreExpiry, boolean isToken)Deprecated.This method is to keep backward compatible for those call without VerificationKeyResolver.static org.jose4j.jwt.JwtClaimsverifyJwt(String jwt, boolean ignoreExpiry, boolean isToken, BiFunction<String,Boolean,org.jose4j.keys.resolvers.VerificationKeyResolver> getKeyResolver)Deprecated.Verify JWT token format and signature.
-
-
-
Field Detail
-
KID
public static final String KID
Deprecated.- See Also:
- Constant Field Values
-
JWT_CONFIG
public static final String JWT_CONFIG
Deprecated.- See Also:
- Constant Field Values
-
SECURITY_CONFIG
public static final String SECURITY_CONFIG
Deprecated.- See Also:
- Constant Field Values
-
JWT_CERTIFICATE
public static final String JWT_CERTIFICATE
Deprecated.- See Also:
- Constant Field Values
-
JWT_CLOCK_SKEW_IN_SECONDS
public static final String JWT_CLOCK_SKEW_IN_SECONDS
Deprecated.- See Also:
- Constant Field Values
-
ENABLE_VERIFY_JWT
public static final String ENABLE_VERIFY_JWT
Deprecated.- See Also:
- Constant Field Values
-
JWT_KEY_RESOLVER
public static final String JWT_KEY_RESOLVER
Deprecated.- See Also:
- Constant Field Values
-
JWT_KEY_RESOLVER_X509CERT
public static final String JWT_KEY_RESOLVER_X509CERT
Deprecated.- See Also:
- Constant Field Values
-
JWT_KEY_RESOLVER_JWKS
public static final String JWT_KEY_RESOLVER_JWKS
Deprecated.- See Also:
- Constant Field Values
-
-
Method Detail
-
readCertificate
public static X509Certificate readCertificate(String filename) throws Exception
Deprecated.Read certificate from a file and convert it into X509Certificate object- Parameters:
filename- certificate file name- Returns:
- X509Certificate object
- Throws:
Exception- Exception while reading certificate
-
getJwtFromAuthorization
public static String getJwtFromAuthorization(String authorization)
Deprecated.Parse the jwt token from Authorization header.- Parameters:
authorization- authorization header.- Returns:
- JWT token
-
verifyJwt
@Deprecated public static org.jose4j.jwt.JwtClaims verifyJwt(String jwt, boolean ignoreExpiry) throws org.jose4j.jwt.consumer.InvalidJwtException, ExpiredTokenException
Deprecated.Use verifyToken instead.Verify JWT token format and signature. If ignoreExpiry is true, skip expiry verification, otherwise verify the expiry before signature verification. In most cases, we need to verify the expiry of the jwt token. The only time we need to ignore expiry verification is in SPA middleware handlers which need to verify csrf token in jwt against the csrf token in the request header to renew the expired token.- Parameters:
jwt- String of Json web tokenignoreExpiry- If true, don't verify if the token is expired.- Returns:
- JwtClaims object
- Throws:
org.jose4j.jwt.consumer.InvalidJwtException- InvalidJwtExceptionExpiredTokenException- ExpiredTokenException
-
verifyJwt
public static org.jose4j.jwt.JwtClaims verifyJwt(String jwt, boolean ignoreExpiry, boolean isToken) throws org.jose4j.jwt.consumer.InvalidJwtException, ExpiredTokenException
Deprecated.This method is to keep backward compatible for those call without VerificationKeyResolver.- Parameters:
jwt- JWT tokenignoreExpiry- indicate if the expiry will be ignoredisToken- indicate if the JWT is a token- Returns:
- JwtClaims
- Throws:
org.jose4j.jwt.consumer.InvalidJwtException- throw when the token is invalidExpiredTokenException- throw when the token is expired
-
verifyJwt
public static org.jose4j.jwt.JwtClaims verifyJwt(String jwt, boolean ignoreExpiry, boolean isToken, BiFunction<String,Boolean,org.jose4j.keys.resolvers.VerificationKeyResolver> getKeyResolver) throws org.jose4j.jwt.consumer.InvalidJwtException, ExpiredTokenException
Deprecated.Verify JWT token format and signature. If ignoreExpiry is true, skip expiry verification, otherwise verify the expiry before signature verification. In most cases, we need to verify the expiry of the jwt token. The only time we need to ignore expiry verification is in SPA middleware handlers which need to verify csrf token in jwt against the csrf token in the request header to renew the expired token.- Parameters:
jwt- String of Json web tokenignoreExpiry- If true, don't verify if the token is expired.isToken- True if the jwt is an OAuth 2.0 access tokengetKeyResolver- How to get VerificationKeyResolver- Returns:
- JwtClaims object
- Throws:
org.jose4j.jwt.consumer.InvalidJwtException- InvalidJwtExceptionExpiredTokenException- ExpiredTokenException
-
getCertForToken
public static X509Certificate getCertForToken(String kid)
Deprecated.
-
getCertForSign
public static X509Certificate getCertForSign(String kid)
Deprecated.
-
getFingerPrints
public static List getFingerPrints()
Deprecated.Get a list of certificate fingerprints for server info endpoint so that certification process in light-portal can detect if your service still use the default public key certificates provided by the light-4j framework. The default public key certificates are for dev only and should be replaced on any other environment or set bootstrapFromKeyService: true if you are using light-oauth2 so that key can be dynamically loaded.- Returns:
- List of certificate fingerprints
-
-