Class AbstractJOSEHeader<A extends AbstractJOSEHeader<A>>
- Type Parameters:
A- the JOSE header type
- All Implemented Interfaces:
JOSEHeader,JOSEHeaderConfigurator<A>
- Direct Known Subclasses:
GenericJWEHeader,GenericJWSHeader
Base JOSE Header implementation.
It processes the following parameters: alg, jku, jwk, kid, x5u, x5c, x5t, x5t#S256, typ, cty, crit
- Since:
- 1.5
- Author:
- Jeremy Kuhn
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe algorithm parameter as defined by RFC7515 Section 4.1.1 and RFC7516 Section 4.1.1.The Critical parameter as defined by RFC7515 Section 4.1.11 and RFC7516 Section 4.1.13.protected StringThe Content Type parameter as defined by RFC7515 Section 4.1.10 and RFC7516 Section 4.1.12.The custom parameters as defined by RFC7515 Section 4.2 and RFC7516 Section 4.2.protected StringThe JOSE header encoded as Base64URL without paddingprotected URIThe JWK Set URL parameter as defined by RFC7515 Section 4.1.2 and RFC7516 Section 4.1.4.The JWK parameter as defined by RFC7515 Section 4.1.3 and RFC7516 Section 4.1.5.protected JWKThe key that was used to secure the JOSE object.protected StringThe Key id parameter as defined by RFC7515 Section 4.1.4 and RFC7516 Section 4.1.6.The set of parameters processed in the JOSE header.protected StringThe Type parameter as defined by RFC7515 Section 4.1.9 and RFC7516 Section 4.1.11.protected String[]The X.509 Certificate Chain parameter as defined by RFC7515 Section 4.1.6 and RFC7516 Section 4.1.8.protected StringThe X.509 Certificate SHA-1 Thumbprint parameter as defined by RFC7515 Section 4.1.7 and RFC7516 Section 4.1.9.protected StringThe X.509 Certificate SHA-256 Thumbprint parameter as defined by RFC7515 Section 4.1.8 and RFC7516 Section 4.1.10.protected URIThe X.509 URL parameter as defined by RFC7515 Section 4.1.5 and RFC7516 Section 4.1.7. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a JOSE header.AbstractJOSEHeader(String alg) Creates a JOSE header with the specified algorithm. -
Method Summary
Modifier and TypeMethodDescriptionaddCustomParameter(String key, Object value) Specifies a custom parameter to add to the header.specifies the cryptographic algorithm to use to secure the JOSE object.contentType(String cty) Specifies the media type of the JOSE object payload.Specifies the set of custom parameters that must be understood and processed.booleanReturns the cryptographic algorithm used to secure the JOSE object.Returns the media type of the JOSE object payload.Returns the set of custom parameters that must be understood and processed.Returns the map of custom parameters.Returns the header encoded as Base64URL.getJWK()Returns the public JWK that corresponds to the key used to secure the JOSE object.Returns the JWK Set URL.getKey()Returns the actual key that was used to secure the JOSE object.getKeyId()Returns the id of the key that was used to secure the JOSE object.Returns the parameters processed by the JOSE header.getType()Returns the media type of the complete JOSE object.String[]Returns the X.509 certificates chain that corresponds to the key that was used to secure the JOSE object.Returns the X.509 SHA1 thumbprint of the certificate that corresponds to the key that was used to secure the JOSE object.Returns the X.509 SHA256 thumbprint of the certificate that corresponds to the key that was used to secure the JOSE object.Returns the URL of the X.509 certificate or certificates chain that corresponds to the key that was used to secure the JOSE object.inthashCode()Specifies the JWK to use to secure the JOSE object.Specifies the JWK Set URL that contains the key to use to secure the JOSE object.Specifies the id of the key to use to secure the JOSE object.voidsetEncoded(String encoded) Sets the encoded header as Base64URL.voidSets the actual key that was used to secure the JOSE object.Specifies the media type of the complete JOSE object.x509CertificateChain(String[] x5c) Specifies the X.509 certificates chain that corresponds to the key to use to secure the JOSE object.Specifies the X.509 SHA1 thumbprint of the certificate that corresponds to the key to use to secure the JOSE object.x509CertificateSHA256Thumbprint(String x5t_S256) Specifies the X.509 SHA256 thumbprint of the certificate that corresponds to the key to use to secure the JOSE object.x509CertificateURL(URI x5u) Specifies the URL of the X.509 certificate or certificates chain that corresponds to the key to use to secure the JOSE object.
-
Field Details
-
PROCESSED_PARAMETERS
The set of parameters processed in the JOSE header. -
alg
The algorithm parameter as defined by RFC7515 Section 4.1.1 and RFC7516 Section 4.1.1. -
jku
The JWK Set URL parameter as defined by RFC7515 Section 4.1.2 and RFC7516 Section 4.1.4. -
jwk
The JWK parameter as defined by RFC7515 Section 4.1.3 and RFC7516 Section 4.1.5. -
kid
The Key id parameter as defined by RFC7515 Section 4.1.4 and RFC7516 Section 4.1.6. -
x5u
The X.509 URL parameter as defined by RFC7515 Section 4.1.5 and RFC7516 Section 4.1.7. -
x5c
The X.509 Certificate Chain parameter as defined by RFC7515 Section 4.1.6 and RFC7516 Section 4.1.8. -
x5t
The X.509 Certificate SHA-1 Thumbprint parameter as defined by RFC7515 Section 4.1.7 and RFC7516 Section 4.1.9. -
x5t_S256
The X.509 Certificate SHA-256 Thumbprint parameter as defined by RFC7515 Section 4.1.8 and RFC7516 Section 4.1.10. -
typ
The Type parameter as defined by RFC7515 Section 4.1.9 and RFC7516 Section 4.1.11. -
cty
The Content Type parameter as defined by RFC7515 Section 4.1.10 and RFC7516 Section 4.1.12. -
crit
The Critical parameter as defined by RFC7515 Section 4.1.11 and RFC7516 Section 4.1.13. -
customParameters
The custom parameters as defined by RFC7515 Section 4.2 and RFC7516 Section 4.2. -
encoded
The JOSE header encoded as Base64URL without padding -
key
The key that was used to secure the JOSE object.
-
-
Constructor Details
-
AbstractJOSEHeader
public AbstractJOSEHeader()Creates a JOSE header.
-
AbstractJOSEHeader
Creates a JOSE header with the specified algorithm.
- Parameters:
alg- a JWA algorithm
-
-
Method Details
-
setEncoded
Sets the encoded header as Base64URL.
- Parameters:
encoded- the Base64URL encoded header
-
getEncoded
Description copied from interface:JOSEHeaderReturns the header encoded as Base64URL.
- Specified by:
getEncodedin interfaceJOSEHeader- Returns:
- the Base64URL encoded header without padding
-
getProcessedParameters
Returns the parameters processed by the JOSE header.
- Returns:
- a set of processed parameters
-
getAlgorithm
Description copied from interface:JOSEHeaderReturns the cryptographic algorithm used to secure the JOSE object.
Depending on the type of JOSE object considered, it might designate a signature or a key management algorithm.
- Specified by:
getAlgorithmin interfaceJOSEHeader- Returns:
- a JWA algorithm
-
getJWKSetURL
Description copied from interface:JOSEHeaderReturns the JWK Set URL.
This URL points to a set of JSON-encoded public keys, one of which corresponds to the key used to secure the JOSE object.
- Specified by:
getJWKSetURLin interfaceJOSEHeader- Returns:
- a URL or null
-
getJWK
Description copied from interface:JOSEHeaderReturns the public JWK that corresponds to the key used to secure the JOSE object.
- Specified by:
getJWKin interfaceJOSEHeader- Returns:
- a JWK or null
-
getKeyId
Description copied from interface:JOSEHeaderReturns the id of the key that was used to secure the JOSE object.
- Specified by:
getKeyIdin interfaceJOSEHeader- Returns:
- a key id or null
-
getX509CertificateURL
Description copied from interface:JOSEHeaderReturns the URL of the X.509 certificate or certificates chain that corresponds to the key that was used to secure the JOSE object.
The certificates chain located at the URL must be in PEM format. The certificate containing the public key corresponding to the key that was used to secure the JOSE object must be the first certificate in the chain.
- Specified by:
getX509CertificateURLin interfaceJOSEHeader- Returns:
- a URL or null
-
getX509CertificateChain
Description copied from interface:JOSEHeaderReturns the X.509 certificates chain that corresponds to the key that was used to secure the JOSE object.
The certificates chain is represented as an array of Base64URL encoded DER PKIX certificates. The certificate containing the public key corresponding to the key that was used to secure the JOSE object must be the first certificate in the chain.
- Specified by:
getX509CertificateChainin interfaceJOSEHeader- Returns:
- a certificates chain or null
-
getX509CertificateSHA1Thumbprint
Description copied from interface:JOSEHeaderReturns the X.509 SHA1 thumbprint of the certificate that corresponds to the key that was used to secure the JOSE object.
- Specified by:
getX509CertificateSHA1Thumbprintin interfaceJOSEHeader- Returns:
- an X.509 SHA1 thumbprint or null
-
getX509CertificateSHA256Thumbprint
Description copied from interface:JOSEHeaderReturns the X.509 SHA256 thumbprint of the certificate that corresponds to the key that was used to secure the JOSE object.
- Specified by:
getX509CertificateSHA256Thumbprintin interfaceJOSEHeader- Returns:
- an X.509 SHA256 thumbprint or null
-
getType
Description copied from interface:JOSEHeaderReturns the media type of the complete JOSE object.
To keep messages compact in common situations, the
application/prefix of a media type can be omitted when no other/appears in the value.- Specified by:
getTypein interfaceJOSEHeader- Returns:
- a media type or null
-
getContentType
Description copied from interface:JOSEHeaderReturns the media type of the JOSE object payload.
To keep messages compact in common situations, the
application/prefix of a media type can be omitted when no other/appears in the value.- Specified by:
getContentTypein interfaceJOSEHeader- Returns:
- a media type or null
-
getCritical
Description copied from interface:JOSEHeaderReturns the set of custom parameters that must be understood and processed.
Critical parameters are not registered JOSE header parameters and they are present in header's custom parameters.
- Specified by:
getCriticalin interfaceJOSEHeader- Returns:
- a set of custom parameters or null
-
getCustomParameters
Description copied from interface:JOSEHeaderReturns the map of custom parameters.
- Specified by:
getCustomParametersin interfaceJOSEHeader- Returns:
- a map of custom parameters
-
setKey
Sets the actual key that was used to secure the JOSE object.
- Parameters:
key- a JWK
-
getKey
Description copied from interface:JOSEHeaderReturns the actual key that was used to secure the JOSE object.
Depending on the context it may refer to the private key that was used to sign/encrypt the JOSE object or to the public key that was used to verify/decrypt the JOSE object.
- Specified by:
getKeyin interfaceJOSEHeader- Returns:
- a JWK
-
algorithm
Description copied from interface:JOSEHeaderConfiguratorspecifies the cryptographic algorithm to use to secure the JOSE object.
Depending on the type of JOSE object to build, it might designate a signature or a key management algorithm.
- Specified by:
algorithmin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
alg- a JWA algorithm- Returns:
- this builder
-
jwkSetURL
Description copied from interface:JOSEHeaderConfiguratorSpecifies the JWK Set URL that contains the key to use to secure the JOSE object.
The URL must points to a set of JSON-encoded public keys.
- Specified by:
jwkSetURLin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
jku- the JWK Set URL- Returns:
- this builder
-
jwk
Description copied from interface:JOSEHeaderConfiguratorSpecifies the JWK to use to secure the JOSE object.
It is represented as a map to comply with the JOSE object definition, the builder eventually tries to resolve an actual JWK based on these parameters.
- Specified by:
jwkin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
jwk- a JWK as a map- Returns:
- this builder
-
keyId
Description copied from interface:JOSEHeaderConfiguratorSpecifies the id of the key to use to secure the JOSE object.
- Specified by:
keyIdin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
kid- a key id- Returns:
- this builder
-
x509CertificateURL
Description copied from interface:JOSEHeaderConfiguratorSpecifies the URL of the X.509 certificate or certificates chain that corresponds to the key to use to secure the JOSE object.
The certificates chain located at the URL must be in PEM format. The first certificate in the chain must correspond to the key to use to secure the JOSE object.
- Specified by:
x509CertificateURLin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
x5u- a URL- Returns:
- this builder
-
x509CertificateChain
Description copied from interface:JOSEHeaderConfiguratorSpecifies the X.509 certificates chain that corresponds to the key to use to secure the JOSE object.
The certificates chain must be represented as an array of Base64URL encoded DER PKIX certificates. The first certificate in the chain must correspond to the key to use to secure the JOSE object.
- Specified by:
x509CertificateChainin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
x5c- a certificates chain- Returns:
- this builder
-
x509CertificateSHA1Thumbprint
Description copied from interface:JOSEHeaderConfiguratorSpecifies the X.509 SHA1 thumbprint of the certificate that corresponds to the key to use to secure the JOSE object.
- Specified by:
x509CertificateSHA1Thumbprintin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
x5t- an X.509 SHA1 thumbprint- Returns:
- this builder
-
x509CertificateSHA256Thumbprint
Description copied from interface:JOSEHeaderConfiguratorSpecifies the X.509 SHA256 thumbprint of the certificate that corresponds to the key to use to secure the JOSE object.
- Specified by:
x509CertificateSHA256Thumbprintin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
x5t_S256- an X.509 SHA256 thumbprint- Returns:
- this builder
-
type
Description copied from interface:JOSEHeaderConfiguratorSpecifies the media type of the complete JOSE object.
To keep messages compact in common situations, the
application/prefix of a media type can be omitted when no other/appears in the value.- Specified by:
typein interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
typ- a media type- Returns:
- this builder
-
contentType
Description copied from interface:JOSEHeaderConfiguratorSpecifies the media type of the JOSE object payload.
To keep messages compact in common situations, the
application/prefix of a media type can be omitted when no other/appears in the value.The builder might use this media type to determine how to serialize/deserialize a JOSE object payload.
- Specified by:
contentTypein interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
cty- a media type- Returns:
- this builder
-
critical
Description copied from interface:JOSEHeaderConfiguratorSpecifies the set of custom parameters that must be understood and processed.
Critical parameters can not be registered JOSE header parameters and they must be present in header's custom parameters.
- Specified by:
criticalin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
crit- a set of custom parameters- Returns:
- this builder
-
addCustomParameter
Description copied from interface:JOSEHeaderConfiguratorSpecifies a custom parameter to add to the header.
- Specified by:
addCustomParameterin interfaceJOSEHeaderConfigurator<A extends AbstractJOSEHeader<A>>- Parameters:
key- the custom parameter namevalue- the custom parameter value- Returns:
- this builder
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceJOSEHeader- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceJOSEHeader- Overrides:
equalsin classObject
-