Class: VertxAuthMongo::MongoAuth

Inherits:
VertxAuthCommon::AuthProvider show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb

Overview

An extension of AuthProvider which is using as store

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


22
23
24
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 22

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

+ (::VertxAuthMongo::MongoAuth) create(mongoClient = nil, config = nil)

Creates an instance of MongoAuth by using the given and configuration object. An example for a configuration object:

 JsonObject js = new JsonObject();
 js.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
 

Parameters:

  • mongoClient (::VertxMongo::MongoClient) (defaults to: nil)
    an instance of to be used for data storage and retrival
  • config (Hash{String => Object}) (defaults to: nil)
    the configuration object for the current instance. By this

Returns:

Raises:

  • (ArgumentError)


56
57
58
59
60
61
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 56

def self.create(mongoClient=nil,config=nil)
  if mongoClient.class.method_defined?(:j_del) && config.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthMongo::MongoAuth.java_method(:create, [Java::IoVertxExtMongo::MongoClient.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(mongoClient.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxAuthMongo::MongoAuth)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{mongoClient},#{config})"
end

+ (Object) j_api_type



31
32
33
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 31

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



34
35
36
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 34

def self.j_class
  Java::IoVertxExtAuthMongo::MongoAuth.java_class
end

+ (Object) unwrap(obj)



28
29
30
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 28

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

+ (Object) wrap(obj)



25
26
27
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 25

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

Instance Method Details

- (void) authenticate(arg0 = nil) { ... }

This method returns an undefined value.

Parameters:

  • arg0 (Hash{String => Object}) (defaults to: nil)

Yields:

Raises:

  • (ArgumentError)


40
41
42
43
44
45
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 40

def authenticate(arg0=nil)
  if arg0.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(arg0),(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(#{arg0})"
end

- (String) get_collection_name

The name of the collection used to store User objects inside. Defaults to DEFAULT_COLLECTION_NAME

Returns:

  • (String)
    the collectionName

Raises:

  • (ArgumentError)


149
150
151
152
153
154
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 149

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

- (::VertxAuthMongo::HashStrategy) get_hash_strategy

The HashStrategy which is used by the current instance

Returns:

Raises:

  • (ArgumentError)


228
229
230
231
232
233
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 228

def get_hash_strategy
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getHashStrategy, []).call(),::VertxAuthMongo::HashStrategy)
  end
  raise ArgumentError, "Invalid arguments when calling get_hash_strategy()"
end

- (String) get_password_credential_field

Get the name of the field to be used as property for the password of credentials in the method VertxAuthCommon::AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD

Returns:

  • (String)
    the passwordCredentialField

Raises:

  • (ArgumentError)


201
202
203
204
205
206
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 201

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

- (String) get_password_field

Get the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD

Returns:

  • (String)
    the passwordField

Raises:

  • (ArgumentError)


165
166
167
168
169
170
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 165

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

- (String) get_permission_field

Get the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD. Permissions are expected to be saved as JsonArray

Returns:

  • (String)
    the permissionField

Raises:

  • (ArgumentError)


183
184
185
186
187
188
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 183

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

- (String) get_role_field

Get the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to be saved as JsonArray

Returns:

  • (String)
    the roleField

Raises:

  • (ArgumentError)


174
175
176
177
178
179
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 174

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

- (String) get_salt_field

Get the name of the field to be used for the salt. Only used when HashStrategy#set_salt_style is set to

Returns:

  • (String)
    the saltField

Raises:

  • (ArgumentError)


210
211
212
213
214
215
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 210

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

- (String) get_username_credential_field

Get the name of the field to be used as property for the username in the method VertxAuthCommon::AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD

Returns:

  • (String)
    the usernameCredentialField

Raises:

  • (ArgumentError)


192
193
194
195
196
197
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 192

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

- (String) get_username_field

Get the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD

Returns:

  • (String)
    the usernameField

Raises:

  • (ArgumentError)


157
158
159
160
161
162
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 157

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

- (void) insert_user(username = nil, password = nil, roles = nil, permissions = nil) { ... }

This method returns an undefined value.

Insert a new user into mongo in the convenient way

Parameters:

  • username (String) (defaults to: nil)
    the username to be set
  • password (String) (defaults to: nil)
    the passsword in clear text, will be adapted following the definitions of the defined HashStrategy
  • roles (Array<String>) (defaults to: nil)
    a list of roles to be set
  • permissions (Array<String>) (defaults to: nil)
    a list of permissions to be set

Yields:

  • the ResultHandler will be provided with the id of the generated record

Raises:

  • (ArgumentError)


241
242
243
244
245
246
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 241

def insert_user(username=nil,password=nil,roles=nil,permissions=nil)
  if username.class == String && password.class == String && roles.class == Array && permissions.class == Array && block_given?
    return @j_del.java_method(:insertUser, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(username,password,roles.map { |element| element },permissions.map { |element| element },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling insert_user(#{username},#{password},#{roles},#{permissions})"
end

- (self) set_collection_name(collectionName = nil)

Set the name of the collection to be used. Defaults to DEFAULT_COLLECTION_NAME

Parameters:

  • collectionName (String) (defaults to: nil)
    the name of the collection to be used for storing and reading user data

Returns:

  • (self)

Raises:

  • (ArgumentError)


65
66
67
68
69
70
71
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 65

def set_collection_name(collectionName=nil)
  if collectionName.class == String && !block_given?
    @j_del.java_method(:setCollectionName, [Java::java.lang.String.java_class]).call(collectionName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_collection_name(#{collectionName})"
end

- (self) set_hash_strategy(hashStrategy = nil)

The HashStrategy which is used by the current instance

Parameters:

Returns:

  • (self)

Raises:

  • (ArgumentError)


219
220
221
222
223
224
225
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 219

def set_hash_strategy(hashStrategy=nil)
  if hashStrategy.class.method_defined?(:j_del) && !block_given?
    @j_del.java_method(:setHashStrategy, [Java::IoVertxExtAuthMongo::HashStrategy.java_class]).call(hashStrategy.j_del)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_hash_strategy(#{hashStrategy})"
end

- (self) set_password_credential_field(fieldName = nil)

Set the name of the field to be used as property for the password of credentials in the method VertxAuthCommon::AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


129
130
131
132
133
134
135
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 129

def set_password_credential_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setPasswordCredentialField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_password_credential_field(#{fieldName})"
end

- (self) set_password_field(fieldName = nil)

Set the name of the field to be used for the password Defaults to DEFAULT_PASSWORD_FIELD

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


85
86
87
88
89
90
91
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 85

def set_password_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setPasswordField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_password_field(#{fieldName})"
end

- (self) set_permission_field(fieldName = nil)

Set the name of the field to be used for the permissions. Defaults to DEFAULT_PERMISSION_FIELD. Permissions are expected to be saved as JsonArray

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


107
108
109
110
111
112
113
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 107

def set_permission_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setPermissionField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_permission_field(#{fieldName})"
end

- (self) set_role_field(fieldName = nil)

Set the name of the field to be used for the roles. Defaults to DEFAULT_ROLE_FIELD. Roles are expected to be saved as JsonArray

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


96
97
98
99
100
101
102
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 96

def set_role_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setRoleField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_role_field(#{fieldName})"
end

- (self) set_salt_field(fieldName = nil)

Set the name of the field to be used for the salt. Only used when HashStrategy#set_salt_style is set to

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


140
141
142
143
144
145
146
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 140

def set_salt_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setSaltField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_salt_field(#{fieldName})"
end

- (self) set_username_credential_field(fieldName = nil)

Set the name of the field to be used as property for the username in the method VertxAuthCommon::AuthProvider#authenticate. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


118
119
120
121
122
123
124
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 118

def set_username_credential_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setUsernameCredentialField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_username_credential_field(#{fieldName})"
end

- (self) set_username_field(fieldName = nil)

Set the name of the field to be used for the username. Defaults to DEFAULT_USERNAME_FIELD

Parameters:

  • fieldName (String) (defaults to: nil)
    the name of the field to be used

Returns:

  • (self)

Raises:

  • (ArgumentError)


75
76
77
78
79
80
81
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 75

def set_username_field(fieldName=nil)
  if fieldName.class == String && !block_given?
    @j_del.java_method(:setUsernameField, [Java::java.lang.String.java_class]).call(fieldName)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_username_field(#{fieldName})"
end