java.lang.Object
com.aoindustries.aoserv.daemon.posix.ShadowFile.Entry
Enclosing class:
ShadowFile

public static final class ShadowFile.Entry extends Object
Represents one line of the /etc/shadow file on a POSIX server.
  • Constructor Details

    • Entry

      public Entry(User.Name username, String password, int changedDate, Integer minPasswordAge, Integer maxPasswordAge, Integer warningDays, Integer inactivateDays, Integer expirationDate, String flag)
      Constructs a shadow file entry given all the values.
    • Entry

      public Entry(User.Name username, String password, Integer newChangedDate)
      Creates a new shadow file entry for the given user and encrypted password.
    • Entry

      public Entry(User.Name username)
      Creates a new shadow file entry for the given user.
  • Method Details

    • getCurrentDate

      public static int getCurrentDate()
      Gets the number of days from the Epoch for the current day.
    • getCurrentDate

      public static int getCurrentDate(long time)
      Gets the number of days from the Epoch for the provided time in milliseconds from Epoch.
    • toString

      public String toString()
      Gets this ShadowFile.Entry as it would be written in /etc/shadow, not including any newline.
      Overrides:
      toString in class Object
      See Also:
    • appendTo

      public <A extends Appendable> A appendTo(A out) throws IOException
      Appends this ShadowFile.Entry as it would be written in /etc/shadow, not including any newline.
      Throws:
      IOException
      See Also:
    • getUsername

      public User.Name getUsername()
      The username the entry is for.
    • getPassword

      public String getPassword()
      The encrypted password.
    • setPassword

      public ShadowFile.Entry setPassword(String newPassword, Integer newChangedDate)
      Sets the encrypted password, optionally updating the changedDate.
      Parameters:
      newChangedDate - The new changeDate or null to not alter
      Returns:
      a new entry if the password changed or this when the password is the same
    • getChangedDate

      public int getChangedDate()
      The days since Jan 1, 1970 password was last changed.
    • getMinPasswordAge

      public Integer getMinPasswordAge()
      The number of days until a password change is allowed or null if not set.
    • getMaxPasswordAge

      public Integer getMaxPasswordAge()
      The number of days until a password change is forced or null if not set.
    • getWarningDays

      public Integer getWarningDays()
      The days before password is to expire that user is warned of pending password expiration or null if not set.
    • getInactivateDays

      public Integer getInactivateDays()
      The days after password expires that account is considered inactive and disabled or null if not set.
    • getExpirationDate

      public Integer getExpirationDate()
      The days since Jan 1, 1970 when account will be disabled or null if not set.
    • getFlag

      public String getFlag()
      Reserved for future use, null if not set.