io.vertx.ext.auth.mongo

## Interface MongoAuth

- All Superinterfaces:
    AuthProvider

      public interface MongoAuth
      extends AuthProvider

  An extension of AuthProvider which is using `MongoClient` as store
  Author:
    mremme

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_COLLECTION_NAME` The default name of the collection to be used
    `static String` | `DEFAULT_CREDENTIAL_PASSWORD_FIELD` The default name of the property for the password, like it is transported in credentials by method `AuthProvider.authenticate(JsonObject, Handler)`
    `static String` | `DEFAULT_CREDENTIAL_USERNAME_FIELD` The default name of the property for the username, like it is transported in credentials by method `AuthProvider.authenticate(JsonObject, Handler)`
    `static String` | `DEFAULT_PASSWORD_FIELD` The default name of the property for the password, like it is stored in mongodb
    `static String` | `DEFAULT_PERMISSION_FIELD` The default name of the property for the permissions, like it is stored in mongodb.
    `static String` | `DEFAULT_ROLE_FIELD` The default name of the property for the roles, like it is stored in mongodb.
    `static String` | `DEFAULT_SALT_FIELD` The default name of the property for the salt field
    `static String` | `DEFAULT_USERNAME_FIELD` The default name of the property for the username, like it is stored in mongodb
    `static String` | `PROPERTY_COLLECTION_NAME` The property name to be used to set the name of the collection inside the config
    `static String` | `PROPERTY_CREDENTIAL_PASSWORD_FIELD` The property name to be used to set the name of the field, where the password for the credentials is stored inside
    `static String` | `PROPERTY_CREDENTIAL_USERNAME_FIELD` The property name to be used to set the name of the field, where the username for the credentials is stored inside
    `static String` | `PROPERTY_PASSWORD_FIELD` The property name to be used to set the name of the field, where the password is stored inside
    `static String` | `PROPERTY_PERMISSION_FIELD` The property name to be used to set the name of the field, where the permissions are stored inside
    `static String` | `PROPERTY_ROLE_FIELD` The property name to be used to set the name of the field, where the roles are stored inside
    `static String` | `PROPERTY_SALT_FIELD` The property name to be used to set the name of the field, where the SALT is stored inside
    `static String` | `PROPERTY_SALT_STYLE` The property name to be used to set the name of the field, where the salt style is stored inside
    `static String` | `PROPERTY_USERNAME_FIELD` The property name to be used to set the name of the field, where the username is stored inside
    `static String` | `ROLE_PREFIX` The prefix which is used by the method `User.isAuthorised(String, Handler)` when checking for role access

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static MongoAuth` | `create(MongoClient mongoClient, JsonObject config)` Creates an instance of MongoAuth by using the given `MongoClient` and configuration object.
    `String` | `getCollectionName()` The name of the collection used to store User objects inside.
    `HashStrategy` | `getHashStrategy()` The HashStrategy which is used by the current instance
    `String` | `getPasswordCredentialField()` Get the name of the field to be used as property for the password of credentials in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`.
    `String` | `getPasswordField()` Get the name of the field to be used for the password Defaults to `DEFAULT_PASSWORD_FIELD`
    `String` | `getPermissionField()` Get the name of the field to be used for the permissions.
    `String` | `getRoleField()` Get the name of the field to be used for the roles.
    `String` | `getSaltField()` Get the name of the field to be used for the salt.
    `String` | `getUsernameCredentialField()` Get the name of the field to be used as property for the username in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`.
    `String` | `getUsernameField()` Get the name of the field to be used for the username.
    `void` | `insertUser(String username, String password, List<String> roles, List<String> permissions, Handler<AsyncResult<String>> resultHandler)` Insert a new user into mongo in the convenient way
    `MongoAuth` | `setCollectionName(String collectionName)` Set the name of the collection to be used.
    `MongoAuth` | `setHashStrategy(HashStrategy hashStrategy)` The HashStrategy which is used by the current instance
    `MongoAuth` | `setPasswordCredentialField(String fieldName)` Set the name of the field to be used as property for the password of credentials in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`.
    `MongoAuth` | `setPasswordField(String fieldName)` Set the name of the field to be used for the password Defaults to `DEFAULT_PASSWORD_FIELD`
    `MongoAuth` | `setPermissionField(String fieldName)` Set the name of the field to be used for the permissions.
    `MongoAuth` | `setRoleField(String fieldName)` Set the name of the field to be used for the roles.
    `MongoAuth` | `setSaltField(String fieldName)` Set the name of the field to be used for the salt.
    `MongoAuth` | `setUsernameCredentialField(String fieldName)` Set the name of the field to be used as property for the username in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`.
    `MongoAuth` | `setUsernameField(String fieldName)` Set the name of the field to be used for the username.

    - ### Methods inherited from interface io.vertx.ext.auth.AuthProvider

      `authenticate`

