authlete 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,181 +1,181 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2015 Authlete, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
-
18
- require 'set'
19
-
20
-
21
- module Authlete
22
- module Model
23
- class ClientList
24
- # The start index (inclusive) of the clients in this list.
25
- attr_accessor :start
26
-
27
- # The end index (exclusive) of the clients in this list.
28
- attr_accessor :end
29
-
30
- # The total count of clients.
31
- attr_accessor :totalCount
32
- alias_method :total_count, :totalCount
33
- alias_method :total_count=, :totalCount=
34
-
35
- # The list of clients.
36
- attr_accessor :clients
37
-
38
- private
39
-
40
- # Integer attributes.
41
- INTEGER_ATTRIBUTES = ::Set.new([:start, :end, :totalCount])
42
-
43
- # Mapping from snake cases to camel cases.
44
- SNAKE_TO_CAMEL = { :total_count => :totalCount }
45
-
46
- # The constructor
47
- def initialize(hash = nil)
48
- # Set default values to integer attributes.
49
- INTEGER_ATTRIBUTES.each do |attr|
50
- send("#{attr}=", 0)
51
- end
52
-
53
- @clients = nil
54
-
55
- # Set attribute values using the given hash.
56
- authlete_model_clientList_update(hash)
57
- end
58
-
59
- def authlete_model_clientList_to_key(key)
60
- key = key.to_sym
61
-
62
- # Convert snakecase to camelcase, if necessary.
63
- if SNAKE_TO_CAMEL.has_key?(key)
64
- key = SNAKE_TO_CAMEL[key]
65
- end
66
-
67
- return key
68
- end
69
-
70
- def authlete_model_clientList_simple_attribute?(key)
71
- INTEGER_ATTRIBUTES.include?(key)
72
- end
73
-
74
- def authlete_model_clientList_update(hash)
75
- if hash.nil?
76
- return
77
- end
78
-
79
- hash.each do |key, value|
80
- key = authlete_model_clientList_to_key(key)
81
-
82
- # If the attribute is a simple one.
83
- if authlete_model_clientList_simple_attribute?(key)
84
- send("#{key}=", value)
85
- next
86
- end
87
-
88
- if key == :clients
89
- # The attribute 'clients'.
90
- @clients = authlete_model_clientList_parse_array(value) do |element|
91
- Authlete::Model::Client.parse(element)
92
- end
93
- end
94
- end
95
-
96
- return self
97
- end
98
-
99
- def authlete_model_clientList_parse_array(array)
100
- if array.nil? or (array.kind_of?(Array) == false) or (array.length == 0)
101
- return nil
102
- end
103
-
104
- elements = []
105
-
106
- array.each do |element|
107
- parsed_element = yield(element)
108
-
109
- if parsed_element.nil? == false
110
- elements.push(parsed_element)
111
- end
112
- end
113
-
114
- if elements.length == 0
115
- return nil
116
- end
117
-
118
- return elements
119
- end
120
-
121
- public
122
-
123
- # Construct an instance from the given hash.
124
- #
125
- # If the given argument is nil or is not a Hash, nil is returned.
126
- # Otherwise, ClientList.new(hash) is returned.
127
- def self.parse(hash)
128
- if hash.nil? or (hash.kind_of?(Hash) == false)
129
- return nil
130
- end
131
-
132
- return ClientList.new(hash)
133
- end
134
-
135
- # Set attribute values using the given hash.
136
- def update(hash)
137
- authlete_model_clientList_update(hash)
138
- end
139
-
140
- # Convert this object into a hash.
141
- def to_hash
142
- hash = {}
143
-
144
- instance_variables.each do |var|
145
- key = var.to_s.delete("@").to_sym
146
- val = instance_variable_get(var)
147
-
148
- if authlete_model_clientList_simple_attribute?(key) or val.nil?
149
- hash[key] = val
150
- elsif val.kind_of?(Array)
151
- hash[key] = val.map {|element| element.to_hash}
152
- end
153
- end
154
-
155
- return hash
156
- end
157
-
158
- def [](key)
159
- key = authlete_model_clientList_to_key(key)
160
-
161
- if respond_to?(key)
162
- return send(key)
163
- else
164
- return nil
165
- end
166
- end
167
-
168
- def []=(key, value)
169
- key = authlete_model_clientList_to_key(key)
170
- method = "#{key}="
171
-
172
- if respond_to?(method)
173
- return send(method, value)
174
- else
175
- return nil
176
- end
177
- end
178
- end
179
- end
180
- end
181
-
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2015 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ class ClientList
24
+ # The start index (inclusive) of the clients in this list.
25
+ attr_accessor :start
26
+
27
+ # The end index (exclusive) of the clients in this list.
28
+ attr_accessor :end
29
+
30
+ # The total count of clients.
31
+ attr_accessor :totalCount
32
+ alias_method :total_count, :totalCount
33
+ alias_method :total_count=, :totalCount=
34
+
35
+ # The list of clients.
36
+ attr_accessor :clients
37
+
38
+ private
39
+
40
+ # Integer attributes.
41
+ INTEGER_ATTRIBUTES = ::Set.new([:start, :end, :totalCount])
42
+
43
+ # Mapping from snake cases to camel cases.
44
+ SNAKE_TO_CAMEL = { :total_count => :totalCount }
45
+
46
+ # The constructor
47
+ def initialize(hash = nil)
48
+ # Set default values to integer attributes.
49
+ INTEGER_ATTRIBUTES.each do |attr|
50
+ send("#{attr}=", 0)
51
+ end
52
+
53
+ @clients = nil
54
+
55
+ # Set attribute values using the given hash.
56
+ authlete_model_clientList_update(hash)
57
+ end
58
+
59
+ def authlete_model_clientList_to_key(key)
60
+ key = key.to_sym
61
+
62
+ # Convert snakecase to camelcase, if necessary.
63
+ if SNAKE_TO_CAMEL.has_key?(key)
64
+ key = SNAKE_TO_CAMEL[key]
65
+ end
66
+
67
+ return key
68
+ end
69
+
70
+ def authlete_model_clientList_simple_attribute?(key)
71
+ INTEGER_ATTRIBUTES.include?(key)
72
+ end
73
+
74
+ def authlete_model_clientList_update(hash)
75
+ if hash.nil?
76
+ return
77
+ end
78
+
79
+ hash.each do |key, value|
80
+ key = authlete_model_clientList_to_key(key)
81
+
82
+ # If the attribute is a simple one.
83
+ if authlete_model_clientList_simple_attribute?(key)
84
+ send("#{key}=", value)
85
+ next
86
+ end
87
+
88
+ if key == :clients
89
+ # The attribute 'clients'.
90
+ @clients = authlete_model_clientList_parse_array(value) do |element|
91
+ Authlete::Model::Client.parse(element)
92
+ end
93
+ end
94
+ end
95
+
96
+ return self
97
+ end
98
+
99
+ def authlete_model_clientList_parse_array(array)
100
+ if array.nil? or (array.kind_of?(Array) == false) or (array.length == 0)
101
+ return nil
102
+ end
103
+
104
+ elements = []
105
+
106
+ array.each do |element|
107
+ parsed_element = yield(element)
108
+
109
+ if parsed_element.nil? == false
110
+ elements.push(parsed_element)
111
+ end
112
+ end
113
+
114
+ if elements.length == 0
115
+ return nil
116
+ end
117
+
118
+ return elements
119
+ end
120
+
121
+ public
122
+
123
+ # Construct an instance from the given hash.
124
+ #
125
+ # If the given argument is nil or is not a Hash, nil is returned.
126
+ # Otherwise, ClientList.new(hash) is returned.
127
+ def self.parse(hash)
128
+ if hash.nil? or (hash.kind_of?(Hash) == false)
129
+ return nil
130
+ end
131
+
132
+ return ClientList.new(hash)
133
+ end
134
+
135
+ # Set attribute values using the given hash.
136
+ def update(hash)
137
+ authlete_model_clientList_update(hash)
138
+ end
139
+
140
+ # Convert this object into a hash.
141
+ def to_hash
142
+ hash = {}
143
+
144
+ instance_variables.each do |var|
145
+ key = var.to_s.delete("@").to_sym
146
+ val = instance_variable_get(var)
147
+
148
+ if authlete_model_clientList_simple_attribute?(key) or val.nil?
149
+ hash[key] = val
150
+ elsif val.kind_of?(Array)
151
+ hash[key] = val.map {|element| element.to_hash}
152
+ end
153
+ end
154
+
155
+ return hash
156
+ end
157
+
158
+ def [](key)
159
+ key = authlete_model_clientList_to_key(key)
160
+
161
+ if respond_to?(key)
162
+ return send(key)
163
+ else
164
+ return nil
165
+ end
166
+ end
167
+
168
+ def []=(key, value)
169
+ key = authlete_model_clientList_to_key(key)
170
+ method = "#{key}="
171
+
172
+ if respond_to?(method)
173
+ return send(method, value)
174
+ else
175
+ return nil
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
181
+
@@ -1,492 +1,492 @@
1
- # :nodoc:
2
- #
3
- # Copyright (C) 2015 Authlete, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
-
18
- require 'set'
19
-
20
-
21
- module Authlete
22
- module Model
23
- class Client
24
- # The sequential number of the client application. (Integer)
25
- attr_accessor :number
26
-
27
- # The sequential number of the service of the client application.
28
- # (Integer)
29
- attr_accessor :serviceNumber
30
- alias_method :service_number, :serviceNumber
31
- alias_method :service_number=, :serviceNumber=
32
-
33
- # The developer of the client application. (String)
34
- attr_accessor :developer
35
-
36
- # The client ID. (Integer)
37
- attr_accessor :clientId
38
- alias_method :client_id, :clientId
39
- alias_method :client_id=, :clientId=
40
-
41
- # The client secret. (String)
42
- attr_accessor :clientSecret
43
- alias_method :client_secret, :clientSecret
44
- alias_method :client_secret=, :clientSecret=
45
-
46
- # The client type. (String)
47
- attr_accessor :clientType
48
- alias_method :client_type, :clientType
49
- alias_method :client_type=, :clientType=
50
-
51
- # Redirect URIs that the client application uses to receive a response
52
- # from the authorization endpoint. (URI array)
53
- attr_accessor :redirectUris
54
- alias_method :redirect_uris, :redirectUris
55
- alias_method :redirect_uris=, :redirectUris=
56
-
57
- # A string array of response types which the client application declares
58
- # that it will restrict itself to using (String array)
59
- attr_accessor :responseTypes
60
- alias_method :response_types, :responseTypes
61
- alias_method :response_types=, :responseTypes=
62
-
63
- # A string array of grant types which the client application declares
64
- # that it will restrict itself to using. (String array)
65
- attr_accessor :grantTypes
66
- alias_method :grant_types, :grantTypes
67
- alias_method :grant_types=, :grantTypes=
68
-
69
- # The application type. (String)
70
- attr_accessor :applicationType
71
- alias_method :application_type, :applicationType
72
- alias_method :application_type=, :applicationType=
73
-
74
- # An array of email addresses of people responsible for the client application.
75
- # (String array)
76
- attr_accessor :contacts
77
-
78
- # The name of the client application. (String)
79
- attr_accessor :clientName
80
- alias_method :client_name, :clientName
81
- alias_method :client_name=, :clientName=
82
-
83
- # Client names with language tags. (TaggedValue array)
84
- attr_accessor :clientNames
85
- alias_method :client_names, :clientNames
86
- alias_method :client_names=, :clientNames=
87
-
88
- # The URL pointing to the logo image of the client application. (URI)
89
- attr_accessor :logoUri
90
- alias_method :logo_uri, :logoUri
91
- alias_method :logo_uri=, :logoUri=
92
-
93
- # Logo image URLs with language tags. (TaggedValue array)
94
- attr_accessor :logoUris
95
- alias_method :logo_uris, :logoUris
96
- alias_method :logo_uris=, :logoUris=
97
-
98
- # The URL pointing to the home page of the client application. (URI)
99
- attr_accessor :clientUri
100
- alias_method :client_uri, :clientUri
101
- alias_method :client_uri=, :clientUri=
102
-
103
- # Home page URLs with language tags. (TaggedValue array)
104
- attr_accessor :clientUris
105
- alias_method :client_uris, :clientUris
106
- alias_method :client_uris=, :clientUris=
107
-
108
- # The URL pointing to the page which describes the policy
109
- # as to how end-users' profile data are used. (URI)
110
- attr_accessor :policyUri
111
- alias_method :policy_uri, :policyUri
112
- alias_method :policy_uri=, :policyUri=
113
-
114
- # URLs of policy pages with language tags. (TaggedValue array)
115
- attr_accessor :policyUris
116
- alias_method :policy_uris, :policyUris
117
- alias_method :policy_uris=, :policyUris=
118
-
119
- # The URL pointing to the "Terms Of Service" page. (URI)
120
- attr_accessor :tosUri
121
- alias_method :tos_uri, :tosUri
122
- alias_method :tos_uri=, :tosUri=
123
-
124
- # URLs of "Terms Of Service" pages with language tags.
125
- # (TaggedValue array)
126
- attr_accessor :tosUris
127
- alias_method :tos_uris, :tosUris
128
- alias_method :tos_uris=, :tosUris=
129
-
130
- # The URL pointing to the JWK Set of the client application. (URI)
131
- attr_accessor :jwksUri
132
- alias_method :jwks_uri, :jwksUri
133
- alias_method :jwks_uri=, :jwksUri=
134
-
135
- # The content of the JWK Set of the client application. (String)
136
- attr_accessor :jwks
137
-
138
- # The sector identifier which is a URL starting with https. (URI)
139
- attr_accessor :sectorIdentifier
140
- alias_method :sector_identifier, :sectorIdentifier
141
- alias_method :sector_identifier=, :sectorIdentifier=
142
-
143
- # The subject type that the client application requests. (URI)
144
- attr_accessor :subjectType
145
- alias_method :subject_type, :subjectType
146
- alias_method :subject_type=, :subjectType=
147
-
148
- # The value of alg header parameter of JWS that the client application
149
- # requires the service to use for signing an ID token. (String)
150
- attr_accessor :idTokenSignAlg
151
- alias_method :id_token_sign_alg, :idTokenSignAlg
152
- alias_method :id_token_sign_alg=, :idTokenSignAlg=
153
-
154
- # The value of alg header parameter of JWE that the client application
155
- # requires the service to use for encrypting an ID token. (String)
156
- attr_accessor :idTokenEncryptionAlg
157
- alias_method :id_token_encryption_alg, :idTokenEncryptionAlg
158
- alias_method :id_token_encryption_alg=, :idTokenEncryptionAlg=
159
-
160
- # The value of enc header parameter of JWE that the client application
161
- # requires the service to use for encrypting an ID token. (String)
162
- attr_accessor :idTokenEncryptionEnc
163
- alias_method :id_token_encryption_enc, :idTokenEncryptionEnc
164
- alias_method :id_token_encryption_enc=, :idTokenEncryptionEnc=
165
-
166
- # The value of alg header parameter of JWS that the client application
167
- # requires the service to use for signing the JWT returned from the user
168
- # info endpoint. One of the values listed in JWS Algorithm. (String)
169
- attr_accessor :userInfoSignAlg
170
- alias_method :user_info_sign_alg, :userInfoSignAlg
171
- alias_method :user_info_sign_alg=, :userInfoSignAlg=
172
-
173
- # The value of alg header parameter of JWE that the client application
174
- # requires the service to use for encrypting the JWT returned from
175
- # the user info endpoint. (String)
176
- attr_accessor :userInfoEncryptionAlg
177
- alias_method :user_info_encryption_alg, :userInfoEncryptionAlg
178
- alias_method :user_info_encryption_alg=, :userInfoEncryptionAlg=
179
-
180
- # The value of enc header parameter of JWE that the client application
181
- # requires the service to use for encrypting the JWT returned from
182
- # the user info endpoint. (String)
183
- attr_accessor :userInfoEncryptionEnc
184
- alias_method :user_info_encryption_enc, :userInfoEncryptionEnc
185
- alias_method :user_info_encryption_enc=, :userInfoEncryptionEnc=
186
-
187
- # The value of alg header parameter of JWS that the client application
188
- # uses for signing a request object. (String)
189
- attr_accessor :requestSignAlg
190
- alias_method :request_sign_alg, :requestSignAlg
191
- alias_method :request_sign_alg=, :requestSignAlg=
192
-
193
- # The value of alg header parameter of JWE that the client application
194
- # uses for encrypting a request object. (String)
195
- attr_accessor :requestEncryptionAlg
196
- alias_method :request_encryption_alg, :requestEncryptionAlg
197
- alias_method :request_encryption_alg=, :requestEncryptionAlg=
198
-
199
- # The value of enc header parameter of JWE that the client application
200
- # uses for encrypting a request object. (String)
201
- attr_accessor :requestEncryptionEnc
202
- alias_method :request_encryption_enc, :requestEncryptionEnc
203
- alias_method :request_encryption_enc=, :requestEncryptionEnc=
204
-
205
- # The client authentication method that the client application
206
- # declares that it uses at the token endpoint. (String)
207
- attr_accessor :tokenAuthMethod
208
- alias_method :token_auth_method, :tokenAuthMethod
209
- alias_method :token_auth_method=, :tokenAuthMethod=
210
-
211
- # The value of alg header parameter of JWS which is used
212
- # for client authentication at the token endpoint. (String)
213
- attr_accessor :tokenAuthSignAlg
214
- alias_method :token_auth_sign_alg, :tokenAuthSignAlg
215
- alias_method :token_auth_sign_alg=, :tokenAuthSignAlg=
216
-
217
- # The default maximum authentication age in seconds. (Integer)
218
- attr_accessor :defaultMaxAge
219
- alias_method :default_max_age, :defaultMaxAge
220
- alias_method :default_max_age=, :defaultMaxAge=
221
-
222
- # The default ACRs (Authentication Context Class References). (String array)
223
- attr_accessor :defaultAcrs
224
- alias_method :default_acrs, :defaultAcrs
225
- alias_method :default_acrs=, :defaultAcrs=
226
-
227
- # The flag showing the client application requires the auth_time claim
228
- # to be in an ID token. (Boolean)
229
- attr_accessor :authTimeRequired
230
- alias_method :auth_time_required, :authTimeRequired
231
- alias_method :auth_time_required=, :authTimeRequired=
232
-
233
- # The URL which a third party can use to initiate a login by the client
234
- # application. (URI)
235
- attr_accessor :loginUri
236
- alias_method :login_uri, :loginUri
237
- alias_method :login_uri=, :loginUri=
238
-
239
- # An array of URLs each of which points to a request object.
240
- # (URI array)
241
- attr_accessor :requestUris
242
- alias_method :request_uris, :requestUris
243
- alias_method :request_uris=, :requestUris=
244
-
245
- # The description about the client application. At most 200 letters in unicode.
246
- # (String)
247
- attr_accessor :description
248
-
249
- # Descriptions about the client application with language tags. (TaggesValue array)
250
- attr_accessor :descriptions
251
-
252
- # The timestamp at which the client was created. (Integer)
253
- attr_accessor :createdAt
254
- alias_method :created_at, :createdAt
255
- alias_method :created_at=, :createdAt=
256
-
257
- # The timestamp at which the client was modified. (Integer)
258
- attr_accessor :modifiedAt
259
- alias_method :modified_at, :modifiedAt
260
- alias_method :modified_at=, :modifiedAt=
261
-
262
- private
263
-
264
- # Integer attributes.
265
- INTEGER_ATTRIBUTES = ::Set.new([
266
- :number, :serviceNumber, :clientId, :defaultMaxAge, :createdAt, :modifiedAt
267
- ])
268
-
269
- # Boolean attributes.
270
- BOOLEAN_ATTRIBUTES = ::Set.new([ :authTimeRequired ])
271
-
272
- # String attributes.
273
- STRING_ATTRIBUTES = ::Set.new([
274
- :developer, :clientSecret, :clientType, :responseTypes, :applicationType,
275
- :clientName, :logoUri, :clientUri, :policyUri, :tosUri, :jwksUri, :jwks,
276
- :sectorIdentifier, :subjectType, :idTokenSignAlg, :idTokenEncryptionAlg,
277
- :idTokenEncryptionEnc, :userInfoSignAlg, :userInfoEncryptionAlg, :userInfoEncryptionEnc,
278
- :requestSignAlg, :requestEncryptionAlg, :requestEncryptionEnc, :tokenAuthMethod,
279
- :tokenAuthSignAlg, :loginUri, :description
280
- ])
281
-
282
- # String array attributes.
283
- STRING_ARRAY_ATTRIBUTES = ::Set.new([
284
- :redirectUris, :responseTypes, :grantTypes, :contacts, :defaultAcrs, :requestUris
285
- ])
286
-
287
- # Tagged value array atributes.
288
- TAGGED_VALUE_ARRAY_ATTRIBUTES = ::Set.new([
289
- :clientNames, :logoUris, :clientUris, :policyUris, :tosUris, :descriptions
290
- ])
291
-
292
- # Mapping from snake cases to camel cases.
293
- SNAKE_TO_CAMEL = {
294
- :service_number => :serviceNumber,
295
- :client_id => :clientId,
296
- :client_secret => :clientSecret,
297
- :client_type => :clientType,
298
- :redirect_uris => :redirectUris,
299
- :response_types => :responseTypes,
300
- :grant_types => :grantTypes,
301
- :application_type => :applicationType,
302
- :client_name => :clientName,
303
- :client_names => :clientNames,
304
- :logo_uri => :logoUri,
305
- :logo_uris => :logoUris,
306
- :client_uri => :clientUri,
307
- :client_uris => :clientUris,
308
- :policy_uri => :policyUri,
309
- :policy_uris => :policyUris,
310
- :tos_uri => :tosUri,
311
- :tos_uris => :tosUris,
312
- :jwks_uri => :jwksUri,
313
- :sector_identifier => :sectorIdentifier,
314
- :subject_type => :subjectType,
315
- :id_token_sign_alg => :idTokenSignAlg,
316
- :id_token_encryption_alg => :idTokenEncryptionAlg,
317
- :id_token_encryption_enc => :idTokenEncryptionEnc,
318
- :user_info_sign_alg => :userInfoSignAlg,
319
- :user_info_encryption_alg => :userInfoEncryptionAlg,
320
- :user_info_encryption_enc => :userInfoEncryptionEnc,
321
- :request_sign_alg => :requestSignAlg,
322
- :request_encryption_alg => :requestEncryptionAlg,
323
- :request_encryption_enc => :requestEncryptionEnc,
324
- :token_auth_method => :tokenAuthMethod,
325
- :token_auth_sign_alg => :tokenAuthSignAlg,
326
- :default_max_age => :defaultMaxAge,
327
- :default_acrs => :defaultAcrs,
328
- :auth_time_required => :authTimeRequired,
329
- :login_uri => :loginUri,
330
- :request_uris => :requestUris,
331
- :created_at => :createdAt,
332
- :modified_at => :modifiedAt
333
- }
334
-
335
- # The constructor
336
- def initialize(hash = nil)
337
- # Set default values to integer attributes.
338
- INTEGER_ATTRIBUTES.each do |attr|
339
- send("#{attr}=", 0)
340
- end
341
-
342
- # Set default values to boolean attributes.
343
- BOOLEAN_ATTRIBUTES.each do |attr|
344
- send("#{attr}=", false)
345
- end
346
-
347
- # Set default values to string attributes.
348
- STRING_ATTRIBUTES.each do |attr|
349
- send("#{attr}=", nil)
350
- end
351
-
352
- # Set default values to string array attributes.
353
- STRING_ARRAY_ATTRIBUTES.each do |attr|
354
- send("#{attr}=", nil)
355
- end
356
-
357
- # Set default values to tagged value array attributes.
358
- TAGGED_VALUE_ARRAY_ATTRIBUTES.each do |attr|
359
- send("#{attr}=", nil)
360
- end
361
-
362
- # Set attribute values using the given hash.
363
- authlete_model_service_update(hash)
364
- end
365
-
366
- def authlete_model_service_to_key(key)
367
- key = key.to_sym
368
-
369
- # Convert snakecase to camelcase, if necessary.
370
- if SNAKE_TO_CAMEL.has_key?(key)
371
- key = SNAKE_TO_CAMEL[key]
372
- end
373
-
374
- return key
375
- end
376
-
377
- def authlete_model_client_simple_attribute?(key)
378
- INTEGER_ATTRIBUTES.include?(key) or
379
- BOOLEAN_ATTRIBUTES.include?(key) or
380
- STRING_ATTRIBUTES.include?(key) or
381
- STRING_ARRAY_ATTRIBUTES.include?(key)
382
- end
383
-
384
- def authlete_model_client_update(hash)
385
- if hash.nil?
386
- return
387
- end
388
-
389
- hash.each do |key, value|
390
- key = authlete_model_client_to_key(key)
391
-
392
- # If the attribute is a simple one.
393
- if authlete_model_client_simple_attribute?(key)
394
- send("#{key}=", value)
395
- next
396
- end
397
-
398
- # If the attribute is an array of tagged values.
399
- if TAGGED_VALUE_ARRAY_ATTRIBUTES.include?(key)
400
- parsed = authlete_model_client_parse_array(value) do |element|
401
- Authlete::Model::TaggedValue.parse(element)
402
- end
403
-
404
- send("#{key}=", parsed)
405
- end
406
- end
407
-
408
- return self
409
- end
410
-
411
- def authlete_model_client_parse_array(array)
412
- if array.nil? or (array.kind_of?(Array) == false) or (array.length == 0)
413
- return nil
414
- end
415
-
416
- elements = []
417
-
418
- array.each do |element|
419
- parsed_element = yield(element)
420
-
421
- if parsed_element.nil? == false
422
- elements.push(parsed_element)
423
- end
424
- end
425
-
426
- if elements.length == 0
427
- return nil
428
- end
429
-
430
- return elements
431
- end
432
-
433
- public
434
-
435
- # Construct an instance from the given hash.
436
- #
437
- # If the given argument is nil or is not a Hash, nil is returned.
438
- # Otherwise, Service.new(hash) is returned.
439
- def self.parse(hash)
440
- if hash.nil? or (hash.kind_of?(Hash) == false)
441
- return nil
442
- end
443
-
444
- return Client.new(hash)
445
- end
446
-
447
- # Set attribute values using the given hash.
448
- def update(hash)
449
- authlete_model_client_update(hash)
450
- end
451
-
452
- # Convert this object into a hash.
453
- def to_hash
454
- hash = {}
455
-
456
- instance_variables.each do |var|
457
- key = var.to_s.delete("@").to_sym
458
- val = instance_variable_get(var)
459
-
460
- if authlete_model_client_simple_attribute?(key) or val.nil?
461
- hash[key] = val
462
- elsif val.kind_of?(Array)
463
- hash[key] = val.map {|element| element.to_hash}
464
- end
465
- end
466
-
467
- return hash
468
- end
469
-
470
- def [](key)
471
- key = authlete_model_client_to_key(key)
472
-
473
- if respond_to?(key)
474
- return send(key)
475
- else
476
- return nil
477
- end
478
- end
479
-
480
- def []=(key, value)
481
- key = authlete_model_client_to_key(key)
482
- method = "#{key}="
483
-
484
- if respond_to?(method)
485
- return send(method, value)
486
- else
487
- return nil
488
- end
489
- end
490
- end
491
- end
492
- end
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2015 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'set'
19
+
20
+
21
+ module Authlete
22
+ module Model
23
+ class Client
24
+ # The sequential number of the client application. (Integer)
25
+ attr_accessor :number
26
+
27
+ # The sequential number of the service of the client application.
28
+ # (Integer)
29
+ attr_accessor :serviceNumber
30
+ alias_method :service_number, :serviceNumber
31
+ alias_method :service_number=, :serviceNumber=
32
+
33
+ # The developer of the client application. (String)
34
+ attr_accessor :developer
35
+
36
+ # The client ID. (Integer)
37
+ attr_accessor :clientId
38
+ alias_method :client_id, :clientId
39
+ alias_method :client_id=, :clientId=
40
+
41
+ # The client secret. (String)
42
+ attr_accessor :clientSecret
43
+ alias_method :client_secret, :clientSecret
44
+ alias_method :client_secret=, :clientSecret=
45
+
46
+ # The client type. (String)
47
+ attr_accessor :clientType
48
+ alias_method :client_type, :clientType
49
+ alias_method :client_type=, :clientType=
50
+
51
+ # Redirect URIs that the client application uses to receive a response
52
+ # from the authorization endpoint. (URI array)
53
+ attr_accessor :redirectUris
54
+ alias_method :redirect_uris, :redirectUris
55
+ alias_method :redirect_uris=, :redirectUris=
56
+
57
+ # A string array of response types which the client application declares
58
+ # that it will restrict itself to using (String array)
59
+ attr_accessor :responseTypes
60
+ alias_method :response_types, :responseTypes
61
+ alias_method :response_types=, :responseTypes=
62
+
63
+ # A string array of grant types which the client application declares
64
+ # that it will restrict itself to using. (String array)
65
+ attr_accessor :grantTypes
66
+ alias_method :grant_types, :grantTypes
67
+ alias_method :grant_types=, :grantTypes=
68
+
69
+ # The application type. (String)
70
+ attr_accessor :applicationType
71
+ alias_method :application_type, :applicationType
72
+ alias_method :application_type=, :applicationType=
73
+
74
+ # An array of email addresses of people responsible for the client application.
75
+ # (String array)
76
+ attr_accessor :contacts
77
+
78
+ # The name of the client application. (String)
79
+ attr_accessor :clientName
80
+ alias_method :client_name, :clientName
81
+ alias_method :client_name=, :clientName=
82
+
83
+ # Client names with language tags. (TaggedValue array)
84
+ attr_accessor :clientNames
85
+ alias_method :client_names, :clientNames
86
+ alias_method :client_names=, :clientNames=
87
+
88
+ # The URL pointing to the logo image of the client application. (URI)
89
+ attr_accessor :logoUri
90
+ alias_method :logo_uri, :logoUri
91
+ alias_method :logo_uri=, :logoUri=
92
+
93
+ # Logo image URLs with language tags. (TaggedValue array)
94
+ attr_accessor :logoUris
95
+ alias_method :logo_uris, :logoUris
96
+ alias_method :logo_uris=, :logoUris=
97
+
98
+ # The URL pointing to the home page of the client application. (URI)
99
+ attr_accessor :clientUri
100
+ alias_method :client_uri, :clientUri
101
+ alias_method :client_uri=, :clientUri=
102
+
103
+ # Home page URLs with language tags. (TaggedValue array)
104
+ attr_accessor :clientUris
105
+ alias_method :client_uris, :clientUris
106
+ alias_method :client_uris=, :clientUris=
107
+
108
+ # The URL pointing to the page which describes the policy
109
+ # as to how end-users' profile data are used. (URI)
110
+ attr_accessor :policyUri
111
+ alias_method :policy_uri, :policyUri
112
+ alias_method :policy_uri=, :policyUri=
113
+
114
+ # URLs of policy pages with language tags. (TaggedValue array)
115
+ attr_accessor :policyUris
116
+ alias_method :policy_uris, :policyUris
117
+ alias_method :policy_uris=, :policyUris=
118
+
119
+ # The URL pointing to the "Terms Of Service" page. (URI)
120
+ attr_accessor :tosUri
121
+ alias_method :tos_uri, :tosUri
122
+ alias_method :tos_uri=, :tosUri=
123
+
124
+ # URLs of "Terms Of Service" pages with language tags.
125
+ # (TaggedValue array)
126
+ attr_accessor :tosUris
127
+ alias_method :tos_uris, :tosUris
128
+ alias_method :tos_uris=, :tosUris=
129
+
130
+ # The URL pointing to the JWK Set of the client application. (URI)
131
+ attr_accessor :jwksUri
132
+ alias_method :jwks_uri, :jwksUri
133
+ alias_method :jwks_uri=, :jwksUri=
134
+
135
+ # The content of the JWK Set of the client application. (String)
136
+ attr_accessor :jwks
137
+
138
+ # The sector identifier which is a URL starting with https. (URI)
139
+ attr_accessor :sectorIdentifier
140
+ alias_method :sector_identifier, :sectorIdentifier
141
+ alias_method :sector_identifier=, :sectorIdentifier=
142
+
143
+ # The subject type that the client application requests. (URI)
144
+ attr_accessor :subjectType
145
+ alias_method :subject_type, :subjectType
146
+ alias_method :subject_type=, :subjectType=
147
+
148
+ # The value of alg header parameter of JWS that the client application
149
+ # requires the service to use for signing an ID token. (String)
150
+ attr_accessor :idTokenSignAlg
151
+ alias_method :id_token_sign_alg, :idTokenSignAlg
152
+ alias_method :id_token_sign_alg=, :idTokenSignAlg=
153
+
154
+ # The value of alg header parameter of JWE that the client application
155
+ # requires the service to use for encrypting an ID token. (String)
156
+ attr_accessor :idTokenEncryptionAlg
157
+ alias_method :id_token_encryption_alg, :idTokenEncryptionAlg
158
+ alias_method :id_token_encryption_alg=, :idTokenEncryptionAlg=
159
+
160
+ # The value of enc header parameter of JWE that the client application
161
+ # requires the service to use for encrypting an ID token. (String)
162
+ attr_accessor :idTokenEncryptionEnc
163
+ alias_method :id_token_encryption_enc, :idTokenEncryptionEnc
164
+ alias_method :id_token_encryption_enc=, :idTokenEncryptionEnc=
165
+
166
+ # The value of alg header parameter of JWS that the client application
167
+ # requires the service to use for signing the JWT returned from the user
168
+ # info endpoint. One of the values listed in JWS Algorithm. (String)
169
+ attr_accessor :userInfoSignAlg
170
+ alias_method :user_info_sign_alg, :userInfoSignAlg
171
+ alias_method :user_info_sign_alg=, :userInfoSignAlg=
172
+
173
+ # The value of alg header parameter of JWE that the client application
174
+ # requires the service to use for encrypting the JWT returned from
175
+ # the user info endpoint. (String)
176
+ attr_accessor :userInfoEncryptionAlg
177
+ alias_method :user_info_encryption_alg, :userInfoEncryptionAlg
178
+ alias_method :user_info_encryption_alg=, :userInfoEncryptionAlg=
179
+
180
+ # The value of enc header parameter of JWE that the client application
181
+ # requires the service to use for encrypting the JWT returned from
182
+ # the user info endpoint. (String)
183
+ attr_accessor :userInfoEncryptionEnc
184
+ alias_method :user_info_encryption_enc, :userInfoEncryptionEnc
185
+ alias_method :user_info_encryption_enc=, :userInfoEncryptionEnc=
186
+
187
+ # The value of alg header parameter of JWS that the client application
188
+ # uses for signing a request object. (String)
189
+ attr_accessor :requestSignAlg
190
+ alias_method :request_sign_alg, :requestSignAlg
191
+ alias_method :request_sign_alg=, :requestSignAlg=
192
+
193
+ # The value of alg header parameter of JWE that the client application
194
+ # uses for encrypting a request object. (String)
195
+ attr_accessor :requestEncryptionAlg
196
+ alias_method :request_encryption_alg, :requestEncryptionAlg
197
+ alias_method :request_encryption_alg=, :requestEncryptionAlg=
198
+
199
+ # The value of enc header parameter of JWE that the client application
200
+ # uses for encrypting a request object. (String)
201
+ attr_accessor :requestEncryptionEnc
202
+ alias_method :request_encryption_enc, :requestEncryptionEnc
203
+ alias_method :request_encryption_enc=, :requestEncryptionEnc=
204
+
205
+ # The client authentication method that the client application
206
+ # declares that it uses at the token endpoint. (String)
207
+ attr_accessor :tokenAuthMethod
208
+ alias_method :token_auth_method, :tokenAuthMethod
209
+ alias_method :token_auth_method=, :tokenAuthMethod=
210
+
211
+ # The value of alg header parameter of JWS which is used
212
+ # for client authentication at the token endpoint. (String)
213
+ attr_accessor :tokenAuthSignAlg
214
+ alias_method :token_auth_sign_alg, :tokenAuthSignAlg
215
+ alias_method :token_auth_sign_alg=, :tokenAuthSignAlg=
216
+
217
+ # The default maximum authentication age in seconds. (Integer)
218
+ attr_accessor :defaultMaxAge
219
+ alias_method :default_max_age, :defaultMaxAge
220
+ alias_method :default_max_age=, :defaultMaxAge=
221
+
222
+ # The default ACRs (Authentication Context Class References). (String array)
223
+ attr_accessor :defaultAcrs
224
+ alias_method :default_acrs, :defaultAcrs
225
+ alias_method :default_acrs=, :defaultAcrs=
226
+
227
+ # The flag showing the client application requires the auth_time claim
228
+ # to be in an ID token. (Boolean)
229
+ attr_accessor :authTimeRequired
230
+ alias_method :auth_time_required, :authTimeRequired
231
+ alias_method :auth_time_required=, :authTimeRequired=
232
+
233
+ # The URL which a third party can use to initiate a login by the client
234
+ # application. (URI)
235
+ attr_accessor :loginUri
236
+ alias_method :login_uri, :loginUri
237
+ alias_method :login_uri=, :loginUri=
238
+
239
+ # An array of URLs each of which points to a request object.
240
+ # (URI array)
241
+ attr_accessor :requestUris
242
+ alias_method :request_uris, :requestUris
243
+ alias_method :request_uris=, :requestUris=
244
+
245
+ # The description about the client application. At most 200 letters in unicode.
246
+ # (String)
247
+ attr_accessor :description
248
+
249
+ # Descriptions about the client application with language tags. (TaggesValue array)
250
+ attr_accessor :descriptions
251
+
252
+ # The timestamp at which the client was created. (Integer)
253
+ attr_accessor :createdAt
254
+ alias_method :created_at, :createdAt
255
+ alias_method :created_at=, :createdAt=
256
+
257
+ # The timestamp at which the client was modified. (Integer)
258
+ attr_accessor :modifiedAt
259
+ alias_method :modified_at, :modifiedAt
260
+ alias_method :modified_at=, :modifiedAt=
261
+
262
+ private
263
+
264
+ # Integer attributes.
265
+ INTEGER_ATTRIBUTES = ::Set.new([
266
+ :number, :serviceNumber, :clientId, :defaultMaxAge, :createdAt, :modifiedAt
267
+ ])
268
+
269
+ # Boolean attributes.
270
+ BOOLEAN_ATTRIBUTES = ::Set.new([ :authTimeRequired ])
271
+
272
+ # String attributes.
273
+ STRING_ATTRIBUTES = ::Set.new([
274
+ :developer, :clientSecret, :clientType, :responseTypes, :applicationType,
275
+ :clientName, :logoUri, :clientUri, :policyUri, :tosUri, :jwksUri, :jwks,
276
+ :sectorIdentifier, :subjectType, :idTokenSignAlg, :idTokenEncryptionAlg,
277
+ :idTokenEncryptionEnc, :userInfoSignAlg, :userInfoEncryptionAlg, :userInfoEncryptionEnc,
278
+ :requestSignAlg, :requestEncryptionAlg, :requestEncryptionEnc, :tokenAuthMethod,
279
+ :tokenAuthSignAlg, :loginUri, :description
280
+ ])
281
+
282
+ # String array attributes.
283
+ STRING_ARRAY_ATTRIBUTES = ::Set.new([
284
+ :redirectUris, :responseTypes, :grantTypes, :contacts, :defaultAcrs, :requestUris
285
+ ])
286
+
287
+ # Tagged value array atributes.
288
+ TAGGED_VALUE_ARRAY_ATTRIBUTES = ::Set.new([
289
+ :clientNames, :logoUris, :clientUris, :policyUris, :tosUris, :descriptions
290
+ ])
291
+
292
+ # Mapping from snake cases to camel cases.
293
+ SNAKE_TO_CAMEL = {
294
+ :service_number => :serviceNumber,
295
+ :client_id => :clientId,
296
+ :client_secret => :clientSecret,
297
+ :client_type => :clientType,
298
+ :redirect_uris => :redirectUris,
299
+ :response_types => :responseTypes,
300
+ :grant_types => :grantTypes,
301
+ :application_type => :applicationType,
302
+ :client_name => :clientName,
303
+ :client_names => :clientNames,
304
+ :logo_uri => :logoUri,
305
+ :logo_uris => :logoUris,
306
+ :client_uri => :clientUri,
307
+ :client_uris => :clientUris,
308
+ :policy_uri => :policyUri,
309
+ :policy_uris => :policyUris,
310
+ :tos_uri => :tosUri,
311
+ :tos_uris => :tosUris,
312
+ :jwks_uri => :jwksUri,
313
+ :sector_identifier => :sectorIdentifier,
314
+ :subject_type => :subjectType,
315
+ :id_token_sign_alg => :idTokenSignAlg,
316
+ :id_token_encryption_alg => :idTokenEncryptionAlg,
317
+ :id_token_encryption_enc => :idTokenEncryptionEnc,
318
+ :user_info_sign_alg => :userInfoSignAlg,
319
+ :user_info_encryption_alg => :userInfoEncryptionAlg,
320
+ :user_info_encryption_enc => :userInfoEncryptionEnc,
321
+ :request_sign_alg => :requestSignAlg,
322
+ :request_encryption_alg => :requestEncryptionAlg,
323
+ :request_encryption_enc => :requestEncryptionEnc,
324
+ :token_auth_method => :tokenAuthMethod,
325
+ :token_auth_sign_alg => :tokenAuthSignAlg,
326
+ :default_max_age => :defaultMaxAge,
327
+ :default_acrs => :defaultAcrs,
328
+ :auth_time_required => :authTimeRequired,
329
+ :login_uri => :loginUri,
330
+ :request_uris => :requestUris,
331
+ :created_at => :createdAt,
332
+ :modified_at => :modifiedAt
333
+ }
334
+
335
+ # The constructor
336
+ def initialize(hash = nil)
337
+ # Set default values to integer attributes.
338
+ INTEGER_ATTRIBUTES.each do |attr|
339
+ send("#{attr}=", 0)
340
+ end
341
+
342
+ # Set default values to boolean attributes.
343
+ BOOLEAN_ATTRIBUTES.each do |attr|
344
+ send("#{attr}=", false)
345
+ end
346
+
347
+ # Set default values to string attributes.
348
+ STRING_ATTRIBUTES.each do |attr|
349
+ send("#{attr}=", nil)
350
+ end
351
+
352
+ # Set default values to string array attributes.
353
+ STRING_ARRAY_ATTRIBUTES.each do |attr|
354
+ send("#{attr}=", nil)
355
+ end
356
+
357
+ # Set default values to tagged value array attributes.
358
+ TAGGED_VALUE_ARRAY_ATTRIBUTES.each do |attr|
359
+ send("#{attr}=", nil)
360
+ end
361
+
362
+ # Set attribute values using the given hash.
363
+ authlete_model_service_update(hash)
364
+ end
365
+
366
+ def authlete_model_service_to_key(key)
367
+ key = key.to_sym
368
+
369
+ # Convert snakecase to camelcase, if necessary.
370
+ if SNAKE_TO_CAMEL.has_key?(key)
371
+ key = SNAKE_TO_CAMEL[key]
372
+ end
373
+
374
+ return key
375
+ end
376
+
377
+ def authlete_model_client_simple_attribute?(key)
378
+ INTEGER_ATTRIBUTES.include?(key) or
379
+ BOOLEAN_ATTRIBUTES.include?(key) or
380
+ STRING_ATTRIBUTES.include?(key) or
381
+ STRING_ARRAY_ATTRIBUTES.include?(key)
382
+ end
383
+
384
+ def authlete_model_client_update(hash)
385
+ if hash.nil?
386
+ return
387
+ end
388
+
389
+ hash.each do |key, value|
390
+ key = authlete_model_client_to_key(key)
391
+
392
+ # If the attribute is a simple one.
393
+ if authlete_model_client_simple_attribute?(key)
394
+ send("#{key}=", value)
395
+ next
396
+ end
397
+
398
+ # If the attribute is an array of tagged values.
399
+ if TAGGED_VALUE_ARRAY_ATTRIBUTES.include?(key)
400
+ parsed = authlete_model_client_parse_array(value) do |element|
401
+ Authlete::Model::TaggedValue.parse(element)
402
+ end
403
+
404
+ send("#{key}=", parsed)
405
+ end
406
+ end
407
+
408
+ return self
409
+ end
410
+
411
+ def authlete_model_client_parse_array(array)
412
+ if array.nil? or (array.kind_of?(Array) == false) or (array.length == 0)
413
+ return nil
414
+ end
415
+
416
+ elements = []
417
+
418
+ array.each do |element|
419
+ parsed_element = yield(element)
420
+
421
+ if parsed_element.nil? == false
422
+ elements.push(parsed_element)
423
+ end
424
+ end
425
+
426
+ if elements.length == 0
427
+ return nil
428
+ end
429
+
430
+ return elements
431
+ end
432
+
433
+ public
434
+
435
+ # Construct an instance from the given hash.
436
+ #
437
+ # If the given argument is nil or is not a Hash, nil is returned.
438
+ # Otherwise, Service.new(hash) is returned.
439
+ def self.parse(hash)
440
+ if hash.nil? or (hash.kind_of?(Hash) == false)
441
+ return nil
442
+ end
443
+
444
+ return Client.new(hash)
445
+ end
446
+
447
+ # Set attribute values using the given hash.
448
+ def update(hash)
449
+ authlete_model_client_update(hash)
450
+ end
451
+
452
+ # Convert this object into a hash.
453
+ def to_hash
454
+ hash = {}
455
+
456
+ instance_variables.each do |var|
457
+ key = var.to_s.delete("@").to_sym
458
+ val = instance_variable_get(var)
459
+
460
+ if authlete_model_client_simple_attribute?(key) or val.nil?
461
+ hash[key] = val
462
+ elsif val.kind_of?(Array)
463
+ hash[key] = val.map {|element| element.to_hash}
464
+ end
465
+ end
466
+
467
+ return hash
468
+ end
469
+
470
+ def [](key)
471
+ key = authlete_model_client_to_key(key)
472
+
473
+ if respond_to?(key)
474
+ return send(key)
475
+ else
476
+ return nil
477
+ end
478
+ end
479
+
480
+ def []=(key, value)
481
+ key = authlete_model_client_to_key(key)
482
+ method = "#{key}="
483
+
484
+ if respond_to?(method)
485
+ return send(method, value)
486
+ else
487
+ return nil
488
+ end
489
+ end
490
+ end
491
+ end
492
+ end