Class: VertxAuthOauth2::AccessToken

Inherits:
VertxAuthCommon::User show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb

Overview

AccessToken extension to the User interface

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


21
22
23
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 21

def @@j_api_type.accept?(obj)
  obj.class == AccessToken
end

+ (Object) j_api_type



30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 30

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 33

def self.j_class
  Java::IoVertxExtAuthOauth2::AccessToken.java_class
end

+ (Object) unwrap(obj)



27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 27

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 24

def @@j_api_type.wrap(obj)
  AccessToken.new(obj)
end

Instance Method Details

- (Hash{String => Object}) access_token

The Access Token if present parsed as a JsonObject

Returns:

  • (Hash{String => Object})
    JSON

Raises:

  • (ArgumentError)


101
102
103
104
105
106
107
108
109
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 101

def access_token
  if !block_given?
    if @cached_access_token != nil
      return @cached_access_token
    end
    return @cached_access_token = @j_del.java_method(:accessToken, []).call() != nil ? JSON.parse(@j_del.java_method(:accessToken, []).call().encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling access_token()"
end

- (self) clear_cache

The User object will cache any authorities that it knows it has to avoid hitting the underlying auth provider each time. Use this method if you want to clear this cache.

Returns:

  • (self)

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 60

def clear_cache
  if !block_given?
    @j_del.java_method(:clearCache, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling clear_cache()"
end

- (true, false) expired?

Check if the access token is expired or not.

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


93
94
95
96
97
98
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 93

def expired?
  if !block_given?
    return @j_del.java_method(:expired, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling expired?()"
end

- (self) fetch(resource, callback) { ... } - (self) fetch(method, resource, headers, payload, callback) { ... }

Fetches a JSON resource using this Access Token.

Overloads:

  • - (self) fetch(resource, callback) { ... }

    Parameters:

    • resource (String)
      - the resource to fetch.

    Yields:

    • - The callback function returning the results.
  • - (self) fetch(method, resource, headers, payload, callback) { ... }

    Parameters:

    • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER)
      - the HTTP method to user.
    • resource (String)
      - the resource to fetch.
    • headers (Hash{String => Object})
      - extra headers to pass to the request.
    • payload (::Vertx::Buffer)
      - payload to send to the server.

    Yields:

    • - The callback function returning the results.

Returns:

  • (self)

Raises:

  • (ArgumentError)


239
240
241
242
243
244
245
246
247
248
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 239

def fetch(param_1=nil,param_2=nil,param_3=nil,param_4=nil)
  if param_1.class == String && block_given? && param_2 == nil && param_3 == nil && param_4 == nil
    @j_del.java_method(:fetch, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::OAuth2Response) : nil) }))
    return self
  elsif param_1.class == Symbol && param_2.class == String && param_3.class == Hash && param_4.class.method_defined?(:j_del) && block_given?
    @j_del.java_method(:fetch, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1.to_s),param_2,::Vertx::Util::Utils.to_json_object(param_3),param_4.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::OAuth2Response) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{param_1},#{param_2},#{param_3},#{param_4})"
end

- (Hash{String => Object}) id_token

The Id Token if present parsed as a JsonObject

Returns:

  • (Hash{String => Object})
    JSON

Raises:

  • (ArgumentError)


123
124
125
126
127
128
129
130
131
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 123

