class Virgil::SDK::HighLevel::VirgilKeyManager
this class provides a list of methods to generate the VirgilKey
and further them storage in secure place.
Attributes
context[R]
Public Class Methods
new(context)
click to toggle source
# File lib/virgil/sdk/high_level/virgil_key_manager.rb, line 42 def initialize(context) @context = context end
Public Instance Methods
delete(key_name)
click to toggle source
Remove the VirgilKey
from current storage by specified key name.
Args:
key_name: The name of the key.
Raises:
KeyEntryNotFoundException: if key storage doesn't have item with such name ArgumentError: key_name is not valid if key_name is nil KeyStorageException: Destination folder doesn't exist or you don't have permission to write there
# File lib/virgil/sdk/high_level/virgil_key_manager.rb, line 97 def delete(key_name) raise ArgumentError.new("key_name is not valid") if key_name.nil? context.key_storage.delete(key_name) end
generate()
click to toggle source
Generates a new VirgilKey
with default parameters.
# File lib/virgil/sdk/high_level/virgil_key_manager.rb, line 48 def generate key_pair = context.crypto.generate_keys() VirgilKey.new(context, key_pair.private_key) end
import(buffer, password=nil)
click to toggle source
Imports the VirgilKey
from buffer.
Args:
buffer: The buffer with Key password: The Key password
# File lib/virgil/sdk/high_level/virgil_key_manager.rb, line 82 def import(buffer, password=nil) private_key = context.crypto.import_private_key(buffer.bytes, password) VirgilKey.new(context, private_key) end
load(key_name, key_password=nil)
click to toggle source
Loads the VirgilKey
from current storage by specified key name.
Args:
key_name: The name of the key. key_password: The key password.
Returns:
An instance of VirgilKey class
Raises:
KeyEntryNotFoundException: if key storage doesn't have item with such name ArgumentError: key_name is not valid if key_name is nil KeyStorageException: Destination folder doesn't exist or you don't have permission to write there
# File lib/virgil/sdk/high_level/virgil_key_manager.rb, line 67 def load(key_name, key_password=nil) raise ArgumentError.new("key_name is not valid") if key_name.nil? storage_item = context.key_storage.load(key_name) private_key = context.crypto.import_private_key(storage_item.data, key_password) VirgilKey.new(context, private_key) end