java.lang.Object
org.jdrupes.keycloak.moodleauth.moodle.service.Password

public class Password extends Object
Stores a password in such a way that it can be cleared.

Automatically clears the storage if an object of this type becomes weakly reachable.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Password(char[] password)
    Instantiates a new password representation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the stored password.
    boolean
    compareTo(char[] value)
    Compare to a given char array.
    boolean
    Compare to a given string.
    boolean
    equals(Object other)
     
    int
    Passwords shouldn’t be used in sets or as keys.
    char[]
    Returns the stored password.
    Return “(hidden)”.

    Methods inherited from class java.lang.Object

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

    • Password

      public Password(char[] password)
      Instantiates a new password representation.
      Parameters:
      password - the password
  • Method Details

    • clear

      public void clear()
      Clear the stored password.
    • password

      public char[] password()
      Returns the stored password.

      This is returns a reference to the internally used array.

      Returns:
      the char[]
    • compareTo

      public boolean compareTo(String value)
      Compare to a given string.
      Parameters:
      value - the value to compare to
      Returns:
      true, if successful
    • compareTo

      public boolean compareTo(char[] value)
      Compare to a given char array.
      Parameters:
      value - the value to compare to
      Returns:
      true, if successful
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Passwords shouldn’t be used in sets or as keys.

      To avoid disclosing any information about the password, this method always returns 0.

      Overrides:
      hashCode in class Object
      Returns:
      0
    • toString

      public String toString()
      Return “(hidden)”.

      Should prevent the password from appearing unintentionally in outputs.

      Overrides:
      toString in class Object
      Returns:
      the string