Class: OsCtld::SendReceive::KeyChain::Key
- Inherits:
-
Object
- Object
- OsCtld::SendReceive::KeyChain::Key
- Defined in:
- lib/osctld/send_receive/key_chain.rb
Instance Attribute Summary collapse
-
#ctid ⇒ Object
readonly
Returns the value of attribute ctid.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#in_use ⇒ Object
Returns the value of attribute in_use.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#passphrase ⇒ Object
readonly
Returns the value of attribute passphrase.
-
#pubkey ⇒ Object
readonly
Returns the value of attribute pubkey.
-
#single_use ⇒ Object
readonly
Returns the value of attribute single_use.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
- #in_use? ⇒ Boolean
-
#initialize(name, pubkey, opts = {}) ⇒ Key
constructor
A new instance of Key.
- #pubkey_hash ⇒ Object
- #single_use? ⇒ Boolean
Constructor Details
#initialize(name, pubkey, opts = {}) ⇒ Key
Returns a new instance of Key.
23 24 25 26 27 28 29 30 31 |
# File 'lib/osctld/send_receive/key_chain.rb', line 23 def initialize(name, pubkey, opts = {}) @name = name @pubkey = pubkey @from = opts[:from] && opts[:from].split(',') @ctid = opts[:ctid] @passphrase = opts[:passphrase] @single_use = opts[:single_use] @in_use = opts[:in_use] || false end |
Instance Attribute Details
#ctid ⇒ Object (readonly)
Returns the value of attribute ctid.
20 21 22 |
# File 'lib/osctld/send_receive/key_chain.rb', line 20 def ctid @ctid end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
20 21 22 |
# File 'lib/osctld/send_receive/key_chain.rb', line 20 def from @from end |
#in_use ⇒ Object
Returns the value of attribute in_use.
21 22 23 |
# File 'lib/osctld/send_receive/key_chain.rb', line 21 def in_use @in_use end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/osctld/send_receive/key_chain.rb', line 20 def name @name end |
#passphrase ⇒ Object (readonly)
Returns the value of attribute passphrase.
20 21 22 |
# File 'lib/osctld/send_receive/key_chain.rb', line 20 def passphrase @passphrase end |
#pubkey ⇒ Object (readonly)
Returns the value of attribute pubkey.
20 21 22 |
# File 'lib/osctld/send_receive/key_chain.rb', line 20 def pubkey @pubkey end |
#single_use ⇒ Object (readonly)
Returns the value of attribute single_use.
20 21 22 |
# File 'lib/osctld/send_receive/key_chain.rb', line 20 def single_use @single_use end |
Class Method Details
.load(hash) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/osctld/send_receive/key_chain.rb', line 8 def self.load(hash) new( hash['name'], hash['pubkey'], from: hash['from'], ctid: hash['ctid'], passphrase: hash['passphrase'], single_use: hash['single_use'], in_use: hash['in_use'] ) end |
Instance Method Details
#dump ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/osctld/send_receive/key_chain.rb', line 45 def dump { 'name' => name, 'pubkey' => pubkey, 'from' => from && from.join(','), 'ctid' => ctid, 'passphrase' => passphrase, 'single_use' => single_use, 'in_use' => in_use } end |
#in_use? ⇒ Boolean
37 38 39 |
# File 'lib/osctld/send_receive/key_chain.rb', line 37 def in_use? in_use end |
#pubkey_hash ⇒ Object
41 42 43 |
# File 'lib/osctld/send_receive/key_chain.rb', line 41 def pubkey_hash Digest::SHA256.hexdigest(pubkey) end |
#single_use? ⇒ Boolean
33 34 35 |
# File 'lib/osctld/send_receive/key_chain.rb', line 33 def single_use? single_use end |