mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
12.53.2006 2265a2d6559f14316af129a139be40e07b430d79
Make several updates to the AccountStatusNotificationType class:

- Use integers rather than strings as the identifiers for the notification
types, which will make them easier to compare as well as easier to
internationalize.
- Change the ACCOUNT_REQUIRES_ADMIN_UNLOCK type to the simpler and more
consistent ACCOUNT_PERMANENTLY_LOCKED type.
- Change the PASSWORD_RESET_BY_ADMINISTRATOR type to the more compact
PASSWORD_RESET type.
- Add ACCOUNT_RESET_LOCKED and ACCOUNT_EXPIRED types.
2 files modified
296 ■■■■ changed files
opends/src/server/org/opends/server/messages/UtilityMessages.java 147 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/AccountStatusNotificationType.java 149 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/messages/UtilityMessages.java
@@ -1394,6 +1394,127 @@
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the account has been
   * temporarily locked.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_TEMPORARILY_LOCKED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 129;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the account has been
   * permanently locked.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_PERMANENTLY_LOCKED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 130;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the account has been
   * unlocked by an administrator.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_UNLOCKED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 131;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that an authentication
   * attempt failed because the account had been idle for too long.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_IDLE_LOCKED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 132;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that an authentication
   * attempt failed because the password had been administratively reset but not
   * changed by the user in the necessary window.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_RESET_LOCKED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 133;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the account has been
   * administratively disabled.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_DISABLED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 134;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the account has been
   * administratively re-enabled.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_ENABLED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 135;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that an authentication
   * attempt failed because the account had expired.
   */
  public static final int MSGID_ACCTNOTTYPE_ACCOUNT_EXPIRED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 136;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that an authentication
   * attempt failed because the user's password had expired.
   */
  public static final int MSGID_ACCTNOTTYPE_PASSWORD_EXPIRED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 137;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the user's password will
   * expire in the near future.
   */
  public static final int MSGID_ACCTNOTTYPE_PASSWORD_EXPIRING =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 138;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the user's password was
   * reset by an administrator.
   */
  public static final int MSGID_ACCTNOTTYPE_PASSWORD_RESET =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 139;
  /**
   * The message ID for the message that will be used as the identifier string
   * for an account status notification indicating that the user's password was
   * changed by the user.
   */
  public static final int MSGID_ACCTNOTTYPE_PASSWORD_CHANGED =
       CATEGORY_MASK_UTIL | SEVERITY_MASK_INFORMATIONAL | 140;
  /**
   * Associates a set of generic messages with the message IDs defined in this
   * class.
   */
@@ -1860,6 +1981,32 @@
                    "%d hours, %d minutes, %s seconds");
    registerMessage(MSGID_TIME_IN_DAYS_HOURS_MINUTES_SECONDS,
                    "%d days, %d hours, %d minutes, %s seconds");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_TEMPORARILY_LOCKED,
                    "account-temporarily-locked");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_PERMANENTLY_LOCKED,
                    "account-permanently-locked");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_UNLOCKED,
                    "account-unlocked");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_IDLE_LOCKED,
                    "account-idle-locked");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_RESET_LOCKED,
                    "account-reset-locked");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_DISABLED,
                    "account-disabled");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_ENABLED,
                    "account-enabled");
    registerMessage(MSGID_ACCTNOTTYPE_ACCOUNT_EXPIRED,
                    "account-expired");
    registerMessage(MSGID_ACCTNOTTYPE_PASSWORD_EXPIRED,
                    "password-expired");
    registerMessage(MSGID_ACCTNOTTYPE_PASSWORD_EXPIRING,
                    "password-expiring");
    registerMessage(MSGID_ACCTNOTTYPE_PASSWORD_RESET,
                    "password-reset-by-administrator");
    registerMessage(MSGID_ACCTNOTTYPE_PASSWORD_CHANGED,
                    "password-changed");
  }
}
opends/src/server/org/opends/server/types/AccountStatusNotificationType.java
@@ -28,6 +28,8 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.messages.UtilityMessages.*;
import static org.opends.server.util.StaticUtils.*;
@@ -43,7 +45,8 @@
   * whenever a user account has been temporarily locked after too
   * many failed attempts.
   */
  ACCOUNT_TEMPORARILY_LOCKED("account-temporarily-locked"),
  ACCOUNT_TEMPORARILY_LOCKED(
       MSGID_ACCTNOTTYPE_ACCOUNT_TEMPORARILY_LOCKED),
