Method: JavaKeystore#initialize

Defined in:
lib/calabash-android/java_keystore.rb

#initialize(location, keystore_alias, password) ⇒ JavaKeystore

Returns a new instance of JavaKeystore.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/calabash-android/java_keystore.rb', line 3

def initialize(location, keystore_alias, password)
  raise "No such file #{location}" unless File.exists?(File.expand_path(location))

  keystore_data = system_with_stdout_on_success(Env.keytool_path, '-list', '-v', '-alias', keystore_alias, '-keystore', location, '-storepass', password, '-J"-Dfile.encoding=utf-8"')
  if keystore_data.nil?
    error = "Could not list certificates in keystore. Probably because the password was incorrect."
    @errors = [{:message => error}]
    log error
    raise error
    #TODO: Handle the case where password is correct but the alias is missing.
  end
  @location = location
  @keystore_alias = keystore_alias
  @password = password
  log "Key store data:"
  log keystore_data
  @fingerprint = extract_md5_fingerprint(keystore_data)
end