authlete 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2015 Authlete, Inc.
3
+ # Copyright (C) 2014-2018 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2015 Authlete, Inc.
3
+ # Copyright (C) 2014-2018 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -19,6 +19,9 @@ module Authlete
19
19
  class Exception < StandardError
20
20
  include Authlete::Utility
21
21
 
22
+ # The error message.
23
+ attr_accessor :message
24
+
22
25
  # The HTTP status code of the error.
23
26
  attr_accessor :statusCode
24
27
  alias_method :status_code, :statusCode
@@ -33,12 +36,12 @@ module Authlete
33
36
  # The error message from RestClient or the other general exceptions.
34
37
  @message = extract_value(hash, :message)
35
38
  @statusCode = extract_integer_value(hash, :statusCode)
36
- @result = Authlete::Model::Result.new(hash)
39
+ @result = Authlete::Model::Result.new(extract_value(hash, :result))
37
40
  end
38
41
 
39
42
  public
40
43
 
41
- def message
44
+ def available_message
42
45
  @result.resultMessage || @message || self.class.default_message
43
46
  end
44
47
 
@@ -1,136 +1,136 @@
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 ClientExtension < Authlete::Model::Hashable
24
- include Authlete::Utility
25
-
26
- # The set of scopes that a client application is allowed to request.
27
- # (String array)
28
- attr_accessor :requestableScopes
29
- alias_method :requestable_scopes, :requestableScopes
30
- alias_method :requestable_scopes=, :requestableScopes=
31
-
32
- # The flag to show whether a client application can only request
33
- # the set of scopes that it is allowed to request or it can request
34
- # all of the scopes that the service supports. (Boolean)
35
- attr_accessor :requestableScopesEnabled
36
- alias_method :requestable_scopes_enabled, :requestableScopesEnabled
37
- alias_method :requestable_scopes_enabled=, :requestableScopesEnabled=
38
-
39
- private
40
-
41
- # Boolean attributes.
42
- BOOLEAN_ATTRIBUTES = ::Set.new([
43
- :requestableScopesEnabled
44
- ])
45
-
46
- # String array attributes.
47
- STRING_ARRAY_ATTRIBUTES = ::Set.new([
48
- :requestableScopes
49
- ])
50
-
51
- # Mapping from snake cases to camel cases.
52
- SNAKE_TO_CAMEL = {
53
- :requestable_scopes => :requestableScopes,
54
- :requestable_scopes_enabled => :requestableScopesEnabled
55
- }
56
-
57
- # The constructor
58
- def initialize(hash = nil)
59
- # Set default values to boolean attributes.
60
- BOOLEAN_ATTRIBUTES.each do |attr|
61
- send("#{attr}=", false)
62
- end
63
-
64
- # Set default values to string array attributes.
65
- STRING_ARRAY_ATTRIBUTES.each do |attr|
66
- send("#{attr}=", nil)
67
- end
68
-
69
- # Set attribute values using the given hash.
70
- authlete_model_update(hash)
71
- end
72
-
73
- def authlete_model_convert_key(key)
74
- key = key.to_sym
75
-
76
- # Convert snakecase to camelcase, if necessary.
77
- if SNAKE_TO_CAMEL.has_key?(key)
78
- key = SNAKE_TO_CAMEL[key]
79
- end
80
-
81
- key
82
- end
83
-
84
- def authlete_model_simple_attribute?(key)
85
- BOOLEAN_ATTRIBUTES.include?(key) or
86
- STRING_ARRAY_ATTRIBUTES.include?(key)
87
- end
88
-
89
- def authlete_model_update(hash)
90
- return if hash.nil?
91
-
92
- hash.each do |key, value|
93
- key = authlete_model_convert_key(key)
94
-
95
- if authlete_model_simple_attribute?(key)
96
- send("#{key}=", value)
97
- end
98
- end
99
-
100
- self
101
- end
102
-
103
- public
104
-
105
- # Construct an instance from the given hash.
106
- #
107
- # If the given argument is nil or is not a Hash, nil is returned.
108
- # Otherwise, ClientList.new(hash) is returned.
109
- def self.parse(hash)
110
- if hash.nil? or (hash.kind_of?(Hash) == false)
111
- return nil
112
- end
113
-
114
- return ClientExtension.new(hash)
115
- end
116
-
117
- # Convert this object into a hash.
118
- def to_hash
119
- hash = {}
120
-
121
- instance_variables.each do |var|
122
- key = var.to_s.delete("@").to_sym
123
- val = instance_variable_get(var)
124
-
125
- if authlete_model_simple_attribute?(key) or val.nil?
126
- hash[key] = val
127
- elsif val.kind_of?(Array)
128
- hash[key] = val.map { |element| element.to_hash }
129
- end
130
- end
131
-
132
- hash
133
- end
134
- end
135
- 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 ClientExtension < Authlete::Model::Hashable
24
+ include Authlete::Utility
25
+
26
+ # The set of scopes that a client application is allowed to request.
27
+ # (String array)
28
+ attr_accessor :requestableScopes
29
+ alias_method :requestable_scopes, :requestableScopes
30
+ alias_method :requestable_scopes=, :requestableScopes=
31
+
32
+ # The flag to show whether a client application can only request
33
+ # the set of scopes that it is allowed to request or it can request
34
+ # all of the scopes that the service supports. (Boolean)
35
+ attr_accessor :requestableScopesEnabled
36
+ alias_method :requestable_scopes_enabled, :requestableScopesEnabled
37
+ alias_method :requestable_scopes_enabled=, :requestableScopesEnabled=
38
+
39
+ private
40
+
41
+ # Boolean attributes.
42
+ BOOLEAN_ATTRIBUTES = ::Set.new([
43
+ :requestableScopesEnabled
44
+ ])
45
+
46
+ # String array attributes.
47
+ STRING_ARRAY_ATTRIBUTES = ::Set.new([
48
+ :requestableScopes
49
+ ])
50
+
51
+ # Mapping from snake cases to camel cases.
52
+ SNAKE_TO_CAMEL = {
53
+ :requestable_scopes => :requestableScopes,
54
+ :requestable_scopes_enabled => :requestableScopesEnabled
55
+ }
56
+
57
+ # The constructor
58
+ def initialize(hash = nil)
59
+ # Set default values to boolean attributes.
60
+ BOOLEAN_ATTRIBUTES.each do |attr|
61
+ send("#{attr}=", false)
62
+ end
63
+
64
+ # Set default values to string array attributes.
65
+ STRING_ARRAY_ATTRIBUTES.each do |attr|
66
+ send("#{attr}=", nil)
67
+ end
68
+
69
+ # Set attribute values using the given hash.
70
+ authlete_model_update(hash)
71
+ end
72
+
73
+ def authlete_model_convert_key(key)
74
+ key = key.to_sym
75
+
76
+ # Convert snakecase to camelcase, if necessary.
77
+ if SNAKE_TO_CAMEL.has_key?(key)
78
+ key = SNAKE_TO_CAMEL[key]
79
+ end
80
+
81
+ key
82
+ end
83
+
84
+ def authlete_model_simple_attribute?(key)
85
+ BOOLEAN_ATTRIBUTES.include?(key) or
86
+ STRING_ARRAY_ATTRIBUTES.include?(key)
87
+ end
88
+
89
+ def authlete_model_update(hash)
90
+ return if hash.nil?
91
+
92
+ hash.each do |key, value|
93
+ key = authlete_model_convert_key(key)
94
+
95
+ if authlete_model_simple_attribute?(key)
96
+ send("#{key}=", value)
97
+ end
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ public
104
+
105
+ # Construct an instance from the given hash.
106
+ #
107
+ # If the given argument is nil or is not a Hash, nil is returned.
108
+ # Otherwise, ClientList.new(hash) is returned.
109
+ def self.parse(hash)
110
+ if hash.nil? or (hash.kind_of?(Hash) == false)
111
+ return nil
112
+ end
113
+
114
+ return ClientExtension.new(hash)
115
+ end
116
+
117
+ # Convert this object into a hash.
118
+ def to_hash
119
+ hash = {}
120
+
121
+ instance_variables.each do |var|
122
+ key = var.to_s.delete("@").to_sym
123
+ val = instance_variable_get(var)
124
+
125
+ if authlete_model_simple_attribute?(key) or val.nil?
126
+ hash[key] = val
127
+ elsif val.kind_of?(Array)
128
+ hash[key] = val.map { |element| element.to_hash }
129
+ end
130
+ end
131
+
132
+ hash
133
+ end
134
+ end
135
+ end
136
136
  end
