authlete 0.3.6 → 0.3.7

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