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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from VertxAuthCommon::AuthProvider

#authenticate

Class Method Details

+ (::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)


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

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

Instance Method Details

- (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)


123
124
125
126
127
128
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 123

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)


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

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)


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

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)


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

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)


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_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)


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

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)


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

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)


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

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)


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

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)


215
216
217
218
219
220
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 215

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)


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

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)


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

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)


103
104
105
106
107
108
109
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 103

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)


59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 59

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)


81
82
83
84
85
86
87
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 81

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)


70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 70

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)


114
115
116
117
118
119
120
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 114

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)


92
93
94
95
96
97
98
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 92

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)


49
50
51
52
53
54
55
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/mongo_auth.rb', line 49

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