Class SecretString

  • All Implemented Interfaces:
    AutoCloseable, CharSequence

    public class SecretString
    extends Object
    implements CharSequence, AutoCloseable
    This class implements a CharSequence that can be cleared of it's contained characters. This class is utilized to pass around secrets (passwords) instead of a String instance.
    • Constructor Detail

      • SecretString

        public SecretString​(CharSequence charSequence)
      • SecretString

        public SecretString​(char[] chars)
      • SecretString

        public SecretString​(char[] chars,
                            int start,
                            int end)
    • Method Detail

      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface CharSequence
      • clear

        public void clear()
        Clear the contents of this SecretString instance by setting each character to 0. This is automatically done in the finalize() method.