001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * docs/licenses/cddl.txt 011 * or http://www.opensource.org/licenses/cddl1.php. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * docs/licenses/cddl.txt. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Portions Copyright 2021-2023 Ping Identity Corporation 026 */ 027package com.unboundid.directory.sdk.ds.types; 028 029 030import com.unboundid.util.NotNull; 031import com.unboundid.util.Nullable; 032import com.unboundid.util.StaticUtils; 033import com.unboundid.util.ThreadSafety; 034import com.unboundid.util.ThreadSafetyLevel; 035 036 037/** 038 * This class defines the set of result codes for use in 039 * {@link PassThroughAuthenticationResult} objects. 040 */ 041@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 042public enum PassThroughAuthenticationResultCode 043{ 044 /** 045 * Indicates that pass-through authentication attempt succeeded. 046 */ 047 SUCCESS("success"), 048 049 050 051 /** 052 * Indicates that the associated pass-through authentication handler is not 053 * applicable for the bind operation being processed. 054 */ 055 HANDLER_NOT_APPLICABLE("handler-not-applicable"), 056 057 058 059 /** 060 * Indicates that the pass-through authentication attempt failed because the 061 * pass-through authentication handler could not identify exactly one account 062 * in the external service that corresponds to the account in the local 063 * server. 064 */ 065 NO_SUCH_USER("no-such-user"), 066 067 068 069 /** 070 * Indicates that the pass-through authentication attempt failed because the 071 * client provided the wrong password for the target user. 072 */ 073 WRONG_PASSWORD("wrong-password"), 074 075 076 077 /** 078 * Indicates that the pass-through authentication attempt failed because the 079 * password for the mapped account must be changed before the account can be 080 * used. 081 */ 082 MUST_CHANGE_PASSWORD("must-change-password"), 083 084 085 086 /** 087 * Indicates that the pass-through authentication attempt filed because the 088 * mapped account in the external authentication service is not in a usable 089 * state (e.g., the password is expired, the account is locked, etc.). 090 */ 091 ACCOUNT_NOT_USABLE("account-not-usable"), 092 093 094 095 /** 096 * Indicates that the pass-through authentication attempt failed, but the 097 * server did not provide enough information to identify a specific reason 098 * (e.g., whether the user doesn't exist, the wrong password was provided, the 099 * account is in an unusable state, etc.). 100 */ 101 NON_SPECIFIC_AUTHENTICATION_FAILURE("non-specific-authentication-failure"), 102 103 104 105 /** 106 * Indicates that the pass-through authentication attempt failed because the 107 * external service reported an error result. 108 */ 109 EXTERNAL_SERVICE_ERROR("external-service-error"), 110 111 112 113 /** 114 * Indicates that the pass-through authentication attempt failed because the 115 * external service is unavailable. 116 */ 117 EXTERNAL_SERVICE_UNAVAILABLE("external-service-unavailable"), 118 119 120 121 /** 122 * Indicates that the pass-through authentication attempt failed because the 123 * external service did not return a response within an expected timeout 124 * period. 125 */ 126 TIMEOUT("timeout"), 127 128 129 130 /** 131 * Indicates that the pass-through authentication attempt failed for a reason 132 * that is not suited to any other defined result code. 133 */ 134 OTHER_FAILURE("other-failure"); 135 136 137 138 // The human-readable name for this result code. 139 private final String name; 140 141 142 143 /** 144 * Creates a new {@code PassThroughAuthenticationResultCode} with the 145 * specified name. 146 * 147 * @param name The human-readable name for this result code. It must not be 148 * {@code null}. 149 */ 150 PassThroughAuthenticationResultCode(@NotNull final String name) 151 { 152 this.name = name; 153 } 154 155 156 157 /** 158 * Retrieves the human-readable name for this result code. 159 * 160 * @return The human-readable name for this result code. 161 */ 162 @NotNull() 163 public String getName() 164 { 165 return name; 166 } 167 168 169 170 /** 171 * Retrieves the {@code PassThroughAuthenticationResultCode} value that 172 * corresponds to the provided name. 173 * 174 * @param name The name for which to retrieve the corresponding result code. 175 * It must not be {@code null}. 176 * 177 * @return The requested result code value, or {@code null} if there is no 178 * result code with the provided name. 179 */ 180 @Nullable() 181 public static PassThroughAuthenticationResultCode forName( 182 @NotNull final String name) 183 { 184 final String lowerName = StaticUtils.toLowerCase(name).replace('_', '-'); 185 switch (lowerName) 186 { 187 case "success": 188 return SUCCESS; 189 case "handler-not-applicable": 190 return HANDLER_NOT_APPLICABLE; 191 case "no-such-user": 192 return NO_SUCH_USER; 193 case "wrong-password": 194 return WRONG_PASSWORD; 195 case "must-change-password": 196 return MUST_CHANGE_PASSWORD; 197 case "account-not-usable": 198 return ACCOUNT_NOT_USABLE; 199 case "non-specific-authentication-failure": 200 return NON_SPECIFIC_AUTHENTICATION_FAILURE; 201 case "external-service-error": 202 return EXTERNAL_SERVICE_ERROR; 203 case "external-service-unavailable": 204 return EXTERNAL_SERVICE_UNAVAILABLE; 205 case "timeout": 206 return TIMEOUT; 207 case "other-failure": 208 return OTHER_FAILURE; 209 default: 210 return null; 211 } 212 } 213 214 215 216 /** 217 * Retrieves the human-readable name for this {@code IndexType}. 218 * 219 * @return The human-readable name for this {@code IndexType}. 220 */ 221 @Override 222 @NotNull() 223 public String toString() 224 { 225 return name; 226 } 227}