public class SignedJwt
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
Jwt |
getJwt()
Return a Jwt instance from this signed JWT.
|
byte[] |
getSignature() |
byte[] |
getSignedBytes() |
java.lang.String |
getTokenContent() |
static SignedJwt |
parseToken(java.lang.String tokenContent)
Parse a token received over network.
|
static SignedJwt |
sign(Jwt jwt,
Jwk jwk)
Sign a jwt using an explicit jwk.
|
static SignedJwt |
sign(Jwt jwt,
JwkKeys jwks)
Sign a jwt using a key obtained based on kid from
JwkKeys. |
Errors |
verifySignature(JwkKeys keys)
Verify signature against the provided keys (the kid of this
JWT should be present in the
JwkKeys provided). |
public static SignedJwt sign(Jwt jwt, JwkKeys jwks) throws JwtException
JwkKeys.
In case the kid is not provided and alg is none, Jwk.ALG_NONE
is used - e.g. no signature is generated.jwt - jwt to signjwks - keys to find the correct key to signJwtException - in case the algorithm is missing,
the algorithms of JWK and JWT do not match, or in case of other mis-matchespublic static SignedJwt sign(Jwt jwt, Jwk jwk) throws JwtException
jwt - jwt to signjwk - key used to sign the JWTJwtException - in case the algorithm is missing,
the algorithms of JWK and JWT do not match, or in case of other mis-matchespublic static SignedJwt parseToken(java.lang.String tokenContent)
header_base64.payload_base64.signature_base64 where base64 is
base64 URL encoding.
This method does NO validation of content at all, only validates that
the content is correctly formatted:
tokenContent - String with the tokeninstance
and to verifySignature(JwkKeys) verify} the signaturejava.lang.RuntimeException - in case of invalid content, see Errors.ErrorMessagesExceptionpublic java.lang.String getTokenContent()
public byte[] getSignedBytes()
public byte[] getSignature()
public Jwt getJwt()
java.lang.RuntimeException - in case one of the fields has invalid content (e.g. timestamp is invalid)public Errors verifySignature(JwkKeys keys)
JwkKeys provided).keys - JwkKeys to obtain a key to verify signatureErrors.isValid() and Errors.checkValid()Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.