Class: Izokatu::ActionCallSelector
- Inherits:
-
Object
- Object
- Izokatu::ActionCallSelector
- Extended by:
- Callable
- Includes:
- Contracts
- Defined in:
- lib/izokatu/action_call_selector.rb
Overview
Izokatu selector of action class to be called
Instance Attribute Summary collapse
-
#action ⇒ Symbol
readonly
Action to execute.
-
#asym_cipher_type ⇒ Symbol
readonly
OpenSSL public key cipher type.
-
#auth_cipher ⇒ Bool
readonly
Status of cipher as authenticated.
-
#ccm_cipher ⇒ Bool
readonly
Equality of cipher mode to CCM.
-
#mode ⇒ Symbol
readonly
Mode of encryption/decryption.
-
#via ⇒ Symbol
readonly
Library used for encryption/decryption.
Instance Method Summary collapse
-
#initialize(via:, mode:, action:, asym_cipher_type:, ccm_cipher:, auth_cipher:) ⇒ ActionCallSelector
constructor
Initializing options for selection of action class.
-
#perform ⇒ Class
Selecting action class for keys generation or encryption/decryption.
-
#select_default_action_call ⇒ Class
private
Selecting action class for encryption/decryption.
-
#select_keys_generation_action_call ⇒ Class
private
Selecting action class for keys generation.
-
#select_openssl_action_call ⇒ Class
private
Selecting action class for Openssl encryption/decryption.
-
#select_rbnacl_action_call ⇒ Class
private
Selecting action class for Rbnacl encryption/decryption.
Methods included from Callable
Constructor Details
#initialize(via:, mode:, action:, asym_cipher_type:, ccm_cipher:, auth_cipher:) ⇒ ActionCallSelector
Initializing options for selection of action class
34 35 36 37 38 39 40 41 |
# File 'lib/izokatu/action_call_selector.rb', line 34 def initialize(via:, mode:, action:, asym_cipher_type:, ccm_cipher:, auth_cipher:) @via = via @mode = mode @action = action @asym_cipher_type = asym_cipher_type @ccm_cipher = ccm_cipher @auth_cipher = auth_cipher end |
Instance Attribute Details
#action ⇒ Symbol (readonly)
Returns action to execute.
15 16 17 |
# File 'lib/izokatu/action_call_selector.rb', line 15 def action @action end |
#asym_cipher_type ⇒ Symbol (readonly)
Returns OpenSSL public key cipher type.
17 18 19 |
# File 'lib/izokatu/action_call_selector.rb', line 17 def asym_cipher_type @asym_cipher_type end |
#auth_cipher ⇒ Bool (readonly)
Returns status of cipher as authenticated.
21 22 23 |
# File 'lib/izokatu/action_call_selector.rb', line 21 def auth_cipher @auth_cipher end |
#ccm_cipher ⇒ Bool (readonly)
Returns equality of cipher mode to CCM.
19 20 21 |
# File 'lib/izokatu/action_call_selector.rb', line 19 def ccm_cipher @ccm_cipher end |
#mode ⇒ Symbol (readonly)
Returns mode of encryption/decryption.
13 14 15 |
# File 'lib/izokatu/action_call_selector.rb', line 13 def mode @mode end |
#via ⇒ Symbol (readonly)
Returns library used for encryption/decryption.
11 12 13 |
# File 'lib/izokatu/action_call_selector.rb', line 11 def via @via end |
Instance Method Details
#perform ⇒ Class
Selecting action class for keys generation or encryption/decryption
49 50 51 |
# File 'lib/izokatu/action_call_selector.rb', line 49 def perform action == :keys_generation ? select_keys_generation_action_call : select_default_action_call end |
#select_default_action_call ⇒ Class (private)
Selecting action class for encryption/decryption
78 79 80 |
# File 'lib/izokatu/action_call_selector.rb', line 78 def select_default_action_call via == :rbnacl ? select_rbnacl_action_call : select_openssl_action_call end |
#select_keys_generation_action_call ⇒ Class (private)
Selecting action class for keys generation
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/izokatu/action_call_selector.rb', line 61 def select_keys_generation_action_call case [via, mode, action, asym_cipher_type, ccm_cipher, auth_cipher] in [:rbnacl, :public_key, :keys_generation, _, _, _] Izokatu::Rbnacl::PublicKey::KeysGenerator in [:openssl, :public_key, :keys_generation, :rsa, _, _] Izokatu::Openssl::PublicKey::RSA::KeysGenerator in [:openssl, :public_key, :keys_generation, :ec, _, _] Izokatu::Openssl::PublicKey::EC::KeysGenerator end end |
#select_openssl_action_call ⇒ Class (private)
Selecting action class for Openssl encryption/decryption
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/izokatu/action_call_selector.rb', line 107 def select_openssl_action_call case [via, mode, action, asym_cipher_type, ccm_cipher, auth_cipher] in [:openssl, :private_key, :encryption, _, false, false] Izokatu::Openssl::PrivateKey::Default::Encrypter in [:openssl, :private_key, :decryption, _, false, false] Izokatu::Openssl::PrivateKey::Default::Decrypter in [:openssl, :private_key, :encryption, _, false, true] Izokatu::Openssl::PrivateKey::Auth::Encrypter in [:openssl, :private_key, :decryption, _, false, true] Izokatu::Openssl::PrivateKey::Auth::Decrypter in [:openssl, :private_key, :encryption, _, true, _] Izokatu::Openssl::PrivateKey::Auth::CCM::Encrypter in [:openssl, :private_key, :decryption, _, true, _] Izokatu::Openssl::PrivateKey::Auth::CCM::Decrypter in [:openssl, :public_key, :encryption, :rsa, _, _] Izokatu::Openssl::PublicKey::RSA::Encrypter in [:openssl, :public_key, :decryption, :rsa, _, _] Izokatu::Openssl::PublicKey::RSA::Decrypter in [:openssl, :public_key, :encryption, :ec, _, _] Izokatu::Openssl::PublicKey::EC::Encrypter in [:openssl, :public_key, :decryption, :ec, _, _] Izokatu::Openssl::PublicKey::EC::Decrypter end end |
#select_rbnacl_action_call ⇒ Class (private)
Selecting action class for Rbnacl encryption/decryption
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/izokatu/action_call_selector.rb', line 88 def select_rbnacl_action_call case [via, mode, action, asym_cipher_type, ccm_cipher, auth_cipher] in [:rbnacl, :private_key, :encryption, _, _, _] Izokatu::Rbnacl::PrivateKey::Encrypter in [:rbnacl, :private_key, :decryption, _, _, _] Izokatu::Rbnacl::PrivateKey::Decrypter in [:rbnacl, :public_key, :encryption, _, _, _] Izokatu::Rbnacl::PublicKey::Encrypter in [:rbnacl, :public_key, :decryption, _, _, _] Izokatu::Rbnacl::PublicKey::Decrypter end end |