Class: SoarAuthenticationToken::TokenValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/soar_authentication_token/token_validator.rb

Constant Summary collapse

DEFAULT_CONFIGURATION =
{
  :mode => 'local',
  :public_key => '',
  :url => ''
}

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ TokenValidator

Returns a new instance of TokenValidator.



12
13
14
15
16
17
# File 'lib/soar_authentication_token/token_validator.rb', line 12

def initialize(configuration)
  @configuration = merge_with_default_configuration(configuration)
  validate_configuration
  @public_key = OpenSSL::PKey::EC.new(@configuration[:public_key])
  @public_key.private_key = nil
end

Instance Method Details

#validate(authentication_token) ⇒ Object



19
20
21
22
# File 'lib/soar_authentication_token/token_validator.rb', line 19

def validate(authentication_token)
  return validate_locally(authentication_token) if 'local' == @configuration[:mode]
  return validate_remotely(authentication_token)
end