ResultCode.java revision 6870993d12bf8a2b9d5cd103dc5ccabc42f9bf5d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2009 Sun Microsystems, Inc.
* Portions copyright 2013 ForgeRock AS.
*/
/**
* An operation result code as defined in RFC 4511 section 4.1.9 is used to
* indicate the final status of an operation. If a server detects multiple
* errors for an operation, only one result code is returned. The server should
* return the result code that best indicates the nature of the error
* encountered. Servers may return substituted result codes to prevent
* unauthorized disclosures.
*
* @see <a href="http://tools.ietf.org/html/rfc4511#section-4.1.9">RFC 4511 -
* Lightweight Directory Access Protocol (LDAP): The Protocol </a>
*/
public final class ResultCode {
/**
* Contains equivalent values for the ResultCode values.
* This allows easily using ResultCode values with switch statements.
*/
public static enum Enum {
//@Checkstyle:off
/** @see ResultCode#UNDEFINED */
/** @see ResultCode#SUCCESS */
/** @see ResultCode#OPERATIONS_ERROR */
/** @see ResultCode#PROTOCOL_ERROR */
/** @see ResultCode#TIME_LIMIT_EXCEEDED */
/** @see ResultCode#SIZE_LIMIT_EXCEEDED */
/** @see ResultCode#COMPARE_FALSE */
/** @see ResultCode#COMPARE_TRUE */
/** @see ResultCode#AUTH_METHOD_NOT_SUPPORTED */
/** @see ResultCode#STRONG_AUTH_REQUIRED */
/** @see ResultCode#REFERRAL */
/** @see ResultCode#ADMIN_LIMIT_EXCEEDED */
/** @see ResultCode#UNAVAILABLE_CRITICAL_EXTENSION */
/** @see ResultCode#CONFIDENTIALITY_REQUIRED */
/** @see ResultCode#SASL_BIND_IN_PROGRESS */
/** @see ResultCode#NO_SUCH_ATTRIBUTE */
/** @see ResultCode#UNDEFINED_ATTRIBUTE_TYPE */
/** @see ResultCode#INAPPROPRIATE_MATCHING */
/** @see ResultCode#CONSTRAINT_VIOLATION */
/** @see ResultCode#ATTRIBUTE_OR_VALUE_EXISTS */
/** @see ResultCode#INVALID_ATTRIBUTE_SYNTAX */
/** @see ResultCode#NO_SUCH_OBJECT */
/** @see ResultCode#ALIAS_PROBLEM */
/** @see ResultCode#INVALID_DN_SYNTAX */
/** @see ResultCode#ALIAS_DEREFERENCING_PROBLEM */
/** @see ResultCode#INAPPROPRIATE_AUTHENTICATION */
/** @see ResultCode#INVALID_CREDENTIALS */
/** @see ResultCode#INSUFFICIENT_ACCESS_RIGHTS */
/** @see ResultCode#BUSY */
BUSY,
/** @see ResultCode#UNAVAILABLE */
/** @see ResultCode#UNWILLING_TO_PERFORM */
/** @see ResultCode#LOOP_DETECT */
/** @see ResultCode#SORT_CONTROL_MISSING */
/** @see ResultCode#OFFSET_RANGE_ERROR */
/** @see ResultCode#NAMING_VIOLATION */
/** @see ResultCode#OBJECTCLASS_VIOLATION */
/** @see ResultCode#NOT_ALLOWED_ON_NONLEAF */
/** @see ResultCode#NOT_ALLOWED_ON_RDN */
/** @see ResultCode#ENTRY_ALREADY_EXISTS */
/** @see ResultCode#OBJECTCLASS_MODS_PROHIBITED */
/** @see ResultCode#AFFECTS_MULTIPLE_DSAS */
/** @see ResultCode#VIRTUAL_LIST_VIEW_ERROR */
/** @see ResultCode#OTHER */
/** @see ResultCode#CLIENT_SIDE_SERVER_DOWN */
/** @see ResultCode#CLIENT_SIDE_LOCAL_ERROR */
/** @see ResultCode#CLIENT_SIDE_ENCODING_ERROR */
/** @see ResultCode#CLIENT_SIDE_DECODING_ERROR */
/** @see ResultCode#CLIENT_SIDE_TIMEOUT */
/** @see ResultCode#CLIENT_SIDE_AUTH_UNKNOWN */
/** @see ResultCode#CLIENT_SIDE_FILTER_ERROR */
/** @see ResultCode#CLIENT_SIDE_USER_CANCELLED */
/** @see ResultCode#CLIENT_SIDE_PARAM_ERROR */
/** @see ResultCode#CLIENT_SIDE_NO_MEMORY */
/** @see ResultCode#CLIENT_SIDE_CONNECT_ERROR */
/** @see ResultCode#CLIENT_SIDE_NOT_SUPPORTED */
/** @see ResultCode#CLIENT_SIDE_CONTROL_NOT_FOUND */
/** @see ResultCode#CLIENT_SIDE_NO_RESULTS_RETURNED */
/** @see ResultCode#CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED */
/** @see ResultCode#CLIENT_SIDE_CLIENT_LOOP */
/** @see ResultCode#CLIENT_SIDE_REFERRAL_LIMIT_EXCEEDED */
/** @see ResultCode#CANCELLED */
/** @see ResultCode#NO_SUCH_OPERATION */
/** @see ResultCode#TOO_LATE */
/** @see ResultCode#CANNOT_CANCEL */
/** @see ResultCode#ASSERTION_FAILED */
/** @see ResultCode#AUTHORIZATION_DENIED */
/** @see ResultCode#NO_OPERATION */
/** Used for unknown search scopes. */
//@Checkstyle:on
}
private static final List<ResultCode> IMMUTABLE_ELEMENTS = Collections.unmodifiableList(new ArrayList<ResultCode>(
/**
* The result code that should only be used if the actual result code has
* not yet been determined.
* <p>
* Despite not being a standard result code, it is an implementation of the
* null object design pattern for this type.
*/
/**
* The result code that indicates that the operation completed successfully.
* <p>
* This result code corresponds to the LDAP result code value of {@code 0}.
*/
public static final ResultCode SUCCESS =
/**
* The result code that indicates that an internal error prevented the
* operation from being processed properly.
* <p>
* This result code corresponds to the LDAP result code value of {@code 1}.
*/
/**
* The result code that indicates that the client sent a malformed or
* illegal request to the server.
* <p>
* This result code corresponds to the LDAP result code value of {@code 2}.
*/
/**
* The result code that indicates that a time limit was exceeded while
* attempting to process the request.
* <p>
* This result code corresponds to the LDAP result code value of {@code 3}.
*/
/**
* The result code that indicates that a size limit was exceeded while
* attempting to process the request.
* <p>
* This result code corresponds to the LDAP result code value of {@code 4}.
*/
/**
* The result code that indicates that the attribute value assertion
* included in a compare request did not match the targeted entry.
* <p>
* This result code corresponds to the LDAP result code value of {@code 5}.
*/
/**
* The result code that indicates that the attribute value assertion
* included in a compare request did match the targeted entry.
* <p>
* This result code corresponds to the LDAP result code value of {@code 6}.
*/
/**
* The result code that indicates that the requested authentication attempt
* failed because it referenced an invalid SASL mechanism.
* <p>
* This result code corresponds to the LDAP result code value of {@code 7}.
*/
/**
* The result code that indicates that the requested operation could not be
* processed because it requires that the client has completed a strong form
* of authentication.
* <p>
* This result code corresponds to the LDAP result code value of {@code 8}.
*/
/**
* The result code that indicates that a referral was encountered.
* <p>
* Strictly speaking this result code should not be exceptional since it is
* considered as a "success" response. However, referrals should occur
* rarely in practice and, when they do occur, should not be ignored since
* the application may believe that a request has succeeded when, in fact,
* nothing was done.
* <p>
* This result code corresponds to the LDAP result code value of {@code 10}.
*/
/**
* The result code that indicates that processing on the requested operation
* could not continue because an administrative limit was exceeded.
* <p>
* This result code corresponds to the LDAP result code value of {@code 11}.
*/
/**
* The result code that indicates that the requested operation failed
* because it included a critical extension that is unsupported or
* inappropriate for that request.
* <p>
* This result code corresponds to the LDAP result code value of {@code 12}.
*/
/**
* The result code that indicates that the requested operation could not be
* processed because it requires confidentiality for the communication
* between the client and the server.
* <p>
* This result code corresponds to the LDAP result code value of {@code 13}.
*/
/**
* The result code that should be used for intermediate responses in
* multi-stage SASL bind operations.
* <p>
* This result code corresponds to the LDAP result code value of {@code 14}.
*/
/**
* The result code that indicates that the requested operation failed
* because it targeted an attribute or attribute value that did not exist in
* the specified entry.
* <p>
* This result code corresponds to the LDAP result code value of {@code 16}.
*/
/**
* The result code that indicates that the requested operation failed
* because it referenced an attribute that is not defined in the server
* schema.
* <p>
* This result code corresponds to the LDAP result code value of {@code 17}.
*/
/**
* The result code that indicates that the requested operation failed
* because it attempted to perform an inappropriate type of matching against
* an attribute.
* <p>
* This result code corresponds to the LDAP result code value of {@code 18}.
*/
/**
* The result code that indicates that the requested operation failed
* because it would have violated some constraint defined in the server.
* <p>
* This result code corresponds to the LDAP result code value of {@code 19}.
*/
/**
* The result code that indicates that the requested operation failed
* because it would have resulted in a conflict with an existing attribute
* or attribute value in the target entry.
* <p>
* This result code corresponds to the LDAP result code value of {@code 20}.
*/
/**
* The result code that indicates that the requested operation failed
* because it violated the syntax for a specified attribute.
* <p>
* This result code corresponds to the LDAP result code value of {@code 21}.
*/
/**
* The result code that indicates that the requested operation failed
* because it referenced an entry that does not exist.
* <p>
* This result code corresponds to the LDAP result code value of {@code 32}.
*/
/**
* The result code that indicates that the requested operation failed
* because it attempted to perform an illegal operation on an alias.
* <p>
* This result code corresponds to the LDAP result code value of {@code 33}.
*/
/**
* The result code that indicates that the requested operation failed
* because it would have resulted in an entry with an invalid or malformed
* DN.
* <p>
* This result code corresponds to the LDAP result code value of {@code 34}.
*/
/**
* The result code that indicates that a problem was encountered while
* attempting to dereference an alias for a search operation.
* <p>
* This result code corresponds to the LDAP result code value of {@code 36}.
*/
/**
* The result code that indicates that an authentication attempt failed
* because the requested type of authentication was not appropriate for the
* targeted entry.
* <p>
* This result code corresponds to the LDAP result code value of {@code 48}.
*/
/**
* The result code that indicates that an authentication attempt failed
* because the user did not provide a valid set of credentials.
* <p>
* This result code corresponds to the LDAP result code value of {@code 49}.
*/
/**
* The result code that indicates that the client does not have sufficient
* permission to perform the requested operation.
* <p>
* This result code corresponds to the LDAP result code value of {@code 50}.
*/
/**
* The result code that indicates that the server is too busy to process the
* requested operation.
* <p>
* This result code corresponds to the LDAP result code value of {@code 51}.
*/
public static final ResultCode BUSY = registerErrorResultCode(51, INFO_RESULT_BUSY.get(), Enum.BUSY);
/**
* The result code that indicates that either the entire server or one or
* more required resources were not available for use in processing the
* request.
* <p>
* This result code corresponds to the LDAP result code value of {@code 52}.
*/
/**
* The result code that indicates that the server is unwilling to perform
* the requested operation.
* <p>
* This result code corresponds to the LDAP result code value of {@code 53}.
*/
/**
* The result code that indicates that a referral or chaining loop was
* detected while processing the request.
* <p>
* This result code corresponds to the LDAP result code value of {@code 54}.
*/
/**
* The result code that indicates that a search request included a VLV
* request control without a server-side sort control.
* <p>
* This result code corresponds to the LDAP result code value of {@code 60}.
*/
/**
* The result code that indicates that a search request included a VLV
* request control with an invalid offset.
* <p>
* This result code corresponds to the LDAP result code value of {@code 61}.
*/
/**
* The result code that indicates that the requested operation failed
* because it would have violated the server's naming configuration.
* <p>
* This result code corresponds to the LDAP result code value of {@code 64}.
*/
/**
* The result code that indicates that the requested operation failed
* because it would have resulted in an entry that violated the server
* schema.
* <p>
* This result code corresponds to the LDAP result code value of {@code 65}.
*/
/**
* The result code that indicates that the requested operation is not
* allowed for non-leaf entries.
* <p>
* This result code corresponds to the LDAP result code value of {@code 66}.
*/
/**
* The result code that indicates that the requested operation is not
* allowed on an RDN attribute.
* <p>
* This result code corresponds to the LDAP result code value of {@code 67}.
*/
/**
* The result code that indicates that the requested operation failed
* because it would have resulted in an entry that conflicts with an entry
* that already exists.
* <p>
* This result code corresponds to the LDAP result code value of {@code 68}.
*/
/**
* The result code that indicates that the operation could not be processed
* because it would have modified the objectclasses associated with an entry
* in an illegal manner.
* <p>
* This result code corresponds to the LDAP result code value of {@code 69}.
*/
/**
* The result code that indicates that the operation could not be processed
* because it would impact multiple DSAs or other repositories.
* <p>
* This result code corresponds to the LDAP result code value of {@code 71}.
*/
/**
* The result code that indicates that the operation could not be processed
* because there was an error while processing the virtual list view
* control.
* <p>
* This result code corresponds to the LDAP result code value of {@code 76}.
*/
/**
* The result code that should be used if no other result code is
* appropriate.
* <p>
* This result code corresponds to the LDAP result code value of {@code 80}.
*/
public static final ResultCode OTHER = registerErrorResultCode(80, INFO_RESULT_OTHER.get(), Enum.OTHER);
/**
* The client-side result code that indicates that a previously-established
* connection to the server was lost. This is for client-side use only and
* should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 81}.
*/
/**
* The client-side result code that indicates that a local error occurred
* that had nothing to do with interaction with the server. This is for
* client-side use only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 82}.
*/
/**
* The client-side result code that indicates that an error occurred while
* encoding a request to send to the server. This is for client-side use
* only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 83}.
*/
/**
* The client-side result code that indicates that an error occurred while
* decoding a response from the server. This is for client-side use only and
* should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 84}.
*/
/**
* The client-side result code that indicates that the client did not
* receive an expected response in a timely manner. This is for client-side
* use only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 85}.
*/
/**
* The client-side result code that indicates that the user requested an
* unknown or unsupported authentication mechanism. This is for client-side
* use only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 86}.
*/
/**
* The client-side result code that indicates that the filter provided by
* the user was malformed and could not be parsed. This is for client-side
* use only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 87}.
*/
/**
* The client-side result code that indicates that the user cancelled an
* operation. This is for client-side use only and should never be
* transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 88}.
*/
/**
* The client-side result code that indicates that there was a problem with
* one or more of the parameters provided by the user. This is for
* client-side use only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 89}.
*/
/**
* The client-side result code that indicates that the client application
* was not able to allocate enough memory for the requested operation. This
* is for client-side use only and should never be transferred over
* protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 90}.
*/
/**
* The client-side result code that indicates that the client was not able
* to establish a connection to the server. This is for client-side use only
* and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 91}.
*/
/**
* The client-side result code that indicates that the user requested an
* operation that is not supported. This is for client-side use only and
* should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 92}.
*/
/**
* The client-side result code that indicates that the client expected a
* control to be present in the response from the server but it was not
* included. This is for client-side use only and should never be
* transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 93}.
*/
/**
* The client-side result code that indicates that the requested single
* entry search operation or read operation failed because the Directory
* Server did not return any matching entries. This is for client-side use
* only and should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 94}.
*/
/**
* The client-side result code that the requested single entry search
* operation or read operation failed because the Directory Server returned
* multiple matching entries (or search references) when only a single
* matching entry was expected. This is for client-side use only and should
* never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 95}.
*/
public static final ResultCode CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED = registerErrorResultCode(95,
INFO_RESULT_CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED.get(), Enum.CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED);
/**
* The client-side result code that indicates that the client detected a
* referral loop caused by servers referencing each other in a circular
* manner. This is for client-side use only and should never be transferred
* over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 96}.
*/
/**
* The client-side result code that indicates that the client reached the
* maximum number of hops allowed when attempting to follow a referral
* (i.e., following one referral resulted in another referral which resulted
* in another referral and so on). This is for client-side use only and
* should never be transferred over protocol.
* <p>
* This result code corresponds to the LDAP result code value of {@code 97}.
*/
97, INFO_RESULT_CLIENT_SIDE_REFERRAL_LIMIT_EXCEEDED.get(), Enum.CLIENT_SIDE_REFERRAL_LIMIT_EXCEEDED);
/**
* The result code that indicates that a cancel request was successful, or
* that the specified operation was canceled.
* <p>
* This result code corresponds to the LDAP result code value of {@code 118}.
*/
/**
* The result code that indicates that a cancel request was unsuccessful
* because the targeted operation did not exist or had already completed.
* <p>
* This result code corresponds to the LDAP result code value of {@code 119}.
*/
/**
* The result code that indicates that a cancel request was unsuccessful
* because processing on the targeted operation had already reached a point
* at which it could not be canceled.
* <p>
* This result code corresponds to the LDAP result code value of {@code 120}.
*/
/**
* The result code that indicates that a cancel request was unsuccessful
* because the targeted operation was one that could not be canceled.
* <p>
* This result code corresponds to the LDAP result code value of {@code 121}.
*/
/**
* The result code that indicates that the filter contained in an assertion
* control failed to match the target entry.
* <p>
* This result code corresponds to the LDAP result code value of {@code 122}.
*/
/**
* The result code that should be used if the server will not allow the
* client to use the requested authorization.
* <p>
* This result code corresponds to the LDAP result code value of {@code 123}.
*/
/**
* The result code that should be used if the server did not actually
* complete processing on the associated operation because the request
* included the LDAP No-Op control.
* <p>
* This result code corresponds to the LDAP result code value of
* {@code 16654}.
*/
/**
* Returns the result code having the specified integer value as defined in
* RFC 4511 section 4.1.9. If there is no result code associated with the
* specified integer value then a temporary result code is automatically
* created in order to handle cases where unexpected result codes are
* returned from the server.
*
* @param intValue
* The integer value of the result code.
* @return The result code.
*/
result = new ResultCode(
}
return result;
}
/**
* Returns an unmodifiable list containing the set of available result codes
* indexed on their integer value as defined in RFC 4511 section 4.1.9.
*
* @return An unmodifiable list containing the set of available result
* codes.
*/
return IMMUTABLE_ELEMENTS;
}
/**
* Creates and registers a new error result code with the application.
*
* @param intValue
* The integer value of the error result code as defined in RFC
* 4511 section 4.1.9.
* @param name
* The name of the error result code.
* @param resultCodeEnum
* The enum equivalent for this result code
* @return The new error result code.
*/
return t;
}
/**
* Creates and registers a new success result code with the application.
*
* @param intValue
* The integer value of the success result code as defined in RFC
* 4511 section 4.1.9.
* @param name
* The name of the success result code.
* @param resultCodeEnum
* The enum equivalent for this result code
* @return The new success result code.
*/
return t;
}
private final int intValue;
private final LocalizableMessage name;
private final boolean exceptional;
private final Enum resultCodeEnum;
/** Prevent direct instantiation. */
final Enum resultCodeEnum) {
this.exceptional = exceptional;
this.resultCodeEnum = resultCodeEnum;
}
/** {@inheritDoc} */
if (this == obj) {
return true;
} else if (obj instanceof ResultCode) {
} else {
return false;
}
}
/**
* Returns the short human-readable name of this result code.
*
* @return The short human-readable name of this result code.
*/
public LocalizableMessage getName() {
return name;
}
/** {@inheritDoc} */
public int hashCode() {
return intValue;
}
/**
* Returns the integer value of this result code.
*
* @return The integer value of this result code.
*/
public int intValue() {
return intValue;
}
/**
* Returns the enum equivalent for this result code.
*
* @return The enum equivalent for this result code when a known mapping exists,
* or {@link Enum#UNKNOWN} if this is an unknown result code.
*/
return this.resultCodeEnum;
}
/**
* Indicates whether or not this result code represents an error result.
* <p>
* The following result codes are NOT interpreted as error results:
* <ul>
* <li>{@link #SUCCESS}
* <li>{@link #COMPARE_FALSE}
* <li>{@link #COMPARE_TRUE}
* <li>{@link #SASL_BIND_IN_PROGRESS}
* <li>{@link #NO_OPERATION}
* </ul>
* In order to make it easier for application to detect referrals, the
* {@link #REFERRAL} result code is interpreted as an error result (the LDAP
* RFCs treat referrals as a success response).
*
* @return {@code true} if this result code represents an error result,
* otherwise {@code false}.
*/
public boolean isExceptional() {
return exceptional;
}
/**
* Returns the string representation of this result code.
*
* @return The string representation of this result code.
*/
}
}