Skip to content

class Athena::Security::Authentication::Token::Null
inherits Reference #

Represents the absence of an authenticated user, e.g. when deciding the access of a guest.

Included modules

Athena::Security::Authentication::Token::Interface

Methods#

#attribute(name : String, type : T.class) : T forall T#

Returns the value of the attribute with the provided name, deserialized as the provided type.

Raises an ASEC::Exception::InvalidArgument if this token has no attribute with that name.

View source

#attribute?(name : String, type : T.class) : T | Nil forall T#

Returns the value of the attribute with the provided name, deserialized as the provided type, or nil if this token has no attribute with that name.

View source

#attributes : Hash(String, String)#

Returns the attributes of this token, with their values serialized as JSON.

View source

#attributes=(attributes : Hash(String, String)) : NoReturn#

Replaces the attributes of this token with the provided attributes, whose values are serialized as JSON.

Raises an ASEC::Exception::Logic, as a null token has no attributes.

View source

#has_attribute?(name : String) : Bool#

Returns true if this token has an attribute with the provided name, otherwise false.

View source

#role_names : Array(String)#

Returns the roles granted to the user by this token.

View source

#set_attribute(name : String, value : _) : NoReturn#

Sets the attribute with the provided name to the provided value.

Raises an ASEC::Exception::Logic, as a null token has no attributes.

View source

#to_s(io : IO) : Nil#

Writes a representation of this token to the provided io, for debugging purposes.

View source

#user : ASEC::User::Interface | ::Nil#

Returns the authenticated user, if any.

View source

#user=(user : ASEC::User::Interface) : NoReturn#

Sets the authenticated user.

Raises an ASEC::Exception::Logic, as a null token has no user.

View source

#user_identifier : String#

Returns the identifier of the user, e.g. its username or email address, or an empty string if there is no user.

View source