Class PasswordGenerator

  • All Implemented Interfaces:
    de.christofreichardt.diagnosis.Traceable

    public class PasswordGenerator
    extends Object
    implements de.christofreichardt.diagnosis.Traceable
    Generates passwords with specified length and basic character set.
    Author:
    Christof Reichardt
    • Constructor Detail

      • PasswordGenerator

        public PasswordGenerator​(int length)
                          throws GeneralSecurityException
        Creates a PasswordGenerator instance with the specified length and alphanumeric symbols as basic character set.
        Parameters:
        length - the length of the generated passwords
        Throws:
        GeneralSecurityException - if no provider supports the required SecureRandom instance
      • PasswordGenerator

        public PasswordGenerator​(int length,
                                 char[] symbols)
                          throws GeneralSecurityException
        Creates a PasswordGenerator instance with the specified length and given basic character set.
        Parameters:
        length - the length of the generated passwords
        symbols - the basic character set from which the passwords will be generated
        Throws:
        GeneralSecurityException - if no provider supports the required SecureRandom instance
    • Method Detail

      • alphanumeric

        public static char[] alphanumeric()
        Defines the character set comprising alphanumeric symbols.
        Returns:
        all alphanumeric characters
      • umlauts

        public static char[] umlauts()
        Defines the character set comprising german umlauts.
        Returns:
        all german umlauts
      • punctuationAndSymbols

        public static char[] punctuationAndSymbols()
        Defines the character set comprising several punctuation marks and symbols.
        Returns:
        some punctuation marks and symbols
      • alphanumericWithUmlauts

        public static char[] alphanumericWithUmlauts()
        The union of alphanumeric and umlaut characters.
        Returns:
        all alphanumeric characters and all german umlauts
      • alphanumericWithPunctuationAndSymbols

        public static char[] alphanumericWithPunctuationAndSymbols()
        The union of alphanumeric and punctuationAndSymbols() punctuationAndSymbol} characters.
        Returns:
        all alphanumeric characters and some punctuation marks and symbols
      • generate

        public Stream<CharSequence> generate()
        Generates a stream of passwords which will be built from the basic character set with the specified length.
        Returns:
        a password stream
      • generate

        public Stream<CharSequence> generate​(char[] requiredChars)
        Generates a stream of passwords which will be built from the basic character set with the specified length. All of the generated passwords will contain at least one of the required characters.
        Parameters:
        requiredChars - each generated password contains at least one of them
        Returns:
        a password stream
      • generate

        public Stream<CharSequence> generate​(Set<char[]> requiredCharSets)
        Generates a stream of passwords which will be built from the basic character set with the specified length. All of the generated passwords will contain at least one of the characters of each required character set.
        Parameters:
        requiredCharSets - each generated password contains at least one character of each required character set
        Returns:
        a password stream
      • getCurrentTracer

        public de.christofreichardt.diagnosis.AbstractTracer getCurrentTracer()
        Switched off.
        Specified by:
        getCurrentTracer in interface de.christofreichardt.diagnosis.Traceable
        Returns:
        the NullTracer