Class: Authlete::Model::Response::IntrospectionResponse

Inherits:
Authlete::Model::Result show all
Includes:
Utility
Defined in:
lib/authlete/model/response/introspection-response.rb

Instance Attribute Summary collapse

Attributes inherited from Authlete::Model::Result

#resultCode, #resultMessage

Instance Method Summary collapse

Methods included from Utility

#extract_access_token, #get_parsed_array, #to_rack_response_json, #to_rack_response_www_authenticate

Methods inherited from Base

parse

Instance Attribute Details

#accessTokenResourcesObject Also known as: access_token_resources

Returns the value of attribute accessTokenResources.



74
75
76
# File 'lib/authlete/model/response/introspection-response.rb', line 74

def accessTokenResources
  @accessTokenResources
end

#actionObject

Returns the value of attribute action.



24
25
26
# File 'lib/authlete/model/response/introspection-response.rb', line 24

def action
  @action
end

#certificateThumbprintObject Also known as: certificate_thumbprint

Returns the value of attribute certificateThumbprint.



68
69
70
# File 'lib/authlete/model/response/introspection-response.rb', line 68

def certificateThumbprint
  @certificateThumbprint
end

#clientIdObject Also known as: client_id

Returns the value of attribute clientId.



26
27
28
# File 'lib/authlete/model/response/introspection-response.rb', line 26

def clientId
  @clientId
end

#clientIdAliasObject Also known as: client_id_alias

Returns the value of attribute clientIdAlias.



30
31
32
# File 'lib/authlete/model/response/introspection-response.rb', line 30

def clientIdAlias
  @clientIdAlias
end

#clientIdAliasUsedObject Also known as: client_id_alias_used

Returns the value of attribute clientIdAliasUsed.



34
35
36
# File 'lib/authlete/model/response/introspection-response.rb', line 34

def clientIdAliasUsed
  @clientIdAliasUsed
end

#existentObject Also known as: existent?, exists, exists?, exist, exist?

Returns the value of attribute existent.



46
47
48
# File 'lib/authlete/model/response/introspection-response.rb', line 46

def existent
  @existent
end

#expiresAtObject Also known as: expires_at

Returns the value of attribute expiresAt.



38
39
40
# File 'lib/authlete/model/response/introspection-response.rb', line 38

def expiresAt
  @expiresAt
end

#propertiesObject

Returns the value of attribute properties.



66
67
68
# File 'lib/authlete/model/response/introspection-response.rb', line 66

def properties
  @properties
end

#refreshableObject Also known as: refreshable?

Returns the value of attribute refreshable.



59
60
61
# File 'lib/authlete/model/response/introspection-response.rb', line 59

def refreshable
  @refreshable
end

#resourcesObject

Returns the value of attribute resources.



72
73
74
# File 'lib/authlete/model/response/introspection-response.rb', line 72

def resources
  @resources
end

#responseContentObject Also known as: response_content

Returns the value of attribute responseContent.



62
63
64
# File 'lib/authlete/model/response/introspection-response.rb', line 62

def responseContent
  @responseContent
end

#scopesObject

Returns the value of attribute scopes.



44
45
46
# File 'lib/authlete/model/response/introspection-response.rb', line 44

def scopes
  @scopes
end

#subjectObject

Returns the value of attribute subject.



42
43
44
# File 'lib/authlete/model/response/introspection-response.rb', line 42

def subject
  @subject
end

#sufficientObject Also known as: sufficient?

Returns the value of attribute sufficient.



56
57
58
# File 'lib/authlete/model/response/introspection-response.rb', line 56

def sufficient
  @sufficient
end

#usableObject Also known as: usable?

Returns the value of attribute usable.



53
54
55
# File 'lib/authlete/model/response/introspection-response.rb', line 53

def usable
  @usable
end

Instance Method Details

#to_rack_responseObject

Generate an array which is usable as a Rack response from this instance. When action method returns other value than ‘OK’, the array returned from this method satisfies RFC 6750.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/authlete/model/response/introspection-response.rb', line 127

def to_rack_response
  # 'action' denotes the next action.
  case @action
    when 'INTERNAL_SERVER_ERROR'
      # 500 Internal Server Error
      #   The API request from this implementation was wrong
      #   or an error occurred in Authlete.
      return to_rack_response_www_authenticate(500, @response_content)

    when 'BAD_REQUEST'
      # 400 Bad Request
      #   The request from the client application does not
      #   contain an access token.
      return to_rack_response_www_authenticate(400, @response_content)

    when 'UNAUTHORIZED'
      # 401 Unauthorized
      #   The presented access token does not exist or has expired.
      return to_rack_response_www_authenticate(401, @response_content)

    when 'FORBIDDEN'
      # 403 Forbidden
      #   The access token does not cover the required scopes
      #   or the subject associated with the access token is
      #   different.
      return to_rack_response_www_authenticate(403, @response_content)

    when 'OK'
      # The access token is valid (= exists and has not expired).
      # Basically, the caller won't use the array returned from here.
      # Instead, it will return the protected resource to the client
      # application which has presented the valid access token.
      return [ 200, nil, nil ]

    else
      # This should not happen.
      return to_rack_response_www_authenticate(500,
        'Bearer error="server_error",error_description="Unknown action"')
  end
end