Class JwtSvid
java.lang.Object
io.spiffe.svid.jwtsvid.JwtSvid
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the Set of audiences.Returns the map of claims.Returns a copy of the expiration date time of the JWT SVID.getHint()Returns the SVID hint.marshal()Returns the JWT-SVID marshaled to a string.static JwtSvidparseAndValidate(@NonNull String token, @NonNull BundleSource<JwtBundle> jwtBundleSource, @NonNull Set<String> audience) Parses and validates a JWT-SVID token and returns an instance ofJwtSvid.static JwtSvidparseAndValidate(@NonNull String token, @NonNull BundleSource<JwtBundle> jwtBundleSource, @NonNull Set<String> audience, String hint) Parses and validates a JWT-SVID token and returns an instance ofJwtSvid.static JwtSvidparseInsecure(@NonNull String token, @NonNull Set<String> audience) Parses and validates a JWT-SVID token and returns an instance of aJwtSvid.static JwtSvidparseInsecure(@NonNull String token, @NonNull Set<String> audience, String hint) Parses and validates a JWT-SVID token and returns an instance of aJwtSvid.
-
Field Details
-
HEADER_TYP_JWT
- See Also:
-
HEADER_TYP_JOSE
- See Also:
-
-
Method Details
-
parseAndValidate
public static JwtSvid parseAndValidate(@NonNull @NonNull String token, @NonNull @NonNull BundleSource<JwtBundle> jwtBundleSource, @NonNull @NonNull Set<String> audience) throws JwtSvidException, BundleNotFoundException, AuthorityNotFoundException Parses and validates a JWT-SVID token and returns an instance ofJwtSvid.The JWT-SVID signature is verified using the JWT bundle source.
- Parameters:
token- a token as a string that is parsed and validatedjwtBundleSource- an implementation of aBundleSourcethat provides the JWT authorities to verify the signatureaudience- audience as a list of strings used to validate the 'aud' claim- Returns:
- an instance of a
JwtSvidwith a SPIFFE ID parsed from the 'sub', audience from 'aud', and expiry from 'exp' claim. - Throws:
JwtSvidException- when the token expired or the expiration claim is missing, when the algorithm is not supported (SeeJwtSignatureAlgorithm), when the header 'kid' is missing, when the header 'typ' is present and is not 'JWT' or 'JOSE' when the signature cannot be verified, when the 'aud' claim has an audience that is not in the audience list provided as parameterIllegalArgumentException- when the token is blank or cannot be parsedBundleNotFoundException- if the bundle for the trust domain of the spiffe id from the 'sub' cannot be found in the JwtBundleSourceAuthorityNotFoundException- if the authority cannot be found in the bundle using the value from the 'kid' header
-
parseAndValidate
public static JwtSvid parseAndValidate(@NonNull @NonNull String token, @NonNull @NonNull BundleSource<JwtBundle> jwtBundleSource, @NonNull @NonNull Set<String> audience, String hint) throws JwtSvidException, BundleNotFoundException, AuthorityNotFoundException Parses and validates a JWT-SVID token and returns an instance ofJwtSvid.The JWT-SVID signature is verified using the JWT bundle source.
- Parameters:
token- a token as a string that is parsed and validatedjwtBundleSource- an implementation of aBundleSourcethat provides the JWT authorities to verify the signatureaudience- audience as a list of strings used to validate the 'aud' claimhint- a hint that can be used to provide guidance on how this identity should be used- Returns:
- an instance of a
JwtSvidwith a SPIFFE ID parsed from the 'sub', audience from 'aud', and expiry from 'exp' claim. - Throws:
JwtSvidException- when the token expired or the expiration claim is missing, when the algorithm is not supported (SeeJwtSignatureAlgorithm), when the header 'kid' is missing, when the header 'typ' is present and is not 'JWT' or 'JOSE' when the signature cannot be verified, when the 'aud' claim has an audience that is not in the audience list provided as parameterIllegalArgumentException- when the token is blank or cannot be parsedBundleNotFoundException- if the bundle for the trust domain of the spiffe id from the 'sub' cannot be found in the JwtBundleSourceAuthorityNotFoundException- if the authority cannot be found in the bundle using the value from the 'kid' header
-
parseInsecure
public static JwtSvid parseInsecure(@NonNull @NonNull String token, @NonNull @NonNull Set<String> audience) throws JwtSvidException Parses and validates a JWT-SVID token and returns an instance of aJwtSvid.The JWT-SVID signature is not verified.
- Parameters:
token- a token as a string that is parsed and validatedaudience- audience as a list of strings used to validate the 'aud' claim- Returns:
- an instance of a
JwtSvidwith a SPIFFE ID parsed from the 'sub', audience from 'aud', and expiry from 'exp' claim. - Throws:
JwtSvidException- when the token expired or the expiration claim is missing, when the 'aud' has an audience that is not in the audience provided as parameter, when the 'alg' is not supported (SeeJwtSignatureAlgorithm), when the header 'typ' is present and is not 'JWT' or 'JOSE'.IllegalArgumentException- when the token cannot be parsed
-
parseInsecure
public static JwtSvid parseInsecure(@NonNull @NonNull String token, @NonNull @NonNull Set<String> audience, String hint) throws JwtSvidException Parses and validates a JWT-SVID token and returns an instance of aJwtSvid.The JWT-SVID signature is not verified.
- Parameters:
token- a token as a string that is parsed and validatedaudience- audience as a list of strings used to validate the 'aud'hint- a hint that can be used to provide guidance on how this identity should be used- Returns:
- an instance of a
JwtSvidwith a SPIFFE ID parsed from the 'sub', audience from 'aud', and expiry from 'exp' claim. - Throws:
JwtSvidException- when the token expired or the expiration claim is missing, when the 'aud' has an audience that is not in the audience provided as parameter, when the 'alg' is not supported (SeeJwtSignatureAlgorithm), when the header 'typ' is present and is not 'JWT' or 'JOSE'.IllegalArgumentException- when the token cannot be parsed
-
marshal
Returns the JWT-SVID marshaled to a string. The returned value is the same token value originally passed to the parseAndValidate method.- Returns:
- the token as String
-
getExpiry
Returns a copy of the expiration date time of the JWT SVID.- Returns:
- a copy of the expiration date time of the JWT SVID
-
getHint
-
getClaims
-
getAudience
-