@@ -1,129 +1,129 @@
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 ClientList < Authlete::Model::Hashable
24
- include Authlete::Utility
25
- # The start index (inclusive) of the clients in this list.
26
- # (Integer)
27
- attr_accessor :start
28
-
29
- # The end index (exclusive) of the clients in this list.
30
- # (Integer)
31
- attr_accessor :end
32
-
33
- # The total count of clients. (Integer)
34
- attr_accessor :totalCount
35
- alias_method :total_count, :totalCount
36
- alias_method :total_count=, :totalCount=
37
-
38
- # The list of clients. (Client array)
39
- attr_accessor :clients
40
-
41
- private
42
-
43
- # Integer attributes.
44
- INTEGER_ATTRIBUTES = ::Set.new([ :start, :end, :totalCount ])
45
-
46
- # Mapping from snake cases to camel cases.
47
- SNAKE_TO_CAMEL = { :total_count => :totalCount }
48
-
49
- # The constructor
50
- def initialize(hash = nil)
51
- # Set default values to integer attributes.
52
- INTEGER_ATTRIBUTES.each do |attr|
53
- send("#{attr}=", 0)
54
- end
55
-
56
- @clients = nil
57
-
58
- # Set attribute values using the given hash.
59
- authlete_model_update(hash)
60
- end
61
-
62
- def authlete_model_convert_key(key)
63
- key = key.to_sym
64
-
65
- # Convert snakecase to camelcase, if necessary.
66
- if SNAKE_TO_CAMEL.has_key?(key)
67
- key = SNAKE_TO_CAMEL[key]
68
- end
69
-
70
- key
71
- end
72
-
73
- def authlete_model_simple_attribute?(key)
74
- INTEGER_ATTRIBUTES.include?(key)
75
- end
76
-
77
- def authlete_model_update(hash)
78
- return if hash.nil?
79
-
80
- hash.each do |key, value|
81
- key = authlete_model_convert_key(key)
82
-
83
- if authlete_model_simple_attribute?(key)
84
- send("#{key}=", value)
85
- elsif key == :clients
86
- # Get an array consisting of "Client" objects.
87
- @clients = get_parsed_array(value) do |element|
88
- Authlete::Model::Client.parse(element)
89
- end
90
- end
91
- end
92
-
93
- self
94
- end
95
-
96
- public
97
-
98
- # Construct an instance from the given hash.
99
- #
100
- # If the given argument is nil or is not a Hash, nil is returned.
101
- # Otherwise, ClientList.new(hash) is returned.
102
- def self.parse(hash)
103
- if hash.nil? or (hash.kind_of?(Hash) == false)
104
- return nil
105
- end
106
-
107
- return ClientList.new(hash)
108
- end
109
-
110
- # Convert this object into a hash.
111
- def to_hash
112
- hash = {}
113
-
114
- instance_variables.each do |var|
115
- key = var.to_s.delete("@").to_sym
116
- val = instance_variable_get(var)
117
-
118
- if authlete_model_simple_attribute?(key) or val.nil?
119
- hash[key] = val
120
- elsif val.kind_of?(Array)
121
- hash[key] = val.map { |element| element.to_hash }
122
- end
123
- end
124
-
125
- hash
126
- end
127
- end
128
- 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 ClientList < Authlete::Model::Hashable
24
+ include Authlete::Utility
25
+ # The start index (inclusive) of the clients in this list.
26
+ # (Integer)
27
+ attr_accessor :start
28
+
29
+ # The end index (exclusive) of the clients in this list.
30
+ # (Integer)
31
+ attr_accessor :end
32
+
33
+ # The total count of clients. (Integer)
34
+ attr_accessor :totalCount
35
+ alias_method :total_count, :totalCount
36
+ alias_method :total_count=, :totalCount=
37
+
38
+ # The list of clients. (Client array)
39
+ attr_accessor :clients
40
+
41
+ private
42
+
43
+ # Integer attributes.
44
+ INTEGER_ATTRIBUTES = ::Set.new([ :start, :end, :totalCount ])
45
+
46
+ # Mapping from snake cases to camel cases.
47
+ SNAKE_TO_CAMEL = { :total_count => :totalCount }
48
+
49
+ # The constructor
50
+ def initialize(hash = nil)
51
+ # Set default values to integer attributes.
52
+ INTEGER_ATTRIBUTES.each do |attr|
53
+ send("#{attr}=", 0)
54
+ end
55
+
56
+ @clients = nil
57
+
58
+ # Set attribute values using the given hash.
59
+ authlete_model_update(hash)
60
+ end
61
+
62
+ def authlete_model_convert_key(key)
63
+ key = key.to_sym
64
+
65
+ # Convert snakecase to camelcase, if necessary.
66
+ if SNAKE_TO_CAMEL.has_key?(key)
67
+ key = SNAKE_TO_CAMEL[key]
68
+ end
69
+
70
+ key
71
+ end
72
+
73
+ def authlete_model_simple_attribute?(key)
74
+ INTEGER_ATTRIBUTES.include?(key)
75
+ end
76
+
77
+ def authlete_model_update(hash)
78
+ return if hash.nil?
79
+
80
+ hash.each do |key, value|
81
+ key = authlete_model_convert_key(key)
82
+
83
+ if authlete_model_simple_attribute?(key)
84
+ send("#{key}=", value)
85
+ elsif key == :clients
86
+ # Get an array consisting of "Client" objects.
87
+ @clients = get_parsed_array(value) do |element|
88
+ Authlete::Model::Client.parse(element)
89
+ end
90
+ end
91
+ end
92
+
93
+ self
94
+ end
95
+
96
+ public
97
+
98
+ # Construct an instance from the given hash.
99
+ #
100
+ # If the given argument is nil or is not a Hash, nil is returned.
101
+ # Otherwise, ClientList.new(hash) is returned.
102
+ def self.parse(hash)
103
+ if hash.nil? or (hash.kind_of?(Hash) == false)
104
+ return nil
105
+ end
106
+
107
+ return ClientList.new(hash)
108
+ end
109
+
110
+ # Convert this object into a hash.
111
+ def to_hash
112
+ hash = {}
113
+
114
+ instance_variables.each do |var|
115
+ key = var.to_s.delete("@").to_sym
116
+ val = instance_variable_get(var)
117
+
118
+ if authlete_model_simple_attribute?(key) or val.nil?
119
+ hash[key] = val
120
+ elsif val.kind_of?(Array)
121
+ hash[key] = val.map { |element| element.to_hash }
122
+ end
123
+ end
124
+
125
+ hash
126
+ end
127
+ end
128
+ end
129
129
  end