@@ -52,7 +55,8 @@
   * whenever a user account has been permanently locked after too
   * many failed attempts.
   */
  ACCOUNT_REQUIRES_ADMIN_UNLOCK("account-requires-admin-unlock"),
  ACCOUNT_PERMANENTLY_LOCKED(
       MSGID_ACCTNOTTYPE_ACCOUNT_PERMANENTLY_LOCKED),
@@ -60,7 +64,7 @@
   * Indicates that an account status message should be generated
   * whenever a user account has been unlocked by an administrator.
   */
  ACCOUNT_UNLOCKED("account-unlocked"),
  ACCOUNT_UNLOCKED(MSGID_ACCTNOTTYPE_ACCOUNT_UNLOCKED),
@@ -69,7 +73,17 @@
   * whenever a user account has been locked because it was idle for
   * too long.
   */
  IDLE_ACCOUNT_LOCKED("idle-account-locked"),
  ACCOUNT_IDLE_LOCKED(MSGID_ACCTNOTTYPE_ACCOUNT_IDLE_LOCKED),
  /**
   * Indicates that an account status message should be generated
   * whenever a user account has been locked because it the password
   * had been reset by an administrator but not changed by the user
   * within the required interval.
   */
  ACCOUNT_RESET_LOCKED(MSGID_ACCTNOTTYPE_ACCOUNT_RESET_LOCKED),
@@ -77,7 +91,7 @@
   * Indicates that an account status message should be generated
   * whenever a user account has been disabled by an administrator.
   */
  ACCOUNT_DISABLED("account-disabled"),
  ACCOUNT_DISABLED(MSGID_ACCTNOTTYPE_ACCOUNT_DISABLED),
@@ -85,7 +99,16 @@
   * Indicates that an account status message should be generated
   * whenever a user account has been enabled by an administrator.
   */
  ACCOUNT_ENABLED("account-enabled"),
  ACCOUNT_ENABLED(MSGID_ACCTNOTTYPE_ACCOUNT_ENABLED),
  /**
   * Indicates that an account status message should be generated
   * whenever a user authentication has failed because the account
   * has expired.
   */
  ACCOUNT_EXPIRED(MSGID_ACCTNOTTYPE_ACCOUNT_EXPIRED),
@@ -94,7 +117,7 @@
   * generated whenever a user authentication has failed because the
   * password has expired.
   */
  PASSWORD_EXPIRED("password-expired"),
  PASSWORD_EXPIRED(MSGID_ACCTNOTTYPE_PASSWORD_EXPIRED),
@@ -104,7 +127,7 @@
   * generated the first time that a password expiration warning is
   * encountered for a user password.
   */
  PASSWORD_EXPIRING("password-expiring"),
  PASSWORD_EXPIRING(MSGID_ACCTNOTTYPE_PASSWORD_EXPIRING),
@@ -113,7 +136,7 @@
   * generated whenever a user's password is reset by an
   * administrator.
   */
  PASSWORD_RESET_BY_ADMINISTRATOR("password-reset-by-administrator"),
  PASSWORD_RESET(MSGID_ACCTNOTTYPE_PASSWORD_RESET),
