Class: SafeNet::Cipher
- Inherits:
-
Object
- Object
- SafeNet::Cipher
- Defined in:
- lib/safenet.rb
Instance Method Summary collapse
- #drop_handle(handle_id) ⇒ Object
- #get_handle(enc_type = 'PLAIN', sym_key_handle = nil) ⇒ Object
-
#initialize(client_obj) ⇒ Cipher
constructor
A new instance of Cipher.
Constructor Details
#initialize(client_obj) ⇒ Cipher
Returns a new instance of Cipher.
1196 1197 1198 |
# File 'lib/safenet.rb', line 1196 def initialize(client_obj) @client = client_obj end |
Instance Method Details
#drop_handle(handle_id) ⇒ Object
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 |
# File 'lib/safenet.rb', line 1215 def drop_handle(handle_id) # entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/cipher-opts/#{handle_id}" # api call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Delete.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}" }) res = http.request(req) res.code == "200" ? true : JSON.parse(res.body) end |
#get_handle(enc_type = 'PLAIN', sym_key_handle = nil) ⇒ Object
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 |
# File 'lib/safenet.rb', line 1200 def get_handle(enc_type = 'PLAIN', sym_key_handle = nil) # Entry point url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/cipher-opts/#{enc_type}" url << "/#{sym_key_handle}?" if sym_key_handle # API call uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path, { 'Authorization' => "Bearer #{@client.key_helper.get_valid_token()}" }) res = http.request(req) res.code == "200" ? JSON.parse(res.body)["handleId"] : JSON.parse(res.body) end |