class Leeloo::GpgPrivateLocalFileSystemKeystore

Public Class Methods

new(name, path) click to toggle source
# File lib/leeloo/keystore.rb, line 121
def initialize name, path
  super name, path
  FileUtils.mkdir_p "#{@path}/keys"

  @recipients = []
  Dir.glob("#{path}/keys/*") { |key| @recipients << File.basename(key) }
  @recipients.each { |key| GPGME::Key.import(File.open("#{path}/keys/#{key}")) }
end

Public Instance Methods

footprint_of(name) click to toggle source
# File lib/leeloo/keystore.rb, line 144
def footprint_of name
  footprint = super name
  footprint["sign"] = Base64.strict_encode64 GPGME::Crypto.new.sign(footprint["footprint"]).to_s
  footprint
end
init() click to toggle source
Calls superclass method Leeloo::Keystore#init
# File lib/leeloo/keystore.rb, line 130
def init
  super
  GPGME::Key.find(:public, nil, ).each { |key| key.export(:output => File.open("#{path}/keys/#{key.uids.first.email}", "w+")) }
end
secret_from_footprint(footprint) click to toggle source
# File lib/leeloo/keystore.rb, line 150
def secret_from_footprint footprint
  data = GPGME::Crypto.new.verify(Base64.strict_decode64 footprint["sign"]) { |signature| signature.valid? }
  if data.read == footprint["footprint"]
    super footprint
  else
    raise "signature is not valid"
  end
end
secret_from_name(name) click to toggle source
# File lib/leeloo/keystore.rb, line 140
def secret_from_name name
  secret_of "#{path}/secrets/#{name}.gpg"
end
secret_of(path) click to toggle source
# File lib/leeloo/keystore.rb, line 135
def secret_of path
  name = path.gsub("#{@path}/secrets/", "").gsub(".gpg", "")
  GpgLocalFileSystemSecret.new path, name, @recipients
end