Class Credentials


public class Credentials extends AbstractProvider<BaseProviders>
Generates credentials such as usernames, uids and passwords.
Since:
2.5.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     

    Fields inherited from class net.datafaker.providers.base.AbstractProvider

    faker
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Generates a password, only with lowercase letters, numbers and with length between 8 and 16 characters.
    password(boolean includeDigit)
    Generates a password, only with lowercase letters and optionally numbers with length between 8 and 16 characters.
    password(int minimumLength, int maximumLength)
    Generates a password, only with lowercase letters, numbers and with min and max length defined by the user.
    password(int minimumLength, int maximumLength, boolean includeUppercase)
    Generates a password with lowercase and optionally uppercase letters, numbers and with min and max length defined by the user.
    password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial)
    Generates a password with lowercase letters, numbers and optionally uppercase letters and special characters and with min and max length defined by the user.
    password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial, boolean includeDigit)
    Generates a password with lowercase letters and optionally uppercase letters, numbers and special characters and with min and max length defined by the user.
    Generates a user ID based on the regex pattern defined in the resource file.
    userId(String regex)
    Generates a user ID based on the provided regex pattern.
    A lowercase username composed of the first_name and last_name joined with a '.'.
    Returns a weak password from a pre-defined list of common weak passwords.

    Methods inherited from class net.datafaker.providers.base.AbstractProvider

    equals, getFaker, hashCode, loadGenerators, resolve, resolve, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • username

      public String username()
      A lowercase username composed of the first_name and last_name joined with a '.'. Some examples are:
      Returns:
      a random two part username.
      See Also:
    • password

      public String password()
      Generates a password, only with lowercase letters, numbers and with length between 8 and 16 characters.
      Returns:
      A randomly generated password
    • password

      public String password(boolean includeDigit)
      Generates a password, only with lowercase letters and optionally numbers with length between 8 and 16 characters.
      Parameters:
      includeDigit - if true, the password will contain at least one digit
      Returns:
      A randomly generated password
    • password

      public String password(int minimumLength, int maximumLength)
      Generates a password, only with lowercase letters, numbers and with min and max length defined by the user.
      Parameters:
      minimumLength - the minimum length of the password
      maximumLength - the maximum length of the password
      Returns:
      A randomly generated password
    • password

      public String password(int minimumLength, int maximumLength, boolean includeUppercase)
      Generates a password with lowercase and optionally uppercase letters, numbers and with min and max length defined by the user.
      Parameters:
      minimumLength - the minimum length of the password
      maximumLength - the maximum length of the password
      includeUppercase - if true, the password will contain at least one uppercase letter
      Returns:
      A randomly generated password
    • password

      public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial)
      Generates a password with lowercase letters, numbers and optionally uppercase letters and special characters and with min and max length defined by the user.
      Parameters:
      minimumLength - the minimum length of the password
      maximumLength - the maximum length of the password
      includeUppercase - if true, the password will contain at least one uppercase letter
      includeSpecial - if true, the password will contain at least one special character
      Returns:
      A randomly generated password
    • password

      public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial, boolean includeDigit)
      Generates a password with lowercase letters and optionally uppercase letters, numbers and special characters and with min and max length defined by the user.
      Parameters:
      minimumLength - the minimum length of the password
      maximumLength - the maximum length of the password
      includeUppercase - if true, the password will contain at least one uppercase letter
      includeSpecial - if true, the password will contain at least one special character
      includeDigit - if true, the password will contain at least one digit
      Returns:
      A randomly generated password
    • weakPassword

      public String weakPassword()
      Returns a weak password from a pre-defined list of common weak passwords. Some examples are:
      • 123456
      • password
      • qwerty
      Returns:
      a random weak password.
    • userId

      public String userId()
      Generates a user ID based on the regex pattern defined in the resource file. If the regex is null or invalid, it returns null.
      Returns:
      A randomly generated user ID based on the regex or null if the regex is null or invalid
    • userId

      public String userId(String regex)
      Generates a user ID based on the provided regex pattern. If the regex is null or invalid, it returns null.
      Parameters:
      regex - The regex pattern to generate the user ID
      Returns:
      A randomly generated user ID based on the regex or null if the regex is null or invalid