class Checkpoint::Credential::Token

A Credential::Token is an identifier object for a Credential. It includes a type and an identifier. A {Grant} can be created for a Token. Concrete actions are resolved into a number of credentials, and those credentials' tokens will be checked for matching grants.

Attributes

credential_id[R]
credential_type[R]
id[R]
type[R]

Public Class Methods

new(type, id) click to toggle source

Create a new Credential representing a permission or instrument that represents multiple permissions.

@param type [String] the application-determined type of this credential.

For example, this might be 'permission' or 'role'.

@param id [String] the application-resolvable identifier for this

credential. For example, this might be an action to be taken or the ID
of a role.
# File lib/checkpoint/credential/token.rb, line 21
def initialize(type, id)
  @type = type.to_s
  @id = id.to_s
end

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source

Compare with another Credential for equality. Consider them to represent the same credential if `other` is a credential, has the same type, and same id.

# File lib/checkpoint/credential/token.rb, line 43
def eql?(other)
  other.is_a?(Token) && type == other.type && id == other.id
end
Also aliased as: ==
hash() click to toggle source

@return [Integer] hash code based on to_s

# File lib/checkpoint/credential/token.rb, line 48
def hash
  to_s.hash
end
inspect()
Alias for: uri
to_s() click to toggle source

@return [String] a token suitable for granting or matching this credential

# File lib/checkpoint/credential/token.rb, line 37
def to_s
  "#{type}:#{id}"
end
token() click to toggle source

@return [Token] self; for convenience of taking a Credential or token

# File lib/checkpoint/credential/token.rb, line 32
def token
  self
end
uri() click to toggle source

@return [String] a URI for this credential, including its type and id

# File lib/checkpoint/credential/token.rb, line 27
def uri
  "credential://#{type}/#{id}"
end
Also aliased as: inspect