Class: OmniAuth::Yubikey::Result
- Inherits:
-
Object
- Object
- OmniAuth::Yubikey::Result
- Defined in:
- lib/omniauth/yubikey/result.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#otp ⇒ Object
readonly
Returns the value of attribute otp.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(otp, response) ⇒ Result
constructor
A new instance of Result.
- #valid? ⇒ Boolean
Constructor Details
#initialize(otp, response) ⇒ Result
Returns a new instance of Result.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/omniauth/yubikey/result.rb', line 9 def initialize(otp, response) @otp = otp @id = otp[0, otp.length-32] if otp.length > 32 response.gsub!("\r\n", "\n") hashes = response.scan(/^h=([\w_\=\/\+]+)$/)[0] statuses = response.scan(/^status=([a-zA-Z0-9_]+)$/)[0] = response.scan(/^t=(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z(\d{4})$/)[0] @hash = hashes[0] if hashes && hashes[0] @status = statuses[0] if statuses && statuses[0] if parts = .map(&:to_i) @timestamp = Time.utc(*parts) end end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
7 8 9 |
# File 'lib/omniauth/yubikey/result.rb', line 7 def hash @hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/omniauth/yubikey/result.rb', line 7 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
7 8 9 |
# File 'lib/omniauth/yubikey/result.rb', line 7 def info @info end |
#otp ⇒ Object (readonly)
Returns the value of attribute otp.
7 8 9 |
# File 'lib/omniauth/yubikey/result.rb', line 7 def otp @otp end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/omniauth/yubikey/result.rb', line 7 def status @status end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/omniauth/yubikey/result.rb', line 7 def @timestamp end |
Instance Method Details
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/omniauth/yubikey/result.rb', line 28 def valid? status == "OK" end |