- - ### Field Detail

    - #### PROPERTY_COLLECTION_NAME

          static final String PROPERTY_COLLECTION_NAME

      The property name to be used to set the name of the collection inside the config
      See Also:
        Constant Field Values

    - #### PROPERTY_USERNAME_FIELD

          static final String PROPERTY_USERNAME_FIELD

      The property name to be used to set the name of the field, where the username is stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_ROLE_FIELD

          static final String PROPERTY_ROLE_FIELD

      The property name to be used to set the name of the field, where the roles are stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_PERMISSION_FIELD

          static final String PROPERTY_PERMISSION_FIELD

      The property name to be used to set the name of the field, where the permissions are stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_PASSWORD_FIELD

          static final String PROPERTY_PASSWORD_FIELD

      The property name to be used to set the name of the field, where the password is stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_CREDENTIAL_USERNAME_FIELD

          static final String PROPERTY_CREDENTIAL_USERNAME_FIELD

      The property name to be used to set the name of the field, where the username for the credentials is stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_CREDENTIAL_PASSWORD_FIELD

          static final String PROPERTY_CREDENTIAL_PASSWORD_FIELD

      The property name to be used to set the name of the field, where the password for the credentials is stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_SALT_FIELD

          static final String PROPERTY_SALT_FIELD

      The property name to be used to set the name of the field, where the SALT is stored inside
      See Also:
        Constant Field Values

    - #### PROPERTY_SALT_STYLE

          static final String PROPERTY_SALT_STYLE

      The property name to be used to set the name of the field, where the salt style is stored inside
      See Also:
        `HashSaltStyle`, Constant Field Values

    - #### DEFAULT_COLLECTION_NAME

          static final String DEFAULT_COLLECTION_NAME

      The default name of the collection to be used
      See Also:
        Constant Field Values

    - #### DEFAULT_USERNAME_FIELD

          static final String DEFAULT_USERNAME_FIELD

      The default name of the property for the username, like it is stored in mongodb
      See Also:
        Constant Field Values

    - #### DEFAULT_PASSWORD_FIELD

          static final String DEFAULT_PASSWORD_FIELD

      The default name of the property for the password, like it is stored in mongodb
      See Also:
        Constant Field Values

    - #### DEFAULT_ROLE_FIELD

          static final String DEFAULT_ROLE_FIELD

      The default name of the property for the roles, like it is stored in mongodb. Roles are expected to be saved as JsonArray
      See Also:
        Constant Field Values

    - #### DEFAULT_PERMISSION_FIELD

          static final String DEFAULT_PERMISSION_FIELD

      The default name of the property for the permissions, like it is stored in mongodb. Permissions are expected to be saved as JsonArray
      See Also:
        Constant Field Values

    - #### DEFAULT_CREDENTIAL_USERNAME_FIELD

          static final String DEFAULT_CREDENTIAL_USERNAME_FIELD

      The default name of the property for the username, like it is transported in credentials by method `AuthProvider.authenticate(JsonObject, Handler)`
      See Also:
        Constant Field Values

    - #### DEFAULT_CREDENTIAL_PASSWORD_FIELD

          static final String DEFAULT_CREDENTIAL_PASSWORD_FIELD

      The default name of the property for the password, like it is transported in credentials by method `AuthProvider.authenticate(JsonObject, Handler)`
      See Also:
        Constant Field Values

    - #### DEFAULT_SALT_FIELD

          static final String DEFAULT_SALT_FIELD

      The default name of the property for the salt field
      See Also:
        Constant Field Values

    - #### ROLE_PREFIX

          static final String ROLE_PREFIX

      The prefix which is used by the method `User.isAuthorised(String, Handler)` when checking for role access
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### create

          static MongoAuth create(MongoClient mongoClient,
                                  JsonObject config)

      Creates an instance of MongoAuth by using the given `MongoClient` 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` - an instance of `MongoClient` to be used for data storage and retrival
        `config` - the configuration object for the current instance. By this
      Returns:
        the created instance of `MongoAuth`s

    - #### setCollectionName

          MongoAuth setCollectionName(String collectionName)

      Set the name of the collection to be used. Defaults to `DEFAULT_COLLECTION_NAME`
      Parameters:
        `collectionName` - the name of the collection to be used for storing and reading user data
      Returns:
        the current instance itself for fluent calls

    - #### setUsernameField

          MongoAuth setUsernameField(String fieldName)

      Set the name of the field to be used for the username. Defaults to `DEFAULT_USERNAME_FIELD`
      Parameters:
        `fieldName` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### setPasswordField

          MongoAuth setPasswordField(String fieldName)

      Set the name of the field to be used for the password Defaults to `DEFAULT_PASSWORD_FIELD`
      Parameters:
        `fieldName` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### setRoleField

          MongoAuth setRoleField(String fieldName)

      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` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### setPermissionField

          MongoAuth setPermissionField(String fieldName)

      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` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### setUsernameCredentialField

          MongoAuth setUsernameCredentialField(String fieldName)

      Set the name of the field to be used as property for the username in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`. Defaults to `DEFAULT_CREDENTIAL_USERNAME_FIELD`
      Parameters:
        `fieldName` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### setPasswordCredentialField

          MongoAuth setPasswordCredentialField(String fieldName)

      Set the name of the field to be used as property for the password of credentials in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`. Defaults to `DEFAULT_CREDENTIAL_PASSWORD_FIELD`
      Parameters:
        `fieldName` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### setSaltField

          MongoAuth setSaltField(String fieldName)

      Set the name of the field to be used for the salt. Only used when `HashStrategy.setSaltStyle(HashSaltStyle)` is set to `HashSaltStyle.COLUMN`
      Parameters:
        `fieldName` - the name of the field to be used
      Returns:
        the current instance itself for fluent calls

    - #### getCollectionName

          String getCollectionName()

      The name of the collection used to store User objects inside. Defaults to `DEFAULT_COLLECTION_NAME`
      Returns:
        the collectionName

    - #### getUsernameField

          String getUsernameField()

      Get the name of the field to be used for the username. Defaults to `DEFAULT_USERNAME_FIELD`
      Returns:
        the usernameField

    - #### getPasswordField

          String getPasswordField()

      Get the name of the field to be used for the password Defaults to `DEFAULT_PASSWORD_FIELD`
      Returns:
        the passwordField

    - #### getRoleField

          String getRoleField()

      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:
        the roleField

    - #### getPermissionField

          String getPermissionField()

      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:
        the permissionField

    - #### getUsernameCredentialField

          String getUsernameCredentialField()

      Get the name of the field to be used as property for the username in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`. Defaults to `DEFAULT_CREDENTIAL_USERNAME_FIELD`
      Returns:
        the usernameCredentialField

    - #### getPasswordCredentialField

          String getPasswordCredentialField()

      Get the name of the field to be used as property for the password of credentials in the method `AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)`. Defaults to `DEFAULT_CREDENTIAL_PASSWORD_FIELD`
      Returns:
        the passwordCredentialField

    - #### getSaltField

          String getSaltField()

      Get the name of the field to be used for the salt. Only used when `HashStrategy.setSaltStyle(HashSaltStyle)` is set to `HashSaltStyle.COLUMN`
      Returns:
        the saltField

    - #### setHashStrategy

          MongoAuth setHashStrategy(HashStrategy hashStrategy)

      The HashStrategy which is used by the current instance
      Parameters:
        `hashStrategy` - the `HashStrategy` to be set
      Returns:
        the current instance itself for fluent calls

    - #### getHashStrategy

          HashStrategy getHashStrategy()

      The HashStrategy which is used by the current instance
      Returns:
        the defined instance of `HashStrategy`

    - #### insertUser

          void insertUser(String username,
                          String password,
                          List<String> roles,
                          List<String> permissions,
                          Handler<AsyncResult<String>> resultHandler)

      Insert a new user into mongo in the convenient way
      Parameters:
        `username` - the username to be set
        `password` - the passsword in clear text, will be adapted following the definitions of the defined `HashStrategy`
        `roles` - a list of roles to be set
        `permissions` - a list of permissions to be set
        `resultHandler` - the ResultHandler will be provided with the id of the generated record

Copyright © 2017. All rights reserved.