Class: VertxAuth::AuthProvider

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-auth-service/src/main/resources/vertx-auth/auth_provider.rb

Overview

This interface is implemented by auth providers which provide the actual auth functionality - e.g. we have a implementation which uses Apache Shiro.

If you wish to use the auth service with other providers, implement this interface for your provider.

Direct Known Subclasses

ShiroAuthProvider

Instance Method Summary (collapse)

Instance Method Details

- (void) has_permission(principal = nil, permission = nil) { ... }

This method returns an undefined value.

Handle whether a principal has a permission

Parameters:

  • principal (Hash{String => Object}) (defaults to: nil)
    represents the unique id (e.g. username) of the user being logged in
  • permission (String) (defaults to: nil)
    the permission

Yields:

  • this must return a failure if the check could not be performed - e.g. the principal is not known. Otherwise it must return a succeeded result which contains a boolean `true` if the principal has the permission, or `false` if they do not have the permission.

Raises:

  • (ArgumentError)


46
47
48
49
50
51
# File '/Users/julien/java/vertx-aggregator/modules/vertx-auth-service/src/main/resources/vertx-auth/auth_provider.rb', line 46

def has_permission(principal=nil,permission=nil)
  if principal.class == Hash && permission.class == String && block_given?
    return @j_del.java_method(:hasPermission, [Java::IoVertxCoreJson::JsonObject.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(principal),permission,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling has_permission(principal,permission)"
end

- (void) has_role(principal = nil, role = nil) { ... }

This method returns an undefined value.

Handle whether a principal has a role

Parameters:

  • principal (Hash{String => Object}) (defaults to: nil)
    represents the unique id (e.g. username) of the user being logged in
  • role (String) (defaults to: nil)
    the role

Yields:

  • this must return a failure if the check could not be performed - e.g. the principal is not known. Otherwise it must return a succeeded result which contains a boolean `true` if the principal has the role, or `false` if they do not have the role.

Raises:

  • (ArgumentError)


35
36
37
38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-auth-service/src/main/resources/vertx-auth/auth_provider.rb', line 35

def has_role(principal=nil,role=nil)
  if principal.class == Hash && role.class == String && block_given?
    return @j_del.java_method(:hasRole, [Java::IoVertxCoreJson::JsonObject.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(principal),role,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling has_role(principal,role)"
end

- (void) login(principal = nil, credentials = nil) { ... }

This method returns an undefined value.

Handle the actual login

Parameters:

  • principal (Hash{String => Object}) (defaults to: nil)
    represents the unique id (e.g. username) of the user being logged in
  • credentials (Hash{String => Object}) (defaults to: nil)
    the credentials - this can contain anything your provider expects, e.g. password

Yields:

  • - this must return a failed result if login fails and it must return a succeeded result if the login succeeds

Raises:

  • (ArgumentError)


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

def (principal=nil,credentials=nil)
  if principal.class == Hash && credentials.class == Hash && block_given?
    return @j_del.java_method(:login, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(principal),::Vertx::Util::Utils.to_json_object(credentials),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling login(principal,credentials)"
end