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.



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

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

Instance Attribute Details

#cert_fileObject

Returns the value of attribute cert_file.



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

def cert_file
  @cert_file
end

#cert_stringObject

Returns the value of attribute cert_string.



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

def cert_string
  @cert_string
end

#private_key_fileObject

Returns the value of attribute private_key_file.



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

def private_key_file
  @private_key_file
end

#private_key_passwordObject

Returns the value of attribute private_key_password.



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

def private_key_password
  @private_key_password
end

#private_key_stringObject

Returns the value of attribute private_key_string.



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

def private_key_string
  @private_key_string
end

Instance Method Details

#certObject

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



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

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.



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

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