Class List Method List File List

# Class: VertxAuthOauth2::AccessToken

Inherits:
  VertxAuthCommon::User
  - Object
  - VertxAuthCommon::User
  - VertxAuthOauth2::AccessToken
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb

## Overview

AccessToken extension to the User interface

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (Hash{String => Object}) access_token
  The Access Token if present parsed as a JsonObject.
- - (self) clear_cache
- - (true, false) expired?
  Check if the access token is expired or not.
- - (self) fetch(param_1 = nil, param_2 = nil, param_3 = nil, param_4 = nil)
  Fetches a JSON resource using this Access Token.
- - (self) introspect(tokenType = nil) { ... }
  Introspect access token.
- - (self) is_authorised(authority = nil) { ... }
- - (self) is_authorized(arg0 = nil) { ... }
- - (self) logout { ... }
  Revoke refresh token and calls the logout endpoint.
- - (Hash{String => Object}) principal
- - (self) refresh { ... }
  Refresh the access token.
- - (self) revoke(token_type = nil) { ... }
  Revoke access or refresh token.
- - (void) set_auth_provider(arg0 = nil)
- - (self) user_info { ... }
  Load the user info as per OIDC spec.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    22
    23
    24
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 22

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

### + (`Object`) j_api_type

    31
    32
    33
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 31

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    34
    35
    36
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 34

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

### + (`Object`) unwrap(obj)

    28
    29
    30
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 28

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

### + (`Object`) wrap(obj)

    25
    26
    27
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 25

    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`)

    90
    91
    92
    93
    94
    95
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 90

    def access_token
      if !block_given?
        return @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

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    58
    59
    60
    61
    62
    63
    64
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 58

    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`)

    82
    83
    84
    85
    86
    87
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 82

    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`)

    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 163

    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

### - (`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`)

    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 132

    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-stack/stack-docs/target/rb/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(arg0 = nil) { ... }

Parameters:

- arg0 (`String`) (defaults to: `nil`)

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    46
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 40

    def is_authorized(arg0=nil)
      if arg0.class == String && block_given?
        @j_del.java_method(:isAuthorized, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(arg0,(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(#{arg0})"
    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`)

    121
    122
    123
    124
    125
    126
    127
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 121

    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

### - (`Hash{String => Object}`) principal

Returns:

- (`Hash{String => Object}`)

Raises:

- (`ArgumentError`)

    66
    67
    68
    69
    70
    71
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 66

    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`)

    99
    100
    101
    102
    103
    104
    105
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 99

    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

### - (`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`)

    110
    111
    112
    113
    114
    115
    116
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 110

    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(arg0 = nil)

This method returns an undefined value.

Parameters:

- arg0 (`::VertxAuthCommon::AuthProvider`) (defaults to: `nil`)

Raises:

- (`ArgumentError`)

    74
    75
    76
    77
    78
    79
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 74

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

### - (`self`) user_info { ... }

Load the user info as per OIDC spec.

Yields:

- - The callback function returning the results.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    145
    146
    147
    148
    149
    150
    151
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/access_token.rb', line 145

    def user_info
      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