Class: Izokatu::ActionCallOptionsSelector
- Inherits:
-
Object
- Object
- Izokatu::ActionCallOptionsSelector
- Extended by:
- Callable
- Includes:
- Contracts
- Defined in:
- lib/izokatu/action_call_options_selector.rb
Overview
Izokatu selector of options for selected action class
Constant Summary collapse
- RBNACL_KEY_CLASSES =
RbNaCl public key classes, used for contracts
[ RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey, RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey ].freeze
- OPENSSL_KEY_CLASSES =
OpenSSL public key classes, used for contracts
[ OpenSSL::PKey::RSA, OpenSSL::PKey::EC ].freeze
Instance Attribute Summary collapse
-
#action ⇒ Symbol
readonly
Action to execute.
-
#action_class ⇒ Class
readonly
Selected action class.
-
#auth_data ⇒ String
readonly
Authenticated data.
-
#auth_tag ⇒ String
readonly
Authentication tag.
-
#bit_number ⇒ Integer
readonly
Bit number for OpenSSL public key RSA encryption/decryption.
-
#cipher ⇒ String
readonly
OpenSSL private key cipher.
-
#clear_data_string ⇒ String
readonly
String of clear data for encryption.
-
#ecies_options ⇒ Hash
readonly
Options for OpenSSL public key EC encryption/decryption.
-
#encrypted_data_string ⇒ String
readonly
String of encrypted data for decryption.
-
#key ⇒ String
readonly
Encryption key for private key encryption/decryption.
-
#nonce ⇒ String
readonly
Initialization vector for one-time use.
-
#private_key ⇒ RBNACL_KEY_CLASSES || OPENSSL_KEY_CLASSES
readonly
Private key for public key encryption/decryption.
-
#public_key ⇒ RBNACL_KEY_CLASSES || OPENSSL_KEY_CLASSES
readonly
Public key for public key encryption/decryption.
-
#via ⇒ Symbol
readonly
Library used for encryption/decryption.
Instance Method Summary collapse
-
#initialize(action_class:, options:) ⇒ ActionCallOptionsSelector
constructor
Initializing options for action class.
-
#perform ⇒ Hash
Selecting options for keys generation class or for encryption/decryption class.
-
#select_default_action_options ⇒ Hash
private
Selecting options for encryption/decryption class.
-
#select_keys_generation_action_options ⇒ Hash
private
Selecting options for keys generation class.
-
#select_openssl_action_options ⇒ Hash
private
Selecting options for Openssl encryption/decryption class.
-
#select_rbnacl_action_options ⇒ Hash
private
Selecting options for Rbnacl encryption/decryption class.
Methods included from Callable
Constructor Details
#initialize(action_class:, options:) ⇒ ActionCallOptionsSelector
Initializing options for action class
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/izokatu/action_call_options_selector.rb', line 59 def initialize(action_class:, options:) @action_class = action_class.to_s @action = [:action] @via = [:via] @cipher = [:cipher] @clear_data_string = [:clear_data_string] @encrypted_data_string = [:encrypted_data_string] @public_key = [:public_key] @private_key = [:private_key] @key = [:key] @nonce = [:nonce] @auth_data = [:auth_data] @auth_tag = [:auth_tag] @ecies_options = [:ecies_options] @bit_number = [:bit_number] end |
Instance Attribute Details
#action ⇒ Symbol (readonly)
Returns action to execute.
13 14 15 |
# File 'lib/izokatu/action_call_options_selector.rb', line 13 def action @action end |
#action_class ⇒ Class (readonly)
Returns selected action class.
11 12 13 |
# File 'lib/izokatu/action_call_options_selector.rb', line 11 def action_class @action_class end |
#auth_data ⇒ String (readonly)
Returns authenticated data.
32 33 34 |
# File 'lib/izokatu/action_call_options_selector.rb', line 32 def auth_data @auth_data end |
#auth_tag ⇒ String (readonly)
Returns authentication tag.
34 35 36 |
# File 'lib/izokatu/action_call_options_selector.rb', line 34 def auth_tag @auth_tag end |
#bit_number ⇒ Integer (readonly)
Returns bit number for OpenSSL public key RSA encryption/decryption.
38 39 40 |
# File 'lib/izokatu/action_call_options_selector.rb', line 38 def bit_number @bit_number end |
#cipher ⇒ String (readonly)
also used for OpenSSL public key ec key generation
Returns OpenSSL private key cipher.
18 19 20 |
# File 'lib/izokatu/action_call_options_selector.rb', line 18 def cipher @cipher end |
#clear_data_string ⇒ String (readonly)
Returns string of clear data for encryption.
20 21 22 |
# File 'lib/izokatu/action_call_options_selector.rb', line 20 def clear_data_string @clear_data_string end |
#ecies_options ⇒ Hash (readonly)
Returns options for OpenSSL public key EC encryption/decryption.
36 37 38 |
# File 'lib/izokatu/action_call_options_selector.rb', line 36 def @ecies_options end |
#encrypted_data_string ⇒ String (readonly)
Returns string of encrypted data for decryption.
22 23 24 |
# File 'lib/izokatu/action_call_options_selector.rb', line 22 def encrypted_data_string @encrypted_data_string end |
#key ⇒ String (readonly)
Returns encryption key for private key encryption/decryption.
28 29 30 |
# File 'lib/izokatu/action_call_options_selector.rb', line 28 def key @key end |
#nonce ⇒ String (readonly)
Returns initialization vector for one-time use.
30 31 32 |
# File 'lib/izokatu/action_call_options_selector.rb', line 30 def nonce @nonce end |
#private_key ⇒ RBNACL_KEY_CLASSES || OPENSSL_KEY_CLASSES (readonly)
Returns private key for public key encryption/decryption.
26 27 28 |
# File 'lib/izokatu/action_call_options_selector.rb', line 26 def private_key @private_key end |
#public_key ⇒ RBNACL_KEY_CLASSES || OPENSSL_KEY_CLASSES (readonly)
Returns public key for public key encryption/decryption.
24 25 26 |
# File 'lib/izokatu/action_call_options_selector.rb', line 24 def public_key @public_key end |
#via ⇒ Symbol (readonly)
Returns library used for encryption/decryption.
15 16 17 |
# File 'lib/izokatu/action_call_options_selector.rb', line 15 def via @via end |
Instance Method Details
#perform ⇒ Hash
Selecting options for keys generation class or for encryption/decryption class
82 83 84 |
# File 'lib/izokatu/action_call_options_selector.rb', line 82 def perform action == :keys_generation ? : end |
#select_default_action_options ⇒ Hash (private)
Selecting options for encryption/decryption class
111 112 113 |
# File 'lib/izokatu/action_call_options_selector.rb', line 111 def via == :rbnacl ? : end |
#select_keys_generation_action_options ⇒ Hash (private)
Selecting options for keys generation class
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/izokatu/action_call_options_selector.rb', line 94 def case action_class when 'Izokatu::Rbnacl::PublicKey::KeysGenerator' {} when 'Izokatu::Openssl::PublicKey::RSA::KeysGenerator' { bit_number: bit_number } when 'Izokatu::Openssl::PublicKey::EC::KeysGenerator' { cipher: cipher } end end |
#select_openssl_action_options ⇒ Hash (private)
Selecting options for Openssl encryption/decryption class
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/izokatu/action_call_options_selector.rb', line 154 def case action_class when 'Izokatu::Openssl::PrivateKey::Default::Encrypter' { cipher: cipher, clear_data: clear_data_string } when 'Izokatu::Openssl::PrivateKey::Default::Decrypter' { cipher: cipher, encrypted_data: encrypted_data_string, key: key, nonce: nonce } when 'Izokatu::Openssl::PrivateKey::Auth::Encrypter' { cipher: cipher, clear_data: clear_data_string, auth_data: auth_data } when 'Izokatu::Openssl::PrivateKey::Auth::Decrypter' { cipher: cipher, encrypted_data: encrypted_data_string, key: key, nonce: nonce, auth_data: auth_data, auth_tag: auth_tag } when 'Izokatu::Openssl::PrivateKey::Auth::CCM::Encrypter' { cipher: cipher, clear_data: clear_data_string, auth_data: auth_data } when 'Izokatu::Openssl::PrivateKey::Auth::CCM::Decrypter' { cipher: cipher, encrypted_data: encrypted_data_string, key: key, nonce: nonce, auth_data: auth_data, auth_tag: auth_tag } when 'Izokatu::Openssl::PublicKey::RSA::Encrypter' { clear_data: clear_data_string, public_key: public_key } when 'Izokatu::Openssl::PublicKey::RSA::Decrypter' { private_key: private_key, encrypted_data: encrypted_data_string } when 'Izokatu::Openssl::PublicKey::EC::Encrypter' { clear_data: clear_data_string, public_key: public_key, ecies_options: } when 'Izokatu::Openssl::PublicKey::EC::Decrypter' { private_key: private_key, encrypted_data: encrypted_data_string, ecies_options: } end end |
#select_rbnacl_action_options ⇒ Hash (private)
Selecting options for Rbnacl encryption/decryption class
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/izokatu/action_call_options_selector.rb', line 121 def case action_class when 'Izokatu::Rbnacl::PrivateKey::Encrypter' { auth_data: auth_data, clear_data: clear_data_string } when 'Izokatu::Rbnacl::PrivateKey::Decrypter' { encrypted_data: encrypted_data_string, nonce: nonce, key: key, auth_data: auth_data } when 'Izokatu::Rbnacl::PublicKey::Encrypter' { public_key: public_key, private_key: private_key, clear_data: clear_data_string } when 'Izokatu::Rbnacl::PublicKey::Decrypter' { encrypted_data: encrypted_data_string, nonce: nonce, public_key: public_key, private_key: private_key } end end |