adp-connection 0.1.1
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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +202 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/adp-connection.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/democlient/Gemfile +16 -0
- data/democlient/LICENSE +201 -0
- data/democlient/README.md +2 -0
- data/democlient/Rakefile +9 -0
- data/democlient/adp_connection_ruby.rb +215 -0
- data/democlient/config.ru +24 -0
- data/democlient/config/authorizationcode_config.yml +15 -0
- data/democlient/config/certs/apiclient_iat.key +27 -0
- data/democlient/config/certs/apiclient_iat.pem +45 -0
- data/democlient/config/certs/apiclient_iat.pfx +0 -0
- data/democlient/config/clientcredential_config.yml +11 -0
- data/democlient/public/favicon.ico +0 -0
- data/democlient/public/images/.gitkeep +0 -0
- data/democlient/public/images/ADP_logo_tagline.png +0 -0
- data/democlient/public/images/busy.gif +0 -0
- data/democlient/public/images/hazel_icon.png +0 -0
- data/democlient/public/images/hazel_small.png +0 -0
- data/democlient/public/javascripts/.gitkeep +0 -0
- data/democlient/public/stylesheets/.gitkeep +0 -0
- data/democlient/public/stylesheets/main.css +163 -0
- data/democlient/spec/adp_connection_ruby_spec.rb +14 -0
- data/democlient/spec/spec_helper.rb +23 -0
- data/democlient/views/authorization_code.erb +90 -0
- data/democlient/views/client_credentials.erb +76 -0
- data/democlient/views/layout.erb +40 -0
- data/democlient/views/welcome.erb +34 -0
- data/lib/adp/Product/.gitkeep +0 -0
- data/lib/adp/Product/dto/.gitkeep +0 -0
- data/lib/adp/access_token.rb +44 -0
- data/lib/adp/api_connection.rb +153 -0
- data/lib/adp/api_connection_factory.rb +32 -0
- data/lib/adp/authorization_code_configuration.rb +33 -0
- data/lib/adp/authorization_code_connection.rb +97 -0
- data/lib/adp/client_credential_configuration.rb +18 -0
- data/lib/adp/client_credential_connection.rb +9 -0
- data/lib/adp/connection.rb +16 -0
- data/lib/adp/connection/version.rb +5 -0
- data/lib/adp/connection_configuration.rb +30 -0
- data/lib/adp/connection_exception.rb +12 -0
- metadata +154 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'adp/client_credential_configuration'
|
2
|
+
require 'adp/authorization_code_configuration'
|
3
|
+
require 'adp/client_credential_connection'
|
4
|
+
require 'adp/authorization_code_connection'
|
5
|
+
|
6
|
+
module Adp
|
7
|
+
module Connection
|
8
|
+
class ApiConnectionFactory
|
9
|
+
|
10
|
+
|
11
|
+
# @param [Object] connectionCfg
|
12
|
+
# @return [ADPApiConnection]
|
13
|
+
def self.createConnection( connectionCfg )
|
14
|
+
|
15
|
+
if connectionCfg.nil?
|
16
|
+
raise ConnectionException, "Configuration object expected, none provided"
|
17
|
+
else
|
18
|
+
classname = connectionCfg.class.name.split('::').last
|
19
|
+
|
20
|
+
case classname
|
21
|
+
when "AuthorizationCodeConfiguration"
|
22
|
+
return AuthorizationCodeConnection.new(connectionCfg)
|
23
|
+
when "ClientCredentialConfiguration"
|
24
|
+
return ClientCredentialConnection.new(connectionCfg)
|
25
|
+
else
|
26
|
+
raise ADPConnectionException, "Grant type / Configuration type not implemented. #{connectionCfg.grantType}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'adp/connection_configuration'
|
2
|
+
|
3
|
+
module Adp
|
4
|
+
module Connection
|
5
|
+
|
6
|
+
class AuthorizationCodeConfiguration < ConnectionConfiguration
|
7
|
+
|
8
|
+
attr_accessor :authorizationCode
|
9
|
+
attr_accessor :baseAuthorizationURL
|
10
|
+
attr_accessor :redirectURL
|
11
|
+
attr_accessor :responseType
|
12
|
+
attr_accessor :scope
|
13
|
+
attr_accessor :state
|
14
|
+
|
15
|
+
|
16
|
+
def initialize( config )
|
17
|
+
|
18
|
+
super
|
19
|
+
|
20
|
+
self.authorizationCode = config["authorizationCode"]
|
21
|
+
self.baseAuthorizationURL = config["baseAuthorizationURL"]
|
22
|
+
self.redirectURL = config["redirectURL"]
|
23
|
+
self.responseType = config["responseType"]
|
24
|
+
self.scope = config["scope"]
|
25
|
+
self.state = config["state"]
|
26
|
+
|
27
|
+
self.grantType = "authorization_code"
|
28
|
+
|
29
|
+
self
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'adp/api_connection'
|
3
|
+
|
4
|
+
module Adp
|
5
|
+
module Connection
|
6
|
+
|
7
|
+
class AuthorizationCodeConnection < ApiConnection
|
8
|
+
attr_accessor :state
|
9
|
+
|
10
|
+
def get_authorization_url
|
11
|
+
|
12
|
+
|
13
|
+
if self.connection_configuration.nil?
|
14
|
+
raise ConnectionException, "Config error: Configuration is empty or not found"
|
15
|
+
end
|
16
|
+
if (self.connection_configuration.baseAuthorizationURL.nil?)
|
17
|
+
raise ConnectionException, "Config error: baseAuthorizationURL is empty or not known"
|
18
|
+
end
|
19
|
+
if (self.connection_configuration.clientID.nil?)
|
20
|
+
raise ConnectionException, "Config error: clientID is empty or not known"
|
21
|
+
end
|
22
|
+
if (self.connection_configuration.responseType.nil?)
|
23
|
+
raise ConnectionException, "Config error: responseType is empty or not known"
|
24
|
+
end
|
25
|
+
if (self.connection_configuration.clientSecret.nil?)
|
26
|
+
raise ConnectionException, "Config error: clientSecret is empty or not known"
|
27
|
+
end
|
28
|
+
if (self.connection_configuration.redirectURL.nil?)
|
29
|
+
raise ConnectionException, "Config error: redirectURL is empty or not known"
|
30
|
+
end
|
31
|
+
|
32
|
+
self.state = SecureRandom.uuid
|
33
|
+
|
34
|
+
url = self.connection_configuration.baseAuthorizationURL + '?' + URI.encode_www_form(
|
35
|
+
:client_id => self.connection_configuration.clientID,
|
36
|
+
:response_type => self.connection_configuration.responseType,
|
37
|
+
:redirect_uri => self.connection_configuration.redirectURL,
|
38
|
+
:scope => 'openid',
|
39
|
+
:state => self.state
|
40
|
+
)
|
41
|
+
|
42
|
+
Log.debug("URL was #{url}")
|
43
|
+
return url
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_access_token
|
47
|
+
token = self.access_token;
|
48
|
+
result = nil;
|
49
|
+
|
50
|
+
if is_connected_indicator?
|
51
|
+
|
52
|
+
if self.connection_configuration.nil?
|
53
|
+
raise ConnectionException, "Config error: Configuration is empty or not found"
|
54
|
+
end
|
55
|
+
if (self.connection_configuration.grantType.nil?)
|
56
|
+
raise ConnectionException, "Config error: grantType is empty or not known"
|
57
|
+
end
|
58
|
+
if (self.connection_configuration.redirectURL.nil?)
|
59
|
+
raise ConnectionException, "Config error: redirectURL is empty or not known"
|
60
|
+
end
|
61
|
+
if (self.connection_configuration.clientID.nil?)
|
62
|
+
raise ConnectionException, "Config error: clientID is empty or not known"
|
63
|
+
end
|
64
|
+
if (self.connection_configuration.clientSecret.nil?)
|
65
|
+
raise ConnectionException, "Config error: clientSecret is empty or not known"
|
66
|
+
end
|
67
|
+
if (self.connection_configuration.authorizationCode.nil?)
|
68
|
+
raise ConnectionException, "Config error: authorizationCode is empty or not known"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
Log.debug("connection configutration: #{self.connection_configuration.inspect}")
|
73
|
+
|
74
|
+
data = {
|
75
|
+
"client_id" => self.connection_configuration.clientID,
|
76
|
+
"client_secret" => self.connection_configuration.clientSecret,
|
77
|
+
"grant_type" => self.connection_configuration.grantType,
|
78
|
+
"code" => self.connection_configuration.authorizationCode,
|
79
|
+
"redirect_uri" => self.connection_configuration.redirectURL
|
80
|
+
};
|
81
|
+
|
82
|
+
result = send_web_request(self.connection_configuration.tokenServerURL, data )
|
83
|
+
|
84
|
+
if result["error"].nil? then
|
85
|
+
token = AccessToken.new(result)
|
86
|
+
else
|
87
|
+
self.access_token = nil
|
88
|
+
raise ConnectionException, "Connection error: #{result["error"]} #{result['error_description']}"
|
89
|
+
end
|
90
|
+
|
91
|
+
Log.debug("Results from request was #{result}");
|
92
|
+
|
93
|
+
token
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'adp/connection_configuration'
|
2
|
+
|
3
|
+
module Adp
|
4
|
+
module Connection
|
5
|
+
|
6
|
+
class ClientCredentialConfiguration < ConnectionConfiguration
|
7
|
+
attr_accessor :grantType
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
super
|
11
|
+
|
12
|
+
self.grantType = :client_credentials
|
13
|
+
|
14
|
+
self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'adp/connection/version'
|
2
|
+
require 'adp/access_token'
|
3
|
+
require 'adp/connection_configuration'
|
4
|
+
require 'adp/connection_exception'
|
5
|
+
require 'adp/api_connection'
|
6
|
+
require 'adp/api_connection_factory'
|
7
|
+
require 'adp/authorization_code_configuration'
|
8
|
+
require 'adp/authorization_code_connection'
|
9
|
+
require 'adp/client_credential_configuration'
|
10
|
+
require 'adp/client_credential_connection'
|
11
|
+
|
12
|
+
module Adp
|
13
|
+
module Connection
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Adp
|
2
|
+
module Connection
|
3
|
+
|
4
|
+
class ConnectionConfiguration
|
5
|
+
|
6
|
+
attr_accessor :clientID
|
7
|
+
attr_accessor :clientSecret
|
8
|
+
attr_accessor :sslCertPath
|
9
|
+
attr_accessor :sslKeyPath
|
10
|
+
attr_accessor :sslKeyPass
|
11
|
+
attr_accessor :tokenServerURL
|
12
|
+
attr_accessor :apiRequestURL
|
13
|
+
attr_accessor :accessScope
|
14
|
+
attr_accessor :grantType
|
15
|
+
|
16
|
+
|
17
|
+
def initialize( config )
|
18
|
+
|
19
|
+
self.clientID = config["clientID"]
|
20
|
+
self.clientSecret = config["clientSecret"]
|
21
|
+
self.sslCertPath = config["sslCertPath"]
|
22
|
+
self.sslKeyPath = config["sslKeyPath"]
|
23
|
+
self.sslKeyPass = config["sslKeyPass"]
|
24
|
+
self.tokenServerURL = config["tokenServerURL"]
|
25
|
+
self.apiRequestURL = config["apiRequestURL"]
|
26
|
+
self.accessScope = config["accessScope"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adp-connection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Napier, Junior (CORP)
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: The ADP Client Connection Library is intended to simplify and aid the
|
70
|
+
process of authenticating, authorizing and connecting to the ADP Marketplace API
|
71
|
+
Gateway. The Library includes a sample application that can be run out-of-the-box
|
72
|
+
to connect to the ADP Marketplace API **test** gateway.
|
73
|
+
email:
|
74
|
+
- JuniorNapier@GMail.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
82
|
+
- CODE_OF_CONDUCT.md
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- adp-connection.gemspec
|
88
|
+
- bin/console
|
89
|
+
- bin/setup
|
90
|
+
- democlient/Gemfile
|
91
|
+
- democlient/LICENSE
|
92
|
+
- democlient/README.md
|
93
|
+
- democlient/Rakefile
|
94
|
+
- democlient/adp_connection_ruby.rb
|
95
|
+
- democlient/config.ru
|
96
|
+
- democlient/config/authorizationcode_config.yml
|
97
|
+
- democlient/config/certs/apiclient_iat.key
|
98
|
+
- democlient/config/certs/apiclient_iat.pem
|
99
|
+
- democlient/config/certs/apiclient_iat.pfx
|
100
|
+
- democlient/config/clientcredential_config.yml
|
101
|
+
- democlient/public/favicon.ico
|
102
|
+
- democlient/public/images/.gitkeep
|
103
|
+
- democlient/public/images/ADP_logo_tagline.png
|
104
|
+
- democlient/public/images/busy.gif
|
105
|
+
- democlient/public/images/hazel_icon.png
|
106
|
+
- democlient/public/images/hazel_small.png
|
107
|
+
- democlient/public/javascripts/.gitkeep
|
108
|
+
- democlient/public/stylesheets/.gitkeep
|
109
|
+
- democlient/public/stylesheets/main.css
|
110
|
+
- democlient/spec/adp_connection_ruby_spec.rb
|
111
|
+
- democlient/spec/spec_helper.rb
|
112
|
+
- democlient/views/authorization_code.erb
|
113
|
+
- democlient/views/client_credentials.erb
|
114
|
+
- democlient/views/layout.erb
|
115
|
+
- democlient/views/welcome.erb
|
116
|
+
- lib/adp/Product/.gitkeep
|
117
|
+
- lib/adp/Product/dto/.gitkeep
|
118
|
+
- lib/adp/access_token.rb
|
119
|
+
- lib/adp/api_connection.rb
|
120
|
+
- lib/adp/api_connection_factory.rb
|
121
|
+
- lib/adp/authorization_code_configuration.rb
|
122
|
+
- lib/adp/authorization_code_connection.rb
|
123
|
+
- lib/adp/client_credential_configuration.rb
|
124
|
+
- lib/adp/client_credential_connection.rb
|
125
|
+
- lib/adp/connection.rb
|
126
|
+
- lib/adp/connection/version.rb
|
127
|
+
- lib/adp/connection_configuration.rb
|
128
|
+
- lib/adp/connection_exception.rb
|
129
|
+
homepage: https://github.com/adplabs/adp-connection-ruby
|
130
|
+
licenses:
|
131
|
+
- Apache-2.0
|
132
|
+
metadata:
|
133
|
+
allowed_push_host: https://rubygems.org
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.5.1
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: A library for Ruby that help applications connect to the ADP API Gateway.
|
154
|
+
test_files: []
|