Class: VertxAuthCommon::User
- Inherits:
-
Object
- Object
- VertxAuthCommon::User
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-common/src/main/resources/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.
Instance Method Summary (collapse)
-
- (self) clear_cache
The User object will cache any authorities that it knows it has to avoid hitting the underlying auth provider each time.
-
- (self) is_authorised(authority = nil) { ... }
Is the user authorised to.
-
- (Hash{String => Object}) principal
Get the underlying principal for the User.
-
- (void) set_auth_provider(authProvider = nil)
Set the auth provider for the User.
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.
33 34 35 36 37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb', line 33 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) { ... }
Is the user authorised to
23 24 25 26 27 28 29 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb', line 23 def (=nil) if .class == String && block_given? @j_del.java_method(:isAuthorised, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(,(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 |
- (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"
}
48 49 50 51 52 53 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb', line 48 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.
58 59 60 61 62 63 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-auth/vertx-auth-common/src/main/resources/vertx-auth-common/user.rb', line 58 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 |