Class: VertxAuthCommon::User

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

Overview

Represents an authenticates User and contains operations to authorise the user.

Please consult the documentation for a detailed explanation.

Direct Known Subclasses

VertxAuthOauth2::AccessToken

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-common/user.rb', line 20

def @@j_api_type.accept?(obj)
  obj.class == User
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-common/user.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-common/user.rb', line 32

def self.j_class
  Java::IoVertxExtAuth::User.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-common/user.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-common/user.rb', line 23

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

Instance Method Details

- (self) clear_cache

The User object will cache any authorities that it knows it has to avoid hitting the underlying auth provider each time. Use this method if you want to clear this cache.

Returns:

  • (self)

Raises:

  • (ArgumentError)


59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/user.rb', line 59

def clear_cache
  if !block_given?
    @j_del.java_method(:clearCache, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling clear_cache()"
end

- (self) is_authorised(authority = nil) { ... }

Parameters:

  • authority (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


49
50
51
52
53
54
55
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/user.rb', line 49

def is_authorised(authority=nil)
  if authority.class == String && block_given?
    @j_del.java_method(:isAuthorised, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(authority,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling is_authorised(#{authority})"
end

- (self) is_authorized(authority = nil) { ... }

Is the user authorised to

Parameters:

  • authority (String) (defaults to: nil)
    the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.

Yields:

  • handler that will be called with an AsyncResult containing the value `true` if the they has the authority or `false` otherwise.

Returns:

  • (self)

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/user.rb', line 39

def is_authorized(authority=nil)
  if authority.class == String && block_given?
    @j_del.java_method(:isAuthorized, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(authority,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling is_authorized(#{authority})"
end

- (Hash{String => Object}) principal

Get the underlying principal for the User. What this actually returns depends on the implementation. For a simple user/password based auth, it's likely to contain a JSON object with the following structure:

   {
     "username", "tim"
   }
 

Returns:

  • (Hash{String => Object})
    JSON representation of the Principal

Raises:

  • (ArgumentError)


74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/user.rb', line 74

def principal
  if !block_given?
    return @j_del.java_method(:principal, []).call() != nil ? JSON.parse(@j_del.java_method(:principal, []).call().encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling principal()"
end

- (void) set_auth_provider(authProvider = nil)

This method returns an undefined value.

Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. after it has been deserialized.

Parameters:

  • authProvider (::VertxAuthCommon::AuthProvider) (defaults to: nil)
    the AuthProvider - this must be the same type of AuthProvider that originally created the User

Raises:

  • (ArgumentError)


84
85
86
87
88
89
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-common/user.rb', line 84

def set_auth_provider(authProvider=nil)
  if authProvider.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:setAuthProvider, [Java::IoVertxExtAuth::AuthProvider.java_class]).call(authProvider.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling set_auth_provider(#{authProvider})"
end