def id_token
  if !block_given?
    if @cached_id_token != nil
      return @cached_id_token
    end
    return @cached_id_token = @j_del.java_method(:idToken, []).call() != nil ? JSON.parse(@j_del.java_method(:idToken, []).call().encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling id_token()"
end

- (self) introspect(tokenType = nil) { ... }

Introspect access token. This is an OAuth2 extension that allow to verify if an access token is still valid.

Parameters:

  • tokenType (String) (defaults to: nil)
    - A String containing the type of token to revoke. Should be either "access_token" or "refresh_token".

Yields:

  • - The callback function returning the results.

Returns:

  • (self)

Raises:

  • (ArgumentError)


208
209
210
211
212
213
214
215
216
217
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 208

def introspect(tokenType=nil)
  if block_given? && tokenType == nil
    @j_del.java_method(:introspect, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  elsif tokenType.class == String && block_given?
    @j_del.java_method(:introspect, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(tokenType,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling introspect(#{tokenType})"
end

- (self) is_authorised(authority = nil) { ... }

Parameters:

  • authority (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


50
51
52
53
54
55
56
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 50

def is_authorised(authority=nil)
  if authority.class == String && block_given?
    @j_del.java_method(:isAuthorised, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(authority,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling is_authorised(#{authority})"
end

- (self) is_authorized(authority = nil) { ... }

Is the user authorised to

Parameters:

  • authority (String) (defaults to: nil)
    the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.

Yields:

  • handler that will be called with an AsyncResult containing the value `true` if the they has the authority or `false` otherwise.

Returns:

  • (self)

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 40

def is_authorized(authority=nil)
  if authority.class == String && block_given?
    @j_del.java_method(:isAuthorized, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(authority,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling is_authorized(#{authority})"
end

- (self) logout { ... }

Revoke refresh token and calls the logout endpoint. This is a openid-connect extension and might not be available on all providers.

Yields:

  • - The callback function returning the results.

Returns:

  • (self)

Raises:

  • (ArgumentError)


197
198
199
200
201
202
203
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 197

def logout
  if block_given?
    @j_del.java_method(:logout, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling logout()"
end

- (String) opaque_access_token

The RAW String if available for the Access Token

Returns:

  • (String)
    String

Raises:

  • (ArgumentError)


134
135
136
137
138
139
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 134

def opaque_access_token
  if !block_given?
    return @j_del.java_method(:opaqueAccessToken, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling opaque_access_token()"
end

- (String) opaque_id_token

The RAW String if available for the Id Token

Returns:

  • (String)
    String

Raises:

  • (ArgumentError)


150
151
152
153
154
155
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 150

def opaque_id_token
  if !block_given?
    return @j_del.java_method(:opaqueIdToken, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling opaque_id_token()"
end

- (String) opaque_refresh_token

The RAW String if available for the Refresh Token

Returns:

  • (String)
    String

Raises:

  • (ArgumentError)


142
143
144
145
146
147
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 142

def opaque_refresh_token
  if !block_given?
    return @j_del.java_method(:opaqueRefreshToken, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling opaque_refresh_token()"
end

- (Hash{String => Object}) principal

Get the underlying principal for the User. What this actually returns depends on the implementation. For a simple user/password based auth, it's likely to contain a JSON object with the following structure:

   {
     "username", "tim"
   }
 

Returns:

  • (Hash{String => Object})
    JSON representation of the Principal

Raises:

  • (ArgumentError)


75
76
77
78
79
80
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 75

def principal
  if !block_given?
    return @j_del.java_method(:principal, []).call() != nil ? JSON.parse(@j_del.java_method(:principal, []).call().encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling principal()"
end

- (self) refresh { ... }

Refresh the access token

Yields:

  • - The callback function returning the results.

Returns:

  • (self)

Raises:

  • (ArgumentError)


175
176
177
178
179
180
181
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 175

def refresh
  if block_given?
    @j_del.java_method(:refresh, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling refresh()"
end

- (Hash{String => Object}) refresh_token

The Refresh Token if present parsed as a JsonObject

Returns:

  • (Hash{String => Object})
    JSON

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
119
120
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 112

def refresh_token
  if !block_given?
    if @cached_refresh_token != nil
      return @cached_refresh_token
    end
    return @cached_refresh_token = @j_del.java_method(:refreshToken, []).call() != nil ? JSON.parse(@j_del.java_method(:refreshToken, []).call().encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling refresh_token()"
end

- (self) revoke(token_type = nil) { ... }

Revoke access or refresh token

Parameters:

  • token_type (String) (defaults to: nil)
    - A String containing the type of token to revoke. Should be either "access_token" or "refresh_token".

Yields:

  • - The callback function returning the results.

Returns:

  • (self)

Raises:

  • (ArgumentError)


186
187
188
189
190
191
192
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 186

def revoke(token_type=nil)
  if token_type.class == String && block_given?
    @j_del.java_method(:revoke, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token_type,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling revoke(#{token_type})"
end

- (void) set_auth_provider(authProvider = nil)

This method returns an undefined value.

Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. after it has been deserialized.

Parameters:

  • authProvider (::VertxAuthCommon::AuthProvider) (defaults to: nil)
    the AuthProvider - this must be the same type of AuthProvider that originally created the User

Raises:

  • (ArgumentError)


85
86
87
88
89
90
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 85

def set_auth_provider(authProvider=nil)
  if authProvider.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:setAuthProvider, [Java::IoVertxExtAuth::AuthProvider.java_class]).call(authProvider.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling set_auth_provider(#{authProvider})"
end

- (self) set_trust_jwt(trust = nil)

Parameters:

  • trust (true, false) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


165
166
167
168
169
170
171
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 165

def set_trust_jwt(trust=nil)
  if (trust.class == TrueClass || trust.class == FalseClass) && !block_given?
    @j_del.java_method(:setTrustJWT, [Java::boolean.java_class]).call(trust)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_trust_jwt(#{trust})"
end

- (String) token_type

Returns:

  • (String)

Raises:

  • (ArgumentError)


157
158
159
160
161
162
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 157

def token_type
  if !block_given?
    return @j_del.java_method(:tokenType, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling token_type()"
end

- (self) user_info { ... }

Load the user info as per OIDC spec.

Yields:

  • - The callback function returning the results.

Returns:

  • (self)

Raises:

  • (ArgumentError)


221
222
223
224
225
226
227
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/access_token.rb', line 221

def 
  if block_given?
    @j_del.java_method(:userInfo, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling user_info()"
end