001/* 002 * Copyright 2007-2023 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2007-2023 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2007-2023 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.experimental; 037 038 039 040import com.unboundid.util.NotNull; 041import com.unboundid.util.Nullable; 042import com.unboundid.util.StaticUtils; 043import com.unboundid.util.ThreadSafety; 044import com.unboundid.util.ThreadSafetyLevel; 045 046 047 048/** 049 * This enum defines a set of warning types that may be included in the password 050 * policy response control as defined in draft-behera-ldap-password-policy-10. 051 */ 052@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 053public enum DraftBeheraLDAPPasswordPolicy10WarningType 054{ 055 /** 056 * The warning type used to indicate that the user's password will expire in 057 * the near future and provide the length of time until it does expire. 058 */ 059 TIME_BEFORE_EXPIRATION("time before expiration"), 060 061 062 063 /** 064 * The warning type used to indicate that the user's password is expired but 065 * that the user may have grace logins remaining, or that a grace login was 066 * used in the associated bind. 067 */ 068 GRACE_LOGINS_REMAINING("grace logins remaining"); 069 070 071 072 // The human-readable name for this password policy warning type. 073 @NotNull private final String name; 074 075 076 077 /** 078 * Creates a new password policy warning type with the provided name. 079 * 080 * @param name The human-readable name for this warning type. 081 */ 082 DraftBeheraLDAPPasswordPolicy10WarningType(@NotNull final String name) 083 { 084 this.name = name; 085 } 086 087 088 089 /** 090 * Retrieves the human-readable name for this password policy warning type. 091 * 092 * @return The human-readable name for this password policy warning type. 093 */ 094 @NotNull() 095 public String getName() 096 { 097 return name; 098 } 099 100 101 102 /** 103 * Retrieves the password policy warning type with the specified name. 104 * 105 * @param name The name of the password policy warning type to retrieve. It 106 * must not be {@code null}. 107 * 108 * @return The requested password policy warning type, or {@code null} if no 109 * such type is defined. 110 */ 111 @Nullable() 112 public static DraftBeheraLDAPPasswordPolicy10WarningType forName( 113 @NotNull final String name) 114 { 115 switch (StaticUtils.toLowerCase(name)) 116 { 117 case "timebeforeexpiration": 118 case "time-before-expiration": 119 case "time_before_expiration": 120 case "time before expiration": 121 return TIME_BEFORE_EXPIRATION; 122 case "graceloginsremaining": 123 case "grace-logins-remaining": 124 case "grace_logins_remaining": 125 case "grace logins remaining": 126 return GRACE_LOGINS_REMAINING; 127 default: 128 return null; 129 } 130 } 131 132 133 134 /** 135 * Retrieves a string representation for this password policy warning type. 136 * 137 * @return A string representation for this password policy warning type. 138 */ 139 @Override() 140 @NotNull() 141 public String toString() 142 { 143 return name; 144 } 145}