class PreAuthenticatedToken extends AbstractToken

PreAuthenticatedToken implements a pre-authenticated token.

Methods

__construct(string|object $user, mixed $credentials, string $providerKey, array $roles = [])

No description

array
getRoleNames()

No description

Role[]
getRoles()

Returns the user roles.

string
getUsername()

Returns the username.

string|object
getUser()

Returns a user representation.

setUser(string|object $user)

Sets the user in the token.

bool
isAuthenticated()

Returns whether the user is authenticated or not.

setAuthenticated($authenticated)

Sets the authenticated flag.

eraseCredentials()

Removes sensitive information from the token.

serialize()

{@inheritdoc}

unserialize($serialized)

{@inheritdoc}

array
getState()

Returns all the necessary state of the object for serialization purposes.

setState(array $data)

Restores the object state from an array given by getState().

array
getAttributes()

Returns the token attributes.

setAttributes(array $attributes)

Sets the token attributes.

bool
hasAttribute(string $name)

Returns true if the attribute exists.

mixed
getAttribute(string $name)

Returns an attribute value.

setAttribute(string $name, mixed $value)

Sets an attribute.

string
__toString()

Returns a string representation of the Token.

doSerialize($serialized, $isCalledFromOverridingMethod)

No description

string
getProviderKey()

Returns the provider key.

mixed
getCredentials()

Returns the user credentials.

Details

at line 30
__construct(string|object $user, mixed $credentials, string $providerKey, array $roles = [])

Parameters

string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
mixed $credentials The user credentials
string $providerKey The provider key
array $roles An array of roles

in AbstractToken at line 52
array getRoleNames()

Return Value

array

in AbstractToken at line 60
Role[] getRoles()

Returns the user roles.

Return Value

Role[] An array of Role instances

in AbstractToken at line 72
string getUsername()

Returns the username.

Return Value

string

in AbstractToken at line 84
string|object getUser()

Returns a user representation.

Return Value

string|object Can be a UserInterface instance, an object implementing a __toString method, or the username as a regular string

in AbstractToken at line 92
setUser(string|object $user)

Sets the user in the token.

The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string.

Parameters

string|object $user The user

Exceptions

InvalidArgumentException

in AbstractToken at line 122
bool isAuthenticated()

Returns whether the user is authenticated or not.

Return Value

bool true if the token has been authenticated, false otherwise

in AbstractToken at line 130
setAuthenticated($authenticated)

Sets the authenticated flag.

Parameters

$authenticated

at line 68
eraseCredentials()

Removes sensitive information from the token.

in AbstractToken at line 152
serialize()

{@inheritdoc}

in AbstractToken at line 164
unserialize($serialized)

{@inheritdoc}

Parameters

$serialized

at line 78
protected array getState()

Returns all the necessary state of the object for serialization purposes.

There is no need to serialize any entry, they should be returned as-is. If you extend this method, keep in mind you MUST guarantee parent data is present in the state. Here is an example of how to extend this method: protected function getState(): array { return [$this->childAttribute, parent::getState()]; }

Return Value

array

at line 86
protected setState(array $data)

Restores the object state from an array given by getState().

There is no need to unserialize any entry in $data, they are already ready-to-use. If you extend this method, keep in mind you MUST pass the parent data to its respective class. Here is an example of how to extend this method: protected function setState(array $data) { [$this->childAttribute, $parentData] = $data; parent::setState($parentData); }

Parameters

array $data

in AbstractToken at line 215
array getAttributes()

Returns the token attributes.

Return Value

array The token attributes

in AbstractToken at line 225
setAttributes(array $attributes)

Sets the token attributes.

Parameters

array $attributes The token attributes

in AbstractToken at line 237
bool hasAttribute(string $name)

Returns true if the attribute exists.

Parameters

string $name The attribute name

Return Value

bool true if the attribute exists, false otherwise

in AbstractToken at line 251
mixed getAttribute(string $name)

Returns an attribute value.

Parameters

string $name The attribute name

Return Value

mixed The attribute value

Exceptions

InvalidArgumentException When attribute doesn't exist for this token

in AbstractToken at line 266
setAttribute(string $name, mixed $value)

Sets an attribute.

Parameters

string $name The attribute name
mixed $value The attribute value

in AbstractToken at line 274
string __toString()

Returns a string representation of the Token.

This is only to be used for debugging purposes.

Return Value

string

in AbstractToken at line 290
protected doSerialize($serialized, $isCalledFromOverridingMethod)

Parameters

$serialized
$isCalledFromOverridingMethod

at line 52
string getProviderKey()

Returns the provider key.

Return Value

string The provider key

at line 60
mixed getCredentials()

Returns the user credentials.

Return Value

mixed The user credentials