Package com.codingchili.core.security
Class Token
java.lang.Object
com.codingchili.core.security.Token
- All Implemented Interfaces:
Serializable
Used to authenticate requests between services and with clients.
- See Also:
- Serialized Form
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddProperty(String key, Object value)
Adds a property to the token.Sets the expiry date of the token.long
getKey()
<T> T
getProperty(String key)
setExpiry(long expiry)
setProperties(Map<String,Object> properties)
-
Constructor Details
-
Token
public Token()Creates a new empty unverified token. -
Token
Creates a new hmac token with the specified token factory.- Parameters:
domain
- a unique identifier - username or service id.
-
-
Method Details
-
getKey
- Returns:
- the cipher value of the token.
-
setKey
- Parameters:
key
- the cipher value, this should be cryptographically generated and balidated.- Returns:
- fluent.
-
getExpiry
public long getExpiry()- Returns:
- the time of expiry in epoch seconds.
-
setExpiry
- Parameters:
expiry
- the time of expiry on epoch seconds.- Returns:
- fluent
-
expires
Sets the expiry date of the token.- Parameters:
value
- the number of time units the token is valid for from now.unit
- the time unit of the given value.- Returns:
- fluent.
-
getDomain
- Returns:
- the domain in which this token is valid for authentication.
-
setDomain
- Parameters:
domain
- the domain where this token should be valid for authentication.- Returns:
- fluent.
-
getProperty
-
addProperty
Adds a property to the token. This must be cryptographically incorporated in thegetKey()
.- Parameters:
key
- the key of the property to set.value
- the value of the property to set.- Returns:
- fluent.
-
getProperties
- Returns:
- all properties that are set on the token.
-
setProperties
- Parameters:
properties
- a map of properties to set.- Returns:
- fluent.
-