Package com.nimbusds.jose.proc
Class DefaultJOSEObjectTypeVerifier<C extends SecurityContext>
- java.lang.Object
-
- com.nimbusds.jose.proc.DefaultJOSEObjectTypeVerifier<C>
-
- All Implemented Interfaces:
JOSEObjectTypeVerifier<C>
@Immutable public class DefaultJOSEObjectTypeVerifier<C extends SecurityContext> extends Object implements JOSEObjectTypeVerifier<C>
Default JOSE header "typ" (type) parameter verifier.Example JWS header with a "typ" (type) parameter set to "at+jwt":
{ "alg" : "ES256", "typ" : "at+jwt", "kid" : "123" }
To create a verifier which allows the "typ" to be omitted or set to "JWT":
JOSEObjectVerifier verifier = new DefaultJOSEObjectTypeVerifier(JOSEObjectType.JWT, null);
To create a verifier which allows a "typ" of "at+jwt":
JOSEObjectVerifier verifier = new DefaultJOSEObjectTypeVerifier(new JOSEObjectType("at+jwt")));
- Since:
- 8.0
- Version:
- 2019-10-15
- Author:
- Vladimir Dzhuvinov
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultJOSEObjectTypeVerifier
JOSE
The standard header "typ" (type) parameter verifier for JWS, JWE and plain (unsecured) JOSE objects (other than JWT).static DefaultJOSEObjectTypeVerifier
JWT
The standard header "typ" (type) parameter verifier for signed, encrypted and plain (unsecured) JWTs.
-
Constructor Summary
Constructors Constructor Description DefaultJOSEObjectTypeVerifier()
Creates a new JOSE object type verifier which allows the type to be omitted ornull
.DefaultJOSEObjectTypeVerifier(JOSEObjectType... allowedTypes)
Creates a new JOSE object type verifier allowing the specified types.DefaultJOSEObjectTypeVerifier(Set<JOSEObjectType> allowedTypes)
Creates a new JOSE object type verifier allowing the specified types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<JOSEObjectType>
getAllowedTypes()
Returns the allowed JOSE object types.void
verify(JOSEObjectType type, C context)
Verifies the JOSE "typ" (type) header parameter.
-
-
-
Field Detail
-
JOSE
public static final DefaultJOSEObjectTypeVerifier JOSE
The standard header "typ" (type) parameter verifier for JWS, JWE and plain (unsecured) JOSE objects (other than JWT). See RFC 7515, section 4.1.9 and RFC 7516, section 4.1.11.
-
JWT
public static final DefaultJOSEObjectTypeVerifier JWT
The standard header "typ" (type) parameter verifier for signed, encrypted and plain (unsecured) JWTs. See RFC 7519, section 5.1.
-
-
Constructor Detail
-
DefaultJOSEObjectTypeVerifier
public DefaultJOSEObjectTypeVerifier()
Creates a new JOSE object type verifier which allows the type to be omitted ornull
.
-
DefaultJOSEObjectTypeVerifier
public DefaultJOSEObjectTypeVerifier(Set<JOSEObjectType> allowedTypes)
Creates a new JOSE object type verifier allowing the specified types.- Parameters:
allowedTypes
- The allowed types, if anull
is included the type parameter may be omitted ornull
. The set must not benull
or empty.
-
DefaultJOSEObjectTypeVerifier
public DefaultJOSEObjectTypeVerifier(JOSEObjectType... allowedTypes)
Creates a new JOSE object type verifier allowing the specified types.- Parameters:
allowedTypes
- The allowed types, if anull
is included the type parameter may be omitted ornull
. The array must not benull
or empty.
-
-
Method Detail
-
getAllowedTypes
public Set<JOSEObjectType> getAllowedTypes()
Returns the allowed JOSE object types.- Returns:
- The allowed JOSE object types, if a
null
is included the type parameter may be omitted ornull
.
-
verify
public void verify(JOSEObjectType type, C context) throws BadJOSEException
Description copied from interface:JOSEObjectTypeVerifier
Verifies the JOSE "typ" (type) header parameter.- Specified by:
verify
in interfaceJOSEObjectTypeVerifier<C extends SecurityContext>
- Parameters:
type
- The "typ" (type) header parameter,null
if not set.context
- Optional context,null
if not required.- Throws:
BadJOSEException
- If the type is rejected.
-
-