public class ClaimValidationUtils extends Object
Constructor and Description |
---|
ClaimValidationUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
validateClaimNameOverride(String name,
String value)
Validates that the given claim name override is valid, where invalid means
any of the following:
null
Zero length
Whitespace only
|
static long |
validateExpiration(String claimName,
Long claimValue)
Validates that the given lifetime is valid, where invalid means any of
the following:
null
Negative
|
static Long |
validateIssuedAt(String claimName,
Long claimValue)
Validates that the given issued at claim name is valid, where invalid means any of
the following:
Negative
|
static Set<String> |
validateScopes(String scopeClaimName,
Collection<String> scopes)
Validates that the scopes are valid, where invalid means any of
the following:
Collection is
null
Collection has duplicates
Any of the elements in the collection are null
Any of the elements in the collection are zero length
Any of the elements in the collection are whitespace only
|
static String |
validateSubject(String claimName,
String claimValue)
Validates that the given claim value is valid, where invalid means any of
the following:
null
Zero length
Whitespace only
|
public static Set<String> validateScopes(String scopeClaimName, Collection<String> scopes) throws ValidateException
null
null
scopeClaimName
- Name of the claim used for the scope valuesscopes
- Collection of String scopesSet
that includes the values of the original set, but with
each value trimmedValidateException
- Thrown if the value is null
, contains duplicates, or
if any of the values in the set are null
, empty,
or whitespace onlypublic static long validateExpiration(String claimName, Long claimValue) throws ValidateException
null
claimName
- Name of the claimclaimValue
- Expiration time (in milliseconds)ValidateException
- Thrown if the value is null
or negativepublic static String validateSubject(String claimName, String claimValue) throws ValidateException
null
claimName
- Name of the claimclaimValue
- Name of the subjectclaimValue
parameterValidateException
- Thrown if the value is null
, empty, or whitespace onlypublic static Long validateIssuedAt(String claimName, Long claimValue) throws ValidateException
claimName
- Name of the claimclaimValue
- Start time (in milliseconds) or null
if not usedValidateException
- Thrown if the value is negativepublic static String validateClaimNameOverride(String name, String value) throws ValidateException
null
name
- "Standard" name of the claim, e.g. sub
value
- "Override" name of the claim, e.g. email
value
parameterValidateException
- Thrown if the value is null
, empty, or whitespace only