Package com.cloudinary
Class AuthToken
java.lang.Object
com.cloudinary.AuthToken
public class AuthToken
extends java.lang.Object
Authentication Token generator
-
Field Summary
Fields Modifier and Type Field Description static AuthTokenNULL_AUTH_TOKENA null AuthToken, which can be passed to a method to override global settings. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description AuthTokenacl(java.lang.String... acl)Define an ACL for a cookie tokenjava.util.Map<java.lang.String,java.lang.Object>asMap()AuthTokencopy()Create a copy of this AuthTokenAuthTokenduration(long duration)The duration of the token in seconds.booleanequals(java.lang.Object o)AuthTokenexpiration(long expiration)Set the end time (expiration) of the tokenjava.lang.Stringgenerate()Generate the authentication tokenjava.lang.Stringgenerate(java.lang.String url)Generate a URL token for the given URL.inthashCode()AuthTokenip(java.lang.String ip)Set the ip of the clientAuthTokenmerge(AuthToken other)Merge this token with another, creating a new token.AuthTokenstartTime(long startTime)Set the start time of the token.AuthTokentokenName(java.lang.String tokenName)Create a new AuthToken configuration overriding the default token name.
-
Field Details
-
NULL_AUTH_TOKEN
A null AuthToken, which can be passed to a method to override global settings.
-
-
Constructor Details
-
Method Details
-
asMap
public java.util.Map<java.lang.String,java.lang.Object> asMap() -
tokenName
Create a new AuthToken configuration overriding the default token name.- Parameters:
tokenName- the name of the token. must be supported by the server.- Returns:
- this
-
startTime
Set the start time of the token. Defaults to now.- Parameters:
startTime- in seconds since epoch- Returns:
- this
-
expiration
Set the end time (expiration) of the token- Parameters:
expiration- in seconds since epoch- Returns:
- this
-
ip
Set the ip of the client- Parameters:
ip-- Returns:
- this
-
acl
Define an ACL for a cookie token- Parameters:
acl-- Returns:
- this
-
duration
The duration of the token in seconds. This value is used to calculate the expiration of the token. It is ignored if expiration is provided.- Parameters:
duration- in seconds- Returns:
- this
-
generate
public java.lang.String generate()Generate the authentication token- Returns:
- a signed token
-
generate
public java.lang.String generate(java.lang.String url)Generate a URL token for the given URL.- Parameters:
url- the URL to be authorized- Returns:
- a URL token
-
copy
Create a copy of this AuthToken- Returns:
- a new AuthToken object
-
merge
Merge this token with another, creating a new token. Other's members who are notnullor0will override this object's members.- Parameters:
other- the token to merge from- Returns:
- a new token
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-