Class List Method List File List

# Class: VertxAuthJwt::JWTAuth

Inherits:
  VertxAuthCommon::AuthProvider
  - Object
  - VertxAuthCommon::AuthProvider
  - VertxAuthJwt::JWTAuth
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jwt/jwt_auth.rb

## Overview

Factory interface for creating JWT based VertxAuthCommon::AuthProvider instances.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxAuthJwt::JWTAuth) create(vertx = nil, config = nil)
  Create a JWT auth provider.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) authenticate(arg0 = nil) { ... }
- - (String) generate_token(claims = nil, options = nil)
  Generate a new JWT token.

## Class Method Details

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

Returns:

- (`Boolean`)

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

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

### + (`::VertxAuthJwt::JWTAuth`) create(vertx = nil, config = nil)

Create a JWT auth provider

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vertx instance
- config (`Hash{String => Object}`) (defaults to: `nil`) —
  the config

Returns:

- (`::VertxAuthJwt::JWTAuth`) —
  the auth provider

Raises:

- (`ArgumentError`)

    49
    50
    51
    52
    53
    54
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jwt/jwt_auth.rb', line 49

    def self.create(vertx=nil,config=nil)
      if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthJwt::JWTAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxAuthJwt::JWTAuth)
      end
      raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{config})"
    end

### + (`Object`) j_api_type

    30
    31
    32
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jwt/jwt_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-jwt/jwt_auth.rb', line 33

    def self.j_class
      Java::IoVertxExtAuthJwt::JWTAuth.java_class
    end

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

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

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

## Instance Method Details

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

This method returns an undefined value.

Parameters:

- arg0 (`Hash{String => Object}`) (defaults to: `nil`)

Yields:

Raises:

- (`ArgumentError`)

    39
    40
    41
    42
    43
    44
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jwt/jwt_auth.rb', line 39

    def authenticate(arg0=nil)
      if arg0.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(arg0),(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(#{arg0})"
    end

### - (`String`) generate_token(claims = nil, options = nil)

Generate a new JWT token.

Parameters:

- claims (`Hash{String => Object}`) (defaults to: `nil`) —
  Json with user defined claims for a list of official claims
- options (`Hash`) (defaults to: `nil`) —
  extra options for the generation

Returns:

- (`String`) —
  JWT encoded token

Raises:

- (`ArgumentError`)

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

    def generate_token(claims=nil,options=nil)
      if claims.class == Hash && options.class == Hash && !block_given?
        return @j_del.java_method(:generateToken, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtAuthJwt::JWTOptions.java_class]).call(::Vertx::Util::Utils.to_json_object(claims),Java::IoVertxExtAuthJwt::JWTOptions.new(::Vertx::Util::Utils.to_json_object(options)))
      end
      raise ArgumentError, "Invalid arguments when calling generate_token(#{claims},#{options})"
    end