CSToken
in package
implements
Stringable
This class represents an authentication token
Tags
Interfaces, Classes and Traits
- Stringable
Table of Contents
- VALIDITY_1_MINUTES = -60
- Validity constants
- VALIDITY_30_MINUTES = -1800
- VALIDITY_5_MINUTES = -300
- VALIDITY_60_MINUTES = -3600
- __toString() : string
- Returns the string representation of the token instance.
- createForAppContext() : CSToken
- Creates a token instance for an app context.
- createForData() : CSToken
- Creates a token instance based on the provided data.
- createForFileContext() : CSToken
- Creates a token instance for a file context.
- createForImageContext() : CSToken
- Creates a token instance for an image context.
- createForModuleContext() : CSToken
- Creates a token instance for a module context.
- createForRestContext() : CSToken
- Creates a token instance for a rest context.
- createFromId() : CSToken
- Creates a new token instance with new context from the data provided in a token id.
- getContext() : string
- Returns the context of the current token instance
- getCurrentId() : string
- Returns the current token id extracted from the environment.
- getFromId() : CSToken
- Creates the token instance from the data provided in a token id.
- getId() : string
- Returns the id of the current token instance.
- getProject() : string
- Returns the project name of the current token instance
- getUrlParameter() : string
- Returns the URL parameter string to append to URLs.
- getUrlParameterName() : string
- Returns the URL parameter name for token.
- getUsername() : string
- Returns the user name of the current token instance
- getValidUntil() : string
- Returns the valid until timestamp of the current token instance.
- hasExpired() : bool
- Returns whether the current token instance has expired or not.
- setCurrentId() : void
- Sets the current token id
Constants
VALIDITY_1_MINUTES
Validity constants
public
mixed
VALIDITY_1_MINUTES
= -60
Tags
VALIDITY_30_MINUTES
public
mixed
VALIDITY_30_MINUTES
= -1800
Tags
VALIDITY_5_MINUTES
public
mixed
VALIDITY_5_MINUTES
= -300
Tags
VALIDITY_60_MINUTES
public
mixed
VALIDITY_60_MINUTES
= -3600
Tags
Methods
__toString()
Returns the string representation of the token instance.
public
__toString() : string
Tags
Return values
string —The string representation of the token instance.
createForAppContext()
Creates a token instance for an app context.
public
static createForAppContext(string $sApp[, int $iValidUntil = CSToken::VALIDITY_5_MINUTES ][, int $iUserId = null ]) : CSToken
Parameters
- $sApp : string
-
The app for which this token is valid.
- $iValidUntil : int = CSToken::VALIDITY_5_MINUTES
-
A timestamp defining the validity of the token.
- $iUserId : int = null
-
A user id allowing to create a token for a specific user
Tags
Return values
CSToken —The matching token instance
createForData()
Creates a token instance based on the provided data.
public
static createForData(string $sProject, string $sUsername, int $iValidUntil, CSTokenContext $oContext) : CSToken
Parameters
- $sProject : string
-
The project name for which this token is created
- $sUsername : string
-
The user name for which this token is created.
- $iValidUntil : int
-
The timestamp defining the validity of the token. It can also be one of the VALIDITY_X_MINUTES-constant
- $oContext : CSTokenContext
-
The context for which this token is valid.
Tags
Return values
CSToken —The token instance matching the provided data
createForFileContext()
Creates a token instance for a file context.
public
static createForFileContext(string $sFile[, int $iValidUntil = CSToken::VALIDITY_5_MINUTES ][, int $iUserId = null ]) : CSToken
Parameters
- $sFile : string
-
The file for which this token is valid.
- $iValidUntil : int = CSToken::VALIDITY_5_MINUTES
-
A timestamp defining the validity of the token.
- $iUserId : int = null
-
A user id allowing to create a token for a specific user
Tags
Return values
CSToken —The matching token instance
createForImageContext()
Creates a token instance for an image context.
public
static createForImageContext(string $sClass[, int $iValidUntil = CSToken::VALIDITY_5_MINUTES ][, int $iUserId = null ]) : CSToken
Parameters
- $sClass : string
-
The class of objects for which this token is valid.
- $iValidUntil : int = CSToken::VALIDITY_5_MINUTES
-
A timestamp defining the validity of the token.
- $iUserId : int = null
-
A user id allowing to create a token for a specific user
Tags
Return values
CSToken —The matching token instance
createForModuleContext()
Creates a token instance for a module context.
public
static createForModuleContext(string $sModule[, int $iValidUntil = CSToken::VALIDITY_5_MINUTES ][, int $iUserId = null ]) : CSToken
Parameters
- $sModule : string
-
The module for which this token is valid.
- $iValidUntil : int = CSToken::VALIDITY_5_MINUTES
-
A timestamp defining the validity of the token.
- $iUserId : int = null
-
A user id allowing to create a token for a specific user
Tags
Return values
CSToken —The matching token instance
createForRestContext()
Creates a token instance for a rest context.
public
static createForRestContext(string $sEndpoint[, int $iValidUntil = CSToken::VALIDITY_5_MINUTES ][, int $iUserId = null ]) : CSToken
Parameters
- $sEndpoint : string
-
The endpoint for which this token is valid.
- $iValidUntil : int = CSToken::VALIDITY_5_MINUTES
-
A timestamp defining the validity of the token.
- $iUserId : int = null
-
A user id allowing to create a token for a specific user
Tags
Return values
CSToken —The matching token instance
createFromId()
Creates a new token instance with new context from the data provided in a token id.
public
static createFromId(string $sId, CSTokenContext $oContext) : CSToken
Parameters
- $sId : string
-
The token id from which the new token should be created.
- $oContext : CSTokenContext
-
The new token context.
Tags
Return values
CSToken —The new token based on the data from the token id and the new context.
getContext()
Returns the context of the current token instance
public
getContext() : string
Tags
Return values
string —The context of the current token instance.
getCurrentId()
Returns the current token id extracted from the environment.
public
static getCurrentId() : string
Tags
Return values
string —The current token id
getFromId()
Creates the token instance from the data provided in a token id.
public
static getFromId(string $sId) : CSToken
Parameters
- $sId : string
-
The token id with the data.
Tags
Return values
CSToken —The token instance based on the data from the token id.
getId()
Returns the id of the current token instance.
public
getId() : string
Tags
Return values
string —The token id of the current token instance.
getProject()
Returns the project name of the current token instance
public
getProject() : string
Tags
Return values
string —The project name of the current token instance.
getUrlParameter()
Returns the URL parameter string to append to URLs.
public
getUrlParameter() : string
Tags
Return values
string —The URL parameter to be appended to URLs.
getUrlParameterName()
Returns the URL parameter name for token.
public
static getUrlParameterName() : string
Tags
Return values
string —The URL parameter name for token.
getUsername()
Returns the user name of the current token instance
public
getUsername() : string
Tags
Return values
string —The user name of the current token instance.
getValidUntil()
Returns the valid until timestamp of the current token instance.
public
getValidUntil() : string
Tags
Return values
string —The valid until timestamp of the current token instance.
hasExpired()
Returns whether the current token instance has expired or not.
public
hasExpired() : bool
Tags
Return values
bool —True, if token instance has expired, otherwise false.
setCurrentId()
Sets the current token id
public
static setCurrentId(string $sId) : void
Parameters
- $sId : string
-
The current token id to set
