authlete 0.5.1 → 1.0.0

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