Class List Method List File List

# Class: VertxAuthCommon::ChainAuth

Inherits:
  AuthProvider
  - Object
  - AuthProvider
  - VertxAuthCommon::ChainAuth
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb

## Overview

Chain several auth providers as if they were one. This is useful for cases where one want to authenticate across several providers, for example, database and fallback to passwd file.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxAuthCommon::ChainAuth) create
  Create a Chainable Auth Provider auth provider.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) append(other = nil)
  Appends a auth provider to the chain.
- - (void) authenticate(authInfo = nil) { ... }
  Authenticate a user.
- - (void) clear
  Clears the chain.
- - (true, false) remove(other = nil)
  Removes a provider from the chain.

## Class Method Details

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

Returns:

- (`Boolean`)

    21
    22
    23
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 21

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

### + (`::VertxAuthCommon::ChainAuth`) create

Create a Chainable Auth Provider auth provider

Returns:

- (`::VertxAuthCommon::ChainAuth`) —
  the auth provider

Raises:

- (`ArgumentError`)

    62
    63
    64
    65
    66
    67
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 62

    def self.create
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuth::ChainAuth.java_method(:create, []).call(),::VertxAuthCommon::ChainAuth)
      end
      raise ArgumentError, "Invalid arguments when calling create()"
    end

### + (`Object`) j_api_type

    30
    31
    32
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 30

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    33
    34
    35
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 33

    def self.j_class
      Java::IoVertxExtAuth::ChainAuth.java_class
    end

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

    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 27

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

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

    24
    25
    26
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 24

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

## Instance Method Details

### - (`self`) append(other = nil)

Appends a auth provider to the chain.

Parameters:

- other (`::VertxAuthCommon::AuthProvider`) (defaults to: `nil`) —
  auth provider

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    71
    72
    73
    74
    75
    76
    77
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 71

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

### - (`void`) authenticate(authInfo = nil) { ... }

This method returns an undefined value.

Authenticate a user.

The first argument is a JSON object containing information for authenticating the user. What this actually contains depends on the specific implementation. In the case of a simple username/password based authentication it is likely to contain a JSON object with the following structure:

       {
         "username": "tim",
         "password": "mypassword"
       }

For other types of authentication it contain different information - for example a JWT token or OAuth bearer token.

If the user is successfully authenticated a User object is passed to the handler in an AsyncResult. The user object can then be used for authorisation.

Parameters:

- authInfo (`Hash{String => Object}`) (defaults to: `nil`) —
  The auth information

Yields:

- The result handler

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 54

    def authenticate(authInfo=nil)
      if authInfo.class == Hash && block_given?
        return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(authInfo),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling authenticate(#{authInfo})"
    end

### - (`void`) clear

This method returns an undefined value.

Clears the chain.

Raises:

- (`ArgumentError`)

    89
    90
    91
    92
    93
    94
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 89

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

### - (`true`, `false`) remove(other = nil)

Removes a provider from the chain.

Parameters:

- other (`::VertxAuthCommon::AuthProvider`) (defaults to: `nil`) —
  provider to remove

Returns:

- (`true`, `false`) —
  true if provider was removed, false if non existent in the chain.

Raises:

- (`ArgumentError`)

    81
    82
    83
    84
    85
    86
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-common/chain_auth.rb', line 81

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