Class: Minecraft::JSONAPIv2::Authorization

Inherits:
Object
  • Object
show all
Defined in:
lib/minecraft_jsonapiv2/authorization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Authorization

Returns a new instance of Authorization.



6
7
8
9
10
11
12
13
14
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 6

def initialize(options={})
    raise "No username given" if options[:user].nil?
    raise "No password given" if options[:password].nil?
    raise "No salt given" if options[:salt].nil?
    @user = options[:user]
    @pass = options[:password]
    @salt = options[:salt]
    @key = nil
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 4

def key
  @key
end

#usernameObject (readonly)

Returns the value of attribute username.



4
5
6
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 4

def username
  @username
end

Instance Method Details

#key_for(method) ⇒ Object



16
17
18
# File 'lib/minecraft_jsonapiv2/authorization.rb', line 16

def key_for(method)
    @key = Digest::SHA256.new.update([@user, method, @pass, @salt].join).to_s
end