Class: Lapis::Yggdrasil::SessionInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/lapis/yggdrasil/session_info.rb

Overview

Token and profile information associated with an authentication session.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_token, access_token, profile) ⇒ SessionInfo

Creates information about an authentication session.

Parameters:

  • client_token (Uuid)

    Unique ID of the client that performed the authentication.

  • access_token (Uuid)

    Unique ID of the authentication session.

  • profile (Profile)

    Information about the currently selected player profile.



26
27
28
29
30
# File 'lib/lapis/yggdrasil/session_info.rb', line 26

def initialize(client_token, access_token, profile)
  @client_token = client_token
  @access_token = access_token
  @profile      = profile
end

Instance Attribute Details

#access_tokenUuid (readonly)

Unique ID of the authentication session.

Returns:

  • (Uuid)


16
17
18
# File 'lib/lapis/yggdrasil/session_info.rb', line 16

def access_token
  @access_token
end

#client_tokenUuid (readonly)

Unique ID of the client that performed the authentication.

Returns:

  • (Uuid)


12
13
14
# File 'lib/lapis/yggdrasil/session_info.rb', line 12

def client_token
  @client_token
end

#profileProfile (readonly)

Information about the currently selected player profile.

Returns:



20
21
22
# File 'lib/lapis/yggdrasil/session_info.rb', line 20

def profile
  @profile
end

Class Method Details

.from_properties(properties) ⇒ SessionInfo

Creates information about an authentication session from response properties.

Parameters:

  • properties (Hash)

    Set of properties.

Options Hash (properties):

  • :clientToken (String)

    Unique ID of the client that performed the authentication.

  • :accessToken (String)

    Unique ID of the authentication session.

  • :selectedProfile (Hash)

    Information about the currently selected player profile.

Returns:

  • (SessionInfo)

    Information about an authentication session pulled from a set of properties.



48
49
50
51
52
53
54
55
56
57
# File 'lib/lapis/yggdrasil/session_info.rb', line 48

def self.from_properties(properties)
  fail ArgumentError, 'Client token is required'     unless properties.key?(:clientToken)
  fail ArgumentError, 'Access token is required'     unless properties.key?(:accessToken)
  fail ArgumentError, 'Selected profile is required' unless properties.key?(:selectedProfile)

  client_token = Uuid.parse(properties[:clientToken])
  access_token = Uuid.parse(properties[:accessToken])
  profile      = Profile.from_properties(properties[:selectedProfile])
  new(client_token, access_token, profile)
end

Instance Method Details

#==(other) ⇒ true, false

Compares this session information to another.

Parameters:

  • other (SessionInfo)

    Session information to compare against.

Returns:

  • (true)

    The session information is identical.

  • (false)

    The session information is different.



36
37
38
39
40
# File 'lib/lapis/yggdrasil/session_info.rb', line 36

def ==(other)
  other.client_token == @client_token &&
      other.access_token == @access_token &&
      other.profile == @profile
end