class VIISP::Auth::Configuration

Constants

CERTS_PATH
DEFAULT_ATTRIBUTES
DEFAULT_OPEN_TIMEOUT
DEFAULT_PROVIDERS
DEFAULT_READ_TIMEOUT
DEFAULT_USER_INFORMATION
PRODUCTION_ENDPOINT
PRODUCTION_PORTAL_ENDPOINT
TEST_ENDPOINT
TEST_PID
TEST_PORTAL_ENDPOINT

Attributes

attributes[RW]
endpoint[W]
open_timeout[RW]
pid[W]
portal_endpoint[W]
postback_url[W]
private_key[W]
providers[RW]
read_timeout[RW]
service_cert[W]
test[W]
user_information[RW]

Public Class Methods

new() click to toggle source
# File lib/viisp/auth/configuration.rb, line 62
def initialize
  @providers = DEFAULT_PROVIDERS
  @attributes = DEFAULT_ATTRIBUTES
  @user_information = DEFAULT_USER_INFORMATION

  @open_timeout = DEFAULT_OPEN_TIMEOUT
  @read_timeout = DEFAULT_READ_TIMEOUT
end

Public Instance Methods

endpoint() click to toggle source
# File lib/viisp/auth/configuration.rb, line 81
def endpoint
  return @endpoint if @endpoint
  return TEST_ENDPOINT if test?
  PRODUCTION_ENDPOINT
end
pid() click to toggle source
# File lib/viisp/auth/configuration.rb, line 71
def pid
  return @pid if @pid
  return TEST_PID if test?
  error('pid not configured')
end
portal_endpoint() click to toggle source
# File lib/viisp/auth/configuration.rb, line 87
def portal_endpoint
  return @portal_endpoint if @portal_endpoint
  return TEST_PORTAL_ENDPOINT if test?
  PRODUCTION_PORTAL_ENDPOINT
end
postback_url() click to toggle source
# File lib/viisp/auth/configuration.rb, line 77
def postback_url
  @postback_url || error('postback_url not configured')
end
private_key() click to toggle source
# File lib/viisp/auth/configuration.rb, line 93
def private_key
  return @private_key if @private_key
  return test_private_key if test?
  error('private key not configured')
end
service_cert() click to toggle source
# File lib/viisp/auth/configuration.rb, line 99
def service_cert
  @service_cert || builtin_service_cert
end
test?() click to toggle source
# File lib/viisp/auth/configuration.rb, line 103
def test?
  @test
end

Private Instance Methods

builtin_service_cert() click to toggle source
# File lib/viisp/auth/configuration.rb, line 109
def builtin_service_cert
  @builtin_service_cert ||= OpenSSL::X509::Certificate.new(
    read_cert('epaslaugos_ident.crt')
  )
end
error(message) click to toggle source
# File lib/viisp/auth/configuration.rb, line 126
def error(message)
  raise(ConfigurationError, message)
end
read_cert(filename) click to toggle source
# File lib/viisp/auth/configuration.rb, line 121
def read_cert(filename)
  path = File.join(CERTS_PATH, filename)
  File.read(path)
end
test_private_key() click to toggle source
# File lib/viisp/auth/configuration.rb, line 115
def test_private_key
  @test_private_key ||= OpenSSL::PKey::RSA.new(
    read_cert('testKey.pem')
  )
end