Sha256: ea16af711bd215c6b808140933e206f49bcd3baa252e7ca10b49d41c476671b3
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
module HasGlobalSession class Directory attr_reader :authorities, :my_private_key, :my_authority_name def initialize(keystore_directory) certs = Dir[File.join(keystore_directory, '*.pub')] keys = Dir[File.join(keystore_directory, '*.key')] @authorities = {} certs.each do |cert_file| basename = File.basename(cert_file) authority = basename[0...(basename.rindex('.'))] #chop trailing .ext @authorities[authority] = OpenSSL::PKey::RSA.new(File.read(cert_file)) raise TypeError, "Expected #{basename} to contain an RSA public key" unless @authorities[authority].public? end raise ArgumentError, "Excepted 0 or 1 key files, found #{keys.size}" if ![0, 1].include?(keys.size) if (key_file = keys[0]) basename = File.basename(key_file) @my_private_key = OpenSSL::PKey::RSA.new(File.read(key_file)) raise TypeError, "Expected #{basename} to contain an RSA private key" unless @my_private_key.private? @my_authority_name = basename[0...(basename.rindex('.'))] #chop trailing .ext end end def invalidated_session?(uuid) false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
has_global_session-0.8.1 | lib/has_global_session/directory.rb |
has_global_session-0.8.0 | lib/has_global_session/directory.rb |