001/* 002 * Copyright 2015-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2018 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025import com.unboundid.util.StaticUtils; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * This enum defines the set of response types that can be used in the 033 * password validation details response control. 034 * <BR> 035 * <BLOCKQUOTE> 036 * <B>NOTE:</B> This class, and other classes within the 037 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 038 * supported for use against Ping Identity, UnboundID, and 039 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 040 * for proprietary functionality or for external specifications that are not 041 * considered stable or mature enough to be guaranteed to work in an 042 * interoperable way with other types of LDAP servers. 043 * </BLOCKQUOTE> 044 */ 045@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 046public enum PasswordValidationDetailsResponseType 047{ 048 /** 049 * The response type that indicates that the server was able to perform 050 * validation against the proposed password, and that the response includes 051 * a set of validation results. 052 */ 053 VALIDATION_DETAILS((byte) 0xA0), 054 055 056 057 /** 058 * The response type that indicates that the server was unable to provide 059 * validation results because the associated request did not include any 060 * password. 061 */ 062 NO_PASSWORD_PROVIDED((byte) 0x81), 063 064 065 066 /** 067 * The response type that indicates that the server was unable to provide 068 * validation results because the associated request included multiple 069 * passwords. 070 */ 071 MULTIPLE_PASSWORDS_PROVIDED((byte) 0x82), 072 073 074 075 /** 076 * The response type that indicates that the server encountered a problem with 077 * the request that caused processing to end before any password validation 078 * was attempted. 079 */ 080 NO_VALIDATION_ATTEMPTED((byte) 0x83); 081 082 083 084 // The BER type that will be used for this response type in an encoded 085 // password validation details response control. 086 private final byte berType; 087 088 089 090 /** 091 * Creates a new password validation details response type with the provided 092 * BER type. 093 * 094 * @param berType The BER type that will be used for this response type in 095 * an encoded password validation details response control. 096 */ 097 PasswordValidationDetailsResponseType(final byte berType) 098 { 099 this.berType = berType; 100 } 101 102 103 104 /** 105 * Retrieves the BER type that will be used for this response type in an 106 * encoded password validation details response control. 107 * 108 * @return The BER type that will be used for this response type in an 109 * encoded password validation details response control. 110 */ 111 public byte getBERType() 112 { 113 return berType; 114 } 115 116 117 118 /** 119 * Retrieves the password validation details response type with the specified 120 * BER type. 121 * 122 * @param berType The BER type for the password validation details response 123 * type to retrieve. 124 * 125 * @return The password validation details response type with the specified 126 * BER type, or {@code null} if there is no response type with the 127 * specified BER type. 128 */ 129 public static PasswordValidationDetailsResponseType 130 forBERType(final byte berType) 131 { 132 for (final PasswordValidationDetailsResponseType t : values()) 133 { 134 if (t.berType == berType) 135 { 136 return t; 137 } 138 } 139 140 return null; 141 } 142 143 144 145 /** 146 * Retrieves the password validation details response type with the specified 147 * name. 148 * 149 * @param name The name of the password validation details response type to 150 * retrieve. It must not be {@code null}. 151 * 152 * @return The requested password validation details response type, or 153 * {@code null} if no such type is defined. 154 */ 155 public static PasswordValidationDetailsResponseType forName(final String name) 156 { 157 switch (StaticUtils.toLowerCase(name)) 158 { 159 case "validationdetails": 160 case "validation-details": 161 case "validation_details": 162 return VALIDATION_DETAILS; 163 case "nopasswordprovided": 164 case "no-password-provided": 165 case "no_password_provided": 166 return NO_PASSWORD_PROVIDED; 167 case "multiplepasswordsprovided": 168 case "multiple-passwords-provided": 169 case "multiple_passwords_provided": 170 return MULTIPLE_PASSWORDS_PROVIDED; 171 case "novalidationattempted": 172 case "no-validation-attempted": 173 case "no_validation_attempted": 174 return NO_VALIDATION_ATTEMPTED; 175 default: 176 return null; 177 } 178 } 179}