Package net.solarnetwork.node.domain
Class SecurityToken
- All Implemented Interfaces:
Serializable,Comparable<String>,net.solarnetwork.dao.Entity<String>,net.solarnetwork.domain.Identity<String>
public class SecurityToken
extends net.solarnetwork.dao.BasicStringEntity
A security token, for API access.
The BasicIdentity.getId() value is the security token identifier.
- Since:
- 3.4
- Version:
- 1.0
- Author:
- matt
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TapplySecret(Function<String, T> dest) Apply the secret to a function.voidcopySecret(Consumer<String> dest) Copy the secret to a consumer.copyWithoutSecret(String newName, String newDescription) Create a copy without the token secret populated.Get the created date as aDateinstance.Get the description.getName()Get the name.<T extends net.solarnetwork.security.AbstractAuthorizationBuilder<T>>
TsaveSigningKey(net.solarnetwork.security.AbstractAuthorizationBuilder<T> builder) Save the signing key from the token secret.static SecurityTokentokenDetails(String name, String description) Create a token from just the detail properties.static SecurityTokentokenDetails(String tokenId, String name, String description) Create a token from just the detail properties.toString()Methods inherited from class net.solarnetwork.dao.BasicStringEntity
cloneMethods inherited from class net.solarnetwork.dao.BasicEntity
getCreatedMethods inherited from class net.solarnetwork.dao.BasicIdentity
compareTo, equals, getId, hashCodeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface net.solarnetwork.domain.Identity
getId, hasId
-
Constructor Details
-
SecurityToken
Constructor.- Parameters:
tokenId- the token identifiertokenSecret- the token secret- Throws:
IllegalArgumentException- if any argument is null
-
SecurityToken
public SecurityToken(String tokenId, Instant created, String tokenSecret, String name, String description) Constructor.- Parameters:
tokenId- the token identifiercreated- the creation datetokenSecret- the token secretname- the namedescription- the description- Throws:
IllegalArgumentException- iftokenIdortokenSecretare null
-
-
Method Details
-
tokenDetails
Create a token from just the detail properties.- Parameters:
tokenId- the token IDname- the namedescription- the description- Returns:
- the token instance
-
tokenDetails
Create a token from just the detail properties.- Parameters:
name- the namedescription- the description- Returns:
- the token instance
-
copyWithoutSecret
Create a copy without the token secret populated.- Parameters:
newName- if non-null then use for thenamein the new copynewDescription- if non-null then use for thedescriptionin the new copy- Returns:
- the copy
-
saveSigningKey
public <T extends net.solarnetwork.security.AbstractAuthorizationBuilder<T>> T saveSigningKey(net.solarnetwork.security.AbstractAuthorizationBuilder<T> builder) Save the signing key from the token secret.- Type Parameters:
T- the builder type- Parameters:
builder- the authorization builder to callAbstractAuthorizationBuilder.saveSigningKey(String)on- Returns:
- the
builderinstance - Throws:
IllegalArgumentException- if any argument is nullnet.solarnetwork.security.SecurityException- if any error occurs computing the key
-
copySecret
Copy the secret to a consumer.- Parameters:
dest- the consumer
-
applySecret
Apply the secret to a function.- Type Parameters:
T- the function return type- Parameters:
dest- the function to apply- Returns:
- the function result
-
toString
-
getCreatedDate
Get the created date as aDateinstance.- Returns:
- the date
-
getName
Get the name.- Returns:
- the name
-
getDescription
Get the description.- Returns:
- the description
-