Class: VertxAuthCommon::AuthProvider

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb

Overview

User-facing interface for authenticating users.

Direct Known Subclasses

ChainAuth, VertxAuthHtdigest::HtdigestAuth, VertxAuthHtpasswd::HtpasswdAuth, VertxAuthJdbc::JDBCAuth, VertxAuthJwt::JWTAuth, VertxAuthMongo::MongoAuth, VertxAuthOauth2::OAuth2Auth, VertxAuthShiro::ShiroAuth

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


19
20
21
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb', line 19

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

+ (Object) j_api_type



28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb', line 28

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb', line 31

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

+ (Object) unwrap(obj)



25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb', line 25

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

+ (Object) wrap(obj)



22
23
24
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb', line 22

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

Instance Method Details

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


52
53
54
55
56
57
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/auth_provider.rb', line 52

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