java.lang.Object
io.helidon.security.jwt.SignedJwt
The JWT used to transfer content across network - e.g. the base64 parts concatenated
 with a dot.
- 
Method SummaryModifier and TypeMethodDescriptiongetJwt()Return a Jwt instance from this signed JWT.byte[]Signature bytes.byte[]The bytes that were signed (payload bytes).static SignedJwtparseToken(JwtHeaders headers, String tokenContent) Parse a token received over network.static SignedJwtparseToken(String tokenContent) Parse a token received over network.static SignedJwtSign a jwt using an explicit jwk.static SignedJwtSign a jwt using a key obtained based on kid fromJwkKeys.The full token (header, payload, signature).verifySignature(JwkKeys keys) Verify signature against the provided keys (the kid of this JWT should be present in theJwkKeysprovided).verifySignature(JwkKeys keys, Jwk defaultJwk) Verify signature against the provided keys (the kid of thisPrincipal JWT should be present in theJwkKeysprovided).
- 
Method Details- 
signSign a jwt using a key obtained based on kid fromJwkKeys. In case the kid is not provided and alg is none,Jwk.ALG_NONEis used - e.g. no signature is generated.- Parameters:
- jwt- jwt to sign
- jwks- keys to find the correct key to sign
- Returns:
- a new instance of this class with signature
- Throws:
- JwtException- in case the algorithm is missing, the algorithms of JWK and JWT do not match, or in case of other mis-matches
 
- 
signSign a jwt using an explicit jwk.- Parameters:
- jwt- jwt to sign
- jwk- key used to sign the JWT
- Returns:
- a new instance of this class with signature
- Throws:
- JwtException- in case the algorithm is missing, the algorithms of JWK and JWT do not match, or in case of other mis-matches
 
- 
parseTokenParse a token received over network. The expected content isheader_base64.payload_base64.signature_base64where base64 is base64 URL encoding. Use this method if you have previous knowledge that this is a signed JWT, otherwise useparseToken(JwtHeaders, String). This method does NO validation of content at all, only validates that the content is correctly formatted:- correct format of string (e.g. base64.base64.base64)
- each base64 part is actually base64 URL encoded
- header and payload are JSON objects
 - Parameters:
- tokenContent- String with the token
- Returns:
- a signed JWT instance that can be used to obtain the instanceand toverifySignature(JwkKeys)verify} the signature
- Throws:
- RuntimeException- in case of invalid content, see- Errors.ErrorMessagesException
 
- 
parseTokenParse a token received over network. The expected content isheader_base64.payload_base64.signature_base64where base64 is base64 URL encoding. This method does NO validation of content at all, only validates that the content is correctly formatted:- correct format of string (e.g. base64.base64.base64)
- each base64 part is actually base64 URL encoded
- header and payload are JSON objects
 - Parameters:
- headers- headers parsed previously (probably to decide whether to use this or- EncryptedJwt)
- tokenContent- String with the token
- Returns:
- a signed JWT instance that can be used to obtain the instanceand toverifySignature(JwkKeys)verify} the signature
- Throws:
- RuntimeException- in case of invalid content, see- Errors.ErrorMessagesException
 
- 
tokenContentThe full token (header, payload, signature).- Returns:
- token content
 
- 
getSignedBytespublic byte[] getSignedBytes()The bytes that were signed (payload bytes).- Returns:
- signed bytes
 
- 
getSignaturepublic byte[] getSignature()Signature bytes.- Returns:
- bytes of the signature
 
- 
getJwtReturn a Jwt instance from this signed JWT.- Returns:
- Jwt instance
- Throws:
- RuntimeException- in case one of the fields has invalid content (e.g. timestamp is invalid)
 
- 
verifySignatureVerify signature against the provided keys (the kid of this JWT should be present in theJwkKeysprovided).- Parameters:
- keys- JwkKeys to obtain a key to verify signature
- Returns:
- Errors with collected messages, see Errors.isValid()andErrors.checkValid()
 
- 
verifySignatureVerify signature against the provided keys (the kid of thisPrincipal JWT should be present in theJwkKeysprovided).- Parameters:
- keys- JwkKeys to obtain a key to verify signature
- defaultJwk- Default value of JWK
- Returns:
- Errors with collected messages, see Errors.isValid()andErrors.checkValid()
 
 
-