Class: Owlet::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/owlet/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.key_optsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/owlet/cli.rb', line 6

def self.key_opts
  begin
    require 'openssl'
    if OpenSSL.const_defined?(:PKCS12)
      method_option :key, :required => true, :description => "Private and public key to be used for signing. Must be in PKCS12 format."
    else
      method_option :public, :required => true, :description => "Public key to be used for signing. Must be in PEM format."
      method_option :private, :required => true, :description => "Private key to be used for signing. Must be in PEM format."
    end
  rescue
    raise "OpenSSL support is required."
  end
end

Instance Method Details

#extract(package, dir = ".") ⇒ Object



48
49
50
# File 'lib/owlet/cli.rb', line 48

def extract(package, dir = ".")
  Owlet::Package.extract(package, dir)
end

#package(dir) ⇒ Object



40
41
42
43
44
45
# File 'lib/owlet/cli.rb', line 40

def package(dir)
  pkg = Owlet::Package.create_from_dir(dir)
  if (options[:key] and pkg)
    Owlet::Signer.sign_package(pkg, options[:key])
  end
end

#sign(package) ⇒ Object



23
24
25
# File 'lib/owlet/cli.rb', line 23

def sign(package)
  Owlet::Signer.sign_package(package, options)
end

#verify(package) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/owlet/cli.rb', line 28

def verify(package)
  begin
    Owlet::Signer.verify_package(package)
    puts "Verify OK."
  rescue
    puts "Verify FAILED."
  end
end