Class: GPGME::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/gpgme.rb

Overview

A public or secret key.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chain_idObject (readonly)

Returns the value of attribute chain_id.



1214
1215
1216
# File 'lib/gpgme.rb', line 1214

def chain_id
  @chain_id
end

#issuer_nameObject (readonly)

Returns the value of attribute issuer_name.



1214
1215
1216
# File 'lib/gpgme.rb', line 1214

def issuer_name
  @issuer_name
end

#issuer_serialObject (readonly)

Returns the value of attribute issuer_serial.



1214
1215
1216
# File 'lib/gpgme.rb', line 1214

def issuer_serial
  @issuer_serial
end

#keylist_modeObject (readonly)

Returns the value of attribute keylist_mode.



1213
1214
1215
# File 'lib/gpgme.rb', line 1213

def keylist_mode
  @keylist_mode
end

#owner_trustObject (readonly)

Returns the value of attribute owner_trust.



1213
1214
1215
# File 'lib/gpgme.rb', line 1213

def owner_trust
  @owner_trust
end

#protocolObject (readonly)

Returns the value of attribute protocol.



1213
1214
1215
# File 'lib/gpgme.rb', line 1213

def protocol
  @protocol
end

#subkeysObject (readonly)

Returns the value of attribute subkeys.



1215
1216
1217
# File 'lib/gpgme.rb', line 1215

def subkeys
  @subkeys
end

#uidsObject (readonly)

Returns the value of attribute uids.



1215
1216
1217
# File 'lib/gpgme.rb', line 1215

def uids
  @uids
end

Instance Method Details

#capabilityObject



1224
1225
1226
1227
1228
1229
1230
1231
# File 'lib/gpgme.rb', line 1224

def capability
  caps = Array.new
  caps << :encrypt if @can_encrypt
  caps << :sign if @can_sign
  caps << :certify if @can_certify
  caps << :authenticate if @can_authenticate
  caps
end

#inspectObject



1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
# File 'lib/gpgme.rb', line 1237

def inspect
  primary_subkey = subkeys[0]
  sprintf("#<#{self.class} %s %4d%c/%s %s trust=%s, owner_trust=%s, \
capability=%s, subkeys=%s, uids=%s>",
          primary_subkey.secret? ? 'sec' : 'pub',
          primary_subkey.length,
          primary_subkey.pubkey_algo_letter,
          primary_subkey.fingerprint[-8 .. -1],
          primary_subkey.timestamp.strftime('%Y-%m-%d'),
          trust.inspect,
          VALIDITY_NAMES[@owner_trust].inspect,
          capability.inspect,
          subkeys.inspect,
          uids.inspect)
end

#secret?Boolean

Returns:



1233
1234
1235
# File 'lib/gpgme.rb', line 1233

def secret?
  @secret == 1
end

#to_sObject



1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
# File 'lib/gpgme.rb', line 1253

def to_s
  primary_subkey = subkeys[0]
  s = sprintf("%s   %4d%c/%s %s\n",
              primary_subkey.secret? ? 'sec' : 'pub',
              primary_subkey.length,
              primary_subkey.pubkey_algo_letter,
              primary_subkey.fingerprint[-8 .. -1],
              primary_subkey.timestamp.strftime('%Y-%m-%d'))
  uids.each do |user_id|
    s << "uid\t\t#{user_id.name} <#{user_id.email}>\n"
  end
  subkeys.each do |subkey|
    s << subkey.to_s
  end
  s
end

#trustObject



1217
1218
1219
1220
1221
1222
# File 'lib/gpgme.rb', line 1217

def trust
  return :revoked if @revoked == 1
  return :expired if @expired == 1
  return :disabled if @disabled == 1
  return :invalid if @invalid == 1
end