Class: Aspera::Keychain::MacosSystem
- Inherits:
-
Object
- Object
- Aspera::Keychain::MacosSystem
- Defined in:
- lib/aspera/keychain/macos_security.rb
Instance Method Summary collapse
- #delete(options) ⇒ Object
- #get(options) ⇒ Object
-
#initialize(name = nil, _password = nil) ⇒ MacosSystem
constructor
A new instance of MacosSystem.
- #list ⇒ Object
- #set(options) ⇒ Object
Constructor Details
#initialize(name = nil, _password = nil) ⇒ MacosSystem
Returns a new instance of MacosSystem.
124 125 126 127 |
# File 'lib/aspera/keychain/macos_security.rb', line 124 def initialize(name=nil, _password=nil) @keychain = name.nil? ? MacosSecurity::Keychain.default_keychain : MacosSecurity::Keychain.by_name(name) raise "no such keychain #{name}" if @keychain.nil? end |
Instance Method Details
#delete(options) ⇒ Object
155 156 157 158 159 160 |
# File 'lib/aspera/keychain/macos_security.rb', line 155 def delete() raise 'options shall be Hash' unless .is_a?(Hash) unsupported = .keys - i[label] raise "unsupported options: #{unsupported}" unless unsupported.empty? raise 'delete not implemented, use macos keychain app' end |
#get(options) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/aspera/keychain/macos_security.rb', line 138 def get() raise 'options shall be Hash' unless .is_a?(Hash) unsupported = .keys - i[label] raise "unsupported options: #{unsupported}" unless unsupported.empty? info = @keychain.password(:find, :generic, label: [:label]) raise 'not found' if info.nil? result = .clone result[:secret] = info['password'] result[:description] = info['icmt'] # cspell: disable-line return result end |
#list ⇒ Object
150 151 152 153 |
# File 'lib/aspera/keychain/macos_security.rb', line 150 def list # the only way to list is `dump-keychain` which triggers security alert raise 'list not implemented, use macos keychain app' end |
#set(options) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/aspera/keychain/macos_security.rb', line 129 def set() raise 'options shall be Hash' unless .is_a?(Hash) unsupported = .keys - i[label username password url description] raise "unsupported options: #{unsupported}" unless unsupported.empty? @keychain.password( :add, :generic, service: [:label], account: [:username] || 'none', password: [:password], comment: [:description]) end |