Class: InstAccess::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/inst_access/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_signing_key, raw_encryption_key = nil) ⇒ Config

Returns a new instance of Config.



27
28
29
30
31
32
33
34
35
# File 'lib/inst_access/config.rb', line 27

def initialize(raw_signing_key, raw_encryption_key = nil)
  @signing_key = OpenSSL::PKey::RSA.new(raw_signing_key)
  if raw_encryption_key
    @encryption_key = OpenSSL::PKey::RSA.new(raw_encryption_key)
    raise ArgumentError, 'the encryption key should be a public RSA key' if @encryption_key.private?
  end
rescue OpenSSL::PKey::RSAError => e
  raise ArgumentError, e
end

Instance Attribute Details

#signing_keyObject (readonly)

Returns the value of attribute signing_key.



25
26
27
# File 'lib/inst_access/config.rb', line 25

def signing_key
  @signing_key
end

Instance Method Details

#encryption_keyObject



37
38
39
# File 'lib/inst_access/config.rb', line 37

def encryption_key
  @encryption_key || raise(ConfigError, 'Encryption key is not configured')
end