cyberark_credential 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cyberark_credential.rb +76 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d1ef342785c0758508a16a2e663e449290598d0c
4
+ data.tar.gz: 078a9d56fcdde00be1047572681a91fca38558f7
5
+ SHA512:
6
+ metadata.gz: 78c741c69065be8f2ff77b1670a22c3bee2b316e294b32eef99487e53b065ac75d58f0a8a3f78a46e633b515bfa061f5f99af8744d96ca3793a79c4cb0ed2e88
7
+ data.tar.gz: 1e86d40e956a04bfefa18a94723fd2bad0bbd3ecad702316104856c741548987cd6a323ab5156d6eaa3421caec0d7e522a81b2c0ab8e69516f1e38584d57a045
@@ -0,0 +1,76 @@
1
+
2
+ # Require the two stdlib classes we need,
3
+ # which aren't included by default
4
+ require "net/http"
5
+ require "uri"
6
+ require "json"
7
+ require "openssl"
8
+
9
+ # The module namespace our classes will live in
10
+ module CyberArk
11
+ # Custom exception class
12
+ class InvalidURLError < StandardError
13
+ end
14
+
15
+ # Our main class definition
16
+ class Credential
17
+
18
+ # Custom getter method for @url class instance variable
19
+ def base_url
20
+ @base_url
21
+ end
22
+
23
+ # Custom setter method for @url class instance variable
24
+ # because we're parsing the url parameter before assigning
25
+ # to @url
26
+ def base_url=(url)
27
+ @base_url = url
28
+ end
29
+
30
+
31
+ def use_ssl
32
+ @use_ssl
33
+ end
34
+
35
+ def use_ssl=(use_ssl)
36
+ @use_ssl = use_ssl
37
+ end
38
+
39
+
40
+ # initialize method
41
+ def initialize(url, use_ssl=false)
42
+
43
+ @base_url = url
44
+ @use_ssl = use_ssl
45
+
46
+ end
47
+
48
+ # Class method to make a GET request
49
+ def get(app_id, query)
50
+ begin
51
+ # Use our @http_object object's request method to call the
52
+ # Net::HTTP::Get class and return the resulting response object
53
+ fullURL = "#{@base_url}/AIMWebService/api/Accounts?AppID=#{app_id}&Query=#{query}"
54
+ parsedURI = URI.parse(fullURL)
55
+ http_object = Net::HTTP.new(parsedURI.host, parsedURI.port)
56
+ http_object.use_ssl = @use_ssl
57
+ http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE
58
+ puts parsedURI.request_uri
59
+ request = http_object.request(Net::HTTP::Get.new(parsedURI.request_uri))
60
+ result = JSON.parse(request.body)
61
+ if result.key?("ErrorCode")
62
+ raise InvalidURLError.new("#{result['ErrorCode']}-#{result['ErrorMsg'}")
63
+ end
64
+ rescue URI::InvalidURIError
65
+ # Raise a custom exception with a more friendly message
66
+ raise InvalidURLError.new("#{fullURL} was not a valid URL.")
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ #puts "initializing"
73
+ #http_requestor = CyberArk::Credential.new("https://192.168.86.162", use_ssl=true)
74
+ #puts "performing GET request"
75
+ #puts "Response code was #{http_requestor.get('Chef_App', query='Safe=Test;Folder=Root;Object=Object')['Content']}"
76
+
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cyberark_credential
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Edward Nunez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: AIM CCP SDK API wrapper to retrieve credentials from CyberArk
14
+ email: edward.nunez@cyberark.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/cyberark_credential.rb
20
+ homepage:
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.6.11
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: AIM CCP SDK API wrapper to retrieve credentials from CyberArk
44
+ test_files: []