Class: Akami::WSSE::Certs

Inherits:
Object
  • Object
show all
Defined in:
lib/akami/wsse/certs.rb

Overview

Contains certs for WSSE::Signature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(certs = {}) ⇒ Certs

Returns a new instance of Certs.



6
7
8
9
10
# File 'lib/akami/wsse/certs.rb', line 6

def initialize(certs = {})
  certs.each do |key, value|
    self.send :"#{key}=", value
  end
end

Instance Attribute Details

#cert_fileObject

Returns the value of attribute cert_file.



12
13
14
# File 'lib/akami/wsse/certs.rb', line 12

def cert_file
  @cert_file
end

#cert_stringObject

Returns the value of attribute cert_string.



12
13
14
# File 'lib/akami/wsse/certs.rb', line 12

def cert_string
  @cert_string
end

#private_key_fileObject

Returns the value of attribute private_key_file.



12
13
14
# File 'lib/akami/wsse/certs.rb', line 12

def private_key_file
  @private_key_file
end

#private_key_passwordObject

Returns the value of attribute private_key_password.



12
13
14
# File 'lib/akami/wsse/certs.rb', line 12

def private_key_password
  @private_key_password
end

#private_key_stringObject

Returns the value of attribute private_key_string.



12
13
14
# File 'lib/akami/wsse/certs.rb', line 12

def private_key_string
  @private_key_string
end

Instance Method Details

#certObject

Returns an OpenSSL::X509::Certificate for the cert_string or cert_file.



15
16
17
18
19
20
21
22
# File 'lib/akami/wsse/certs.rb', line 15

def cert
  @cert ||=
    if !cert_string.nil?
      OpenSSL::X509::Certificate.new(cert_string)
    elsif !cert_file.nil?
      OpenSSL::X509::Certificate.new(File.read(cert_file))
    end
end

#private_keyObject

Returns an OpenSSL::PKey::RSA for the private_key_string or private_key_file.



25
26
27
28
29
30
31
32
# File 'lib/akami/wsse/certs.rb', line 25

def private_key
  @private_key ||=
    if !private_key_string.nil?
      OpenSSL::PKey::RSA.new(private_key_string, private_key_password)
    elsif !private_key_file.nil?
      OpenSSL::PKey::RSA.new(File.read(private_key_file), private_key_password)
    end
end