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-aggregator/modules/vertx-auth/vertx-auth-jwt/src/main/resources/vertx-auth-jwt/jwt_auth.rb

## Overview

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

## Class Method Summary (collapse)

- + (::VertxAuthJwt::JWTAuth) create(vertx = nil, config = nil)
  Create a JWT auth provider.

## Instance Method Summary (collapse)

- - (String) generate_token(claims = nil, options = nil)
  Generate a new JWT token.

## Class Method Details

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

    23
    24
    25
    26
    27
    28
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-jwt/src/main/resources/vertx-auth-jwt/jwt_auth.rb', line 23

    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

## Instance Method Details

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

    33
    34
    35
    36
    37
    38
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-jwt/src/main/resources/vertx-auth-jwt/jwt_auth.rb', line 33

    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