Class: GPGME::Key
- Inherits:
-
Object
- Object
- GPGME::Key
- Defined in:
- lib/gpgme.rb
Overview
A public or secret key.
Instance Attribute Summary collapse
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
-
#issuer_name ⇒ Object
readonly
Returns the value of attribute issuer_name.
-
#issuer_serial ⇒ Object
readonly
Returns the value of attribute issuer_serial.
-
#keylist_mode ⇒ Object
readonly
Returns the value of attribute keylist_mode.
-
#owner_trust ⇒ Object
readonly
Returns the value of attribute owner_trust.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#subkeys ⇒ Object
readonly
Returns the value of attribute subkeys.
-
#uids ⇒ Object
readonly
Returns the value of attribute uids.
Instance Method Summary collapse
- #capability ⇒ Object
- #inspect ⇒ Object
- #secret? ⇒ Boolean
- #to_s ⇒ Object
- #trust ⇒ Object
- #usable_for?(purposes) ⇒ Boolean
Instance Attribute Details
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
1249 1250 1251 |
# File 'lib/gpgme.rb', line 1249 def chain_id @chain_id end |
#issuer_name ⇒ Object (readonly)
Returns the value of attribute issuer_name.
1249 1250 1251 |
# File 'lib/gpgme.rb', line 1249 def issuer_name @issuer_name end |
#issuer_serial ⇒ Object (readonly)
Returns the value of attribute issuer_serial.
1249 1250 1251 |
# File 'lib/gpgme.rb', line 1249 def issuer_serial @issuer_serial end |
#keylist_mode ⇒ Object (readonly)
Returns the value of attribute keylist_mode.
1248 1249 1250 |
# File 'lib/gpgme.rb', line 1248 def keylist_mode @keylist_mode end |
#owner_trust ⇒ Object (readonly)
Returns the value of attribute owner_trust.
1248 1249 1250 |
# File 'lib/gpgme.rb', line 1248 def owner_trust @owner_trust end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
1248 1249 1250 |
# File 'lib/gpgme.rb', line 1248 def protocol @protocol end |
#subkeys ⇒ Object (readonly)
Returns the value of attribute subkeys.
1250 1251 1252 |
# File 'lib/gpgme.rb', line 1250 def subkeys @subkeys end |
#uids ⇒ Object (readonly)
Returns the value of attribute uids.
1250 1251 1252 |
# File 'lib/gpgme.rb', line 1250 def uids @uids end |
Instance Method Details
#capability ⇒ Object
1259 1260 1261 1262 1263 1264 1265 1266 |
# File 'lib/gpgme.rb', line 1259 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 |
#inspect ⇒ Object
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 |
# File 'lib/gpgme.rb', line 1280 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..strftime('%Y-%m-%d'), trust.inspect, VALIDITY_NAMES[@owner_trust].inspect, capability.inspect, subkeys.inspect, uids.inspect) end |
#secret? ⇒ Boolean
1276 1277 1278 |
# File 'lib/gpgme.rb', line 1276 def secret? @secret == 1 end |
#to_s ⇒ Object
1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 |
# File 'lib/gpgme.rb', line 1296 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..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 |
#trust ⇒ Object
1252 1253 1254 1255 1256 1257 |
# File 'lib/gpgme.rb', line 1252 def trust return :revoked if @revoked == 1 return :expired if @expired == 1 return :disabled if @disabled == 1 return :invalid if @invalid == 1 end |
#usable_for?(purposes) ⇒ Boolean
1268 1269 1270 1271 1272 1273 1274 |
# File 'lib/gpgme.rb', line 1268 def usable_for?(purposes) unless purposes.kind_of? Array purposes = [purposes] end return false if [:revoked, :expired, :disabled, :invalid].include? trust return (purposes - capability).empty? end |