Class: SelfSDK::Messages::AuthenticationMessage

Inherits:
Base
  • Object
show all
Defined in:
lib/messages/authentication_message.rb

Direct Known Subclasses

AuthenticationReq, AuthenticationResp

Instance Attribute Summary

Attributes inherited from Base

#description, #exp_timeout, #expires, #fields, #from, #from_device, #id, #input, #intermediary, #payload, #status, #sub, #to, #to_device, #typ

Instance Method Summary collapse

Methods inherited from Base

#accepted?, #encrypt_message, #errored?, #initialize, #rejected?, #request, #send_message, #unauthorized?, #validate!

Constructor Details

This class inherits a constructor from SelfSDK::Messages::Base

Instance Method Details

#parse(input, envelope = nil) ⇒ Object

[View source]

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/messages/authentication_message.rb', line 12

def parse(input, envelope=nil)
  @input = input
  @typ = @typ
  @payload = get_payload input
  @id = payload[:cid]
  @from = payload[:iss]
  @to = payload[:sub]
  @audience = payload[:aud]
  @from_device = payload[:device_id]
  @expires = ::Time.parse(payload[:exp])
  @issued = ::Time.parse(payload[:iat])
  @status = payload[:status]
  if envelope
    issuer = envelope.sender.split(":")
    @from_device = issuer.last
  end
end