Module: StrongKeyLite::API
- Included in:
- StrongKeyLite
- Defined in:
- lib/skles_api.rb
Overview
Module included into StrongKeyLite with higher-level API actions.
Instance Method Summary (collapse)
-
- (String) decrypt(token)
Retrieves a credit card number (or any other encrypted content) from the vault using a ciphered token generated by a call to #encrypt.
-
- (true, false) delete(token)
Removes a credit card number (or any other encrypted content) from the vault.
-
- (String) encrypt(plaintext)
Stores a credit card number (or any other plain text content) to the vault and returns an obscured token for later retrieval.
-
- (Hash) ping
Pings the service and returns information about its health.
-
- (String?) search(plaintext)
Determines if a credit card number (or any other plain text content) is stored in the vault.
Instance Method Details
- (String) decrypt(token)
Retrieves a credit card number (or any other encrypted content) from the vault using a ciphered token generated by a call to #encrypt.
87 88 89 |
# File 'lib/skles_api.rb', line 87 def decrypt(token) call(:decrypt, token: token)[:decrypt_response][:return] end |
- (true, false) delete(token)
Removes a credit card number (or any other encrypted content) from the vault.
98 99 100 |
# File 'lib/skles_api.rb', line 98 def delete(token) call(:delete, token: token)[:delete_response][:return] end |
- (String) encrypt(plaintext)
Stores a credit card number (or any other plain text content) to the vault and returns an obscured token for later retrieval.
77 78 79 |
# File 'lib/skles_api.rb', line 77 def encrypt(plaintext) call(:encrypt, plaintext: plaintext)[:encrypt_response][:return] end |
- (Hash) ping
Pings the service and returns information about its health. You must have a user set for the @:ping@ API action.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/skles_api.rb', line 31 def ping msg = call(:ping)[:ping_response][:return] info = Hash.new msg.each_line do |line| if line =~ /^SKLES (.+?) \(Build (\d+)\)$/ info[:version] = $1 info[:build] = $2.to_i elsif line =~ /^Hostname: (.+?)$/ then info[:hostname] = $1 elsif line =~ /^Current time: (.+?)$/ then info[:current_time] = Time.parse($1) elsif line =~ /^Up since: (.+?)$/ then info[:up_since] = Time.parse($1) elsif line =~ /^Well-known PAN: (\d+?)$/ then info[:well_known_pan] = $1.to_i elsif line =~ /^ENC: (\d+)\/(\d+)$/ then info[:encryptions_since_startup] = $1.to_i info[:encryptions_total] = $2.to_i elsif line =~ /^DEC: (\d+)\/(\d+)$/ then info[:decryptions_since_startup] = $1.to_i info[:decryptions_total] = $2.to_i elsif line =~ /^DEL: (\d+)\/(\d+)$/ then info[:deletions_since_startup] = $1.to_i info[:deletions_total] = $2.to_i elsif line =~ /^SRC: (\d+)\/(\d+)$/ then info[:searches_since_startup] = $1.to_i info[:searches_total] = $2.to_i elsif line =~ /^BAT: (\d+)\/(\d+)$/ then info[:batch_operations_since_startup] = $1.to_i info[:batch_operations_total] = $2.to_i elsif line =~ /SKLES Domain (\d+) is (.+?)$/ then info[:domain_id] = $1.to_i end end return info end |
- (String?) search(plaintext)
Determines if a credit card number (or any other plain text content) is stored in the vault. If so, returns its token.
109 110 111 |
# File 'lib/skles_api.rb', line 109 def search(plaintext) call(:search, plaintext: plaintext)[:search_response][:return] end |