@@ -121,98 +144,86 @@
   * Indicates whether an account status notification message should
   * be generated whenever a user changes his/her own password.
   */
  PASSWORD_CHANGED("password-changed");
  PASSWORD_CHANGED(MSGID_ACCTNOTTYPE_PASSWORD_CHANGED);
  // The name for this account status notification type.
  private String name;
  // The notification type identifier.
  private int notificationTypeID;
  /**
   * Creates a new account status notification type with the provided
   * name.
   * notification type ID.
   *
   * @param  name  The name for this account status notification type.
   * @param  notificationTypeID  The notification type identifier for
   *                             this account status notification.
   */
  private AccountStatusNotificationType(String name)
  private AccountStatusNotificationType(int notificationTypeID)
  {
    this.name = name;
    this.notificationTypeID = notificationTypeID;
  }
  /**
   * Retrieves the account status notification type with the specified
   * name.
   * notification type identifier.
   *
   * @param  name  The name of the account status notification type to
   *               retrieve.
   * @param  notificationTypeID  The notification type identifier for
   *                             the notification type to retrieve.
   *
   * @return  The requested account status notification type, or
   *          <CODE>null</CODE> if there is no type for the given
   *          name.
   *          notification type identifier.
   */
  public static AccountStatusNotificationType typeForName(String name)
  public static AccountStatusNotificationType
                     typeForID(int notificationTypeID)
  {
    String lowerName = toLowerCase(name);
    if (lowerName.equals("account-temporarily-locked"))
    switch(notificationTypeID)
    {
      return ACCOUNT_TEMPORARILY_LOCKED;
    }
    else if (lowerName.equals("account-requires-admin-unlock"))
    {
      return ACCOUNT_REQUIRES_ADMIN_UNLOCK;
    }
    else if (lowerName.equals("account-unlocked"))
    {
      return ACCOUNT_UNLOCKED;
    }
    else if (lowerName.equals("idle-account-locked"))
    {
      return IDLE_ACCOUNT_LOCKED;
    }
    else if (lowerName.equals("account-disabled"))
    {
      return ACCOUNT_DISABLED;
    }
    else if (lowerName.equals("account-enabled"))
    {
      return ACCOUNT_ENABLED;
    }
    else if (lowerName.equals("password-expired"))
    {
      return PASSWORD_EXPIRED;
    }
    else if (lowerName.equals("password-expiring"))
    {
      return PASSWORD_EXPIRING;
    }
    else if (lowerName.equals("password-reset-by-administrator"))
    {
      return PASSWORD_RESET_BY_ADMINISTRATOR;
    }
    else if (lowerName.equals("password-changed"))
    {
      return PASSWORD_CHANGED;
    }
    else
    {
      return null;
      case MSGID_ACCTNOTTYPE_ACCOUNT_TEMPORARILY_LOCKED:
        return ACCOUNT_TEMPORARILY_LOCKED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_PERMANENTLY_LOCKED:
        return ACCOUNT_PERMANENTLY_LOCKED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_UNLOCKED:
        return ACCOUNT_UNLOCKED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_IDLE_LOCKED:
        return ACCOUNT_IDLE_LOCKED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_RESET_LOCKED:
        return ACCOUNT_RESET_LOCKED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_DISABLED:
        return ACCOUNT_DISABLED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_ENABLED:
        return ACCOUNT_ENABLED;
      case MSGID_ACCTNOTTYPE_ACCOUNT_EXPIRED:
        return ACCOUNT_EXPIRED;
      case MSGID_ACCTNOTTYPE_PASSWORD_EXPIRED:
        return PASSWORD_EXPIRED;
      case MSGID_ACCTNOTTYPE_PASSWORD_EXPIRING:
        return PASSWORD_EXPIRING;
      case MSGID_ACCTNOTTYPE_PASSWORD_RESET:
        return PASSWORD_RESET;
      case MSGID_ACCTNOTTYPE_PASSWORD_CHANGED:
        return PASSWORD_CHANGED;
      default:
        return null;
    }
  }
  /**
   * Retrieves the name for this account-status notification type.
   * Retrieves the notification type identifier for this account
   * status notification type.
   *
   * @return  The name for this account status notification type.
   * @return  The notification type identifier for this account
   *          status notification type.
   */
  public String getName()
  public int getNotificationTypeID()
  {
    return name;
    return notificationTypeID;
  }
@@ -226,7 +237,7 @@
   */
  public String toString()
  {
    return name;
    return getMessage(notificationTypeID);
  }
}