Class: VertxAuthShiro::ShiroAuth

Inherits:
VertxAuthCommon::AuthProvider show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb

Overview

Factory interface for creating Apache Shiro based VertxAuthCommon::AuthProvider instances.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


20
21
22
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 20

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

+ (::VertxAuthShiro::ShiroAuth) create(vertx, options) + (::VertxAuthShiro::ShiroAuth) create(vertx, realmType, config)

Create a Shiro auth provider

Overloads:

Returns:

Raises:

  • (ArgumentError)


68
69
70
71
72
73
74
75
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 68

def self.create(param_1=nil,param_2=nil,param_3=nil)
  if param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthShiro::ShiroAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthShiro::ShiroAuthOptions.java_class]).call(param_1.j_del,Java::IoVertxExtAuthShiro::ShiroAuthOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxAuthShiro::ShiroAuth)
  elsif param_1.class.method_defined?(:j_del) && param_2.class == Symbol && param_3.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthShiro::ShiroAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthShiro::ShiroAuthRealmType.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(param_1.j_del,Java::IoVertxExtAuthShiro::ShiroAuthRealmType.valueOf(param_2.to_s),::Vertx::Util::Utils.to_json_object(param_3)),::VertxAuthShiro::ShiroAuth)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2},#{param_3})"
end

+ (Object) DEFAULT_ROLE_PREFIX

The default role prefix


86
87
88
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 86

def self.DEFAULT_ROLE_PREFIX
  Java::IoVertxExtAuthShiro::ShiroAuth.DEFAULT_ROLE_PREFIX
end

+ (Object) j_api_type



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 29

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 32

def self.j_class
  Java::IoVertxExtAuthShiro::ShiroAuth.java_class
end

+ (Object) unwrap(obj)



26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 26

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

+ (Object) wrap(obj)



23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 23

def @@j_api_type.wrap(obj)
  ShiroAuth.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 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)


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

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

- (::VertxAuthShiro::ShiroAuth) set_role_prefix(rolePrefix = nil)

Set the role prefix to distinguish from permissions when checking for isPermitted requests.

Parameters:

  • rolePrefix (String) (defaults to: nil)
    a Prefix e.g.: "role:"

Returns:

Raises:

  • (ArgumentError)


79
80
81
82
83
84
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-shiro/shiro_auth.rb', line 79

def set_role_prefix(rolePrefix=nil)
  if rolePrefix.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:setRolePrefix, [Java::java.lang.String.java_class]).call(rolePrefix),::VertxAuthShiro::ShiroAuth)
  end
  raise ArgumentError, "Invalid arguments when calling set_role_prefix(#{rolePrefix})"
end