Class: OCI::Auth::FileSessionKeySupplier
- Inherits:
-
Object
- Object
- OCI::Auth::FileSessionKeySupplier
- Defined in:
- lib/oci/auth/signers/ephemeral_resource_principal_v21_signer.rb
Overview
FileBasedSessionKeySupplier holds a private key that's loaded (and potentially refreshed) from a file source.
Instance Method Summary collapse
-
#initialize(private_key_file: nil, passphrase_file: nil) ⇒ FileSessionKeySupplier
constructor
A new instance of FileSessionKeySupplier.
- #key_pair ⇒ Object
- #refresh ⇒ Object
Constructor Details
#initialize(private_key_file: nil, passphrase_file: nil) ⇒ FileSessionKeySupplier
Returns a new instance of FileSessionKeySupplier.
229 230 231 232 233 234 235 236 |
# File 'lib/oci/auth/signers/ephemeral_resource_principal_v21_signer.rb', line 229 def initialize(private_key_file: nil, passphrase_file: nil) @private_key_file = private_key_file @passphrase_file = passphrase_file @private_key = nil @public_key = nil @refresh_lock = Mutex.new refresh end |
Instance Method Details
#key_pair ⇒ Object
238 239 240 |
# File 'lib/oci/auth/signers/ephemeral_resource_principal_v21_signer.rb', line 238 def key_pair { 'private_key': @private_key, 'public_key': @public_key } end |
#refresh ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/oci/auth/signers/ephemeral_resource_principal_v21_signer.rb', line 242 def refresh @refresh_lock.lock pass_phrase = nil unless @passphrase_file.nil? pass_phrase = File.read(@passphrase_file) if File.exist?(@passphrase_file) end unless @private_key_file.nil? @private_key = OCI::Auth::Util.load_private_key_from_file(File.(@private_key_file), pass_phrase) @public_key = @private_key.public_key end ensure @refresh_lock.unlock if @refresh_lock.locked? && @refresh_lock.owned? end |