Class List Method List File List

# Class: VertxWeb::ChainAuthHandler

Inherits:
  Object
  - Object
  - VertxWeb::ChainAuthHandler
  show all
Includes:
  AuthHandler
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb

## Overview

An auth handler that chains to a sequence of handlers.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxWeb::ChainAuthHandler) create
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) add_authorities(authorities = nil)
  Add a set of required authorities for this auth handler.
- - (self) add_authority(authority = nil)
  Add a required authority for this auth handler.
- - (self) append(authHandler = nil)
  Appends a auth provider to the chain.
- - (void) authorize(user = nil) { ... }
  Authorizes the given user against all added authorities.
- - (void) clear
  Clears the chain.
- - (void) handle(arg0 = nil)
- - (void) parse_credentials(context = nil) { ... }
  Parses the credentials from the request into a JsonObject.
- - (true, false) remove?(authHandler = 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-web/chain_auth_handler.rb', line 21

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

### + (`::VertxWeb::ChainAuthHandler`) create

Returns:

- (`::VertxWeb::ChainAuthHandler`)

Raises:

- (`ArgumentError`)

    87
    88
    89
    90
    91
    92
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 87

    def self.create
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::ChainAuthHandler.java_method(:create, []).call(),::VertxWeb::ChainAuthHandler)
      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-web/chain_auth_handler.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-web/chain_auth_handler.rb', line 33

    def self.j_class
      Java::IoVertxExtWebHandler::ChainAuthHandler.java_class
    end

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

    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.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-web/chain_auth_handler.rb', line 24

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

## Instance Method Details

### - (`self`) add_authorities(authorities = nil)

Add a set of required authorities for this auth handler

Parameters:

- authorities (`Set<String>`) (defaults to: `nil`) —
  the set of authorities

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    57
    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 57

    def add_authorities(authorities=nil)
      if authorities.class == Set && !block_given?
        @j_del.java_method(:addAuthorities, [Java::JavaUtil::Set.java_class]).call(Java::JavaUtil::LinkedHashSet.new(authorities.map { |element| element }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling add_authorities(#{authorities})"
    end

### - (`self`) add_authority(authority = nil)

Add a required authority for this auth handler

Parameters:

- authority (`String`) (defaults to: `nil`) —
  the authority

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    47
    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 47

    def add_authority(authority=nil)
      if authority.class == String && !block_given?
        @j_del.java_method(:addAuthority, [Java::java.lang.String.java_class]).call(authority)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling add_authority(#{authority})"
    end

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

Appends a auth provider to the chain.

Parameters:

- authHandler (`::VertxWeb::AuthHandler`) (defaults to: `nil`) —
  auth handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    96
    97
    98
    99
    100
    101
    102
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 96

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

### - (`void`) authorize(user = nil) { ... }

This method returns an undefined value.

Authorizes the given user against all added authorities.

Parameters:

- user (`::VertxAuthCommon::User`) (defaults to: `nil`) —
  a user.

Yields:

- the handler for the result.

Raises:

- (`ArgumentError`)

    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 80

    def authorize(user=nil)
      if user.class.method_defined?(:j_del) && block_given?
        return @j_del.java_method(:authorize, [Java::IoVertxExtAuth::User.java_class,Java::IoVertxCore::Handler.java_class]).call(user.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling authorize(#{user})"
    end

### - (`void`) clear

This method returns an undefined value.

Clears the chain.

Raises:

- (`ArgumentError`)

    114
    115
    116
    117
    118
    119
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 114

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

### - (`void`) handle(arg0 = nil)

This method returns an undefined value.

Parameters:

- arg0 (`::VertxWeb::RoutingContext`) (defaults to: `nil`)

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 38

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

### - (`void`) parse_credentials(context = nil) { ... }

This method returns an undefined value.

Parses the credentials from the request into a JsonObject. The implementation should be able to extract the required info for the auth provider in the format the provider expects.

Parameters:

- context (`::VertxWeb::RoutingContext`) (defaults to: `nil`) —
  the routing context

Yields:

- the handler to be called once the information is available.

Raises:

- (`ArgumentError`)

    70
    71
    72
    73
    74
    75
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 70

    def parse_credentials(context=nil)
      if context.class.method_defined?(:j_del) && block_given?
        return @j_del.java_method(:parseCredentials, [Java::IoVertxExtWeb::RoutingContext.java_class,Java::IoVertxCore::Handler.java_class]).call(context.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling parse_credentials(#{context})"
    end

### - (`true`, `false`) remove?(authHandler = nil)

Removes a provider from the chain.

Parameters:

- authHandler (`::VertxWeb::AuthHandler`) (defaults to: `nil`) —
  provider to remove

Returns:

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

Raises:

- (`ArgumentError`)

    106
    107
    108
    109
    110
    111
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/chain_auth_handler.rb', line 106

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