Class Responses

java.lang.Object
org.forgerock.opendj.ldap.messages.Responses

public final class Responses extends Object
This class contains various methods for creating and manipulating responses.

All copy constructors of the form copyOfXXXResult perform deep copies of their response parameter. More specifically, any controls, modifications, and attributes contained within the response will be duplicated.

Similarly, all unmodifiable views of responses returned by methods of the form unmodifiableXXXResult return deep unmodifiable views of their response parameter. More specifically, any controls, modifications, and attributes contained within the returned response will be unmodifiable.

  • Method Details

    • copyOfResult

      public static Result copyOfResult(Result result)
      Creates a new result that is an exact copy of the provided result.
      Parameters:
      result - The result to be copied.
      Returns:
      The new result.
    • copyOfSearchResultEntry

      public static SearchResultEntry copyOfSearchResultEntry(SearchResultEntry searchResultEntry)
      Creates a new search result entry that is an exact copy of the provided result.
      Parameters:
      searchResultEntry - The search result entry to be copied.
      Returns:
      The new search result entry.
    • newBindResult

      public static BindResult newBindResult(ResultCode resultCode)
      Creates a new bind result using the provided result code.
      Parameters:
      resultCode - The result code.
      Returns:
      The new bind result.
    • newBindResult

      public static BindResult newBindResult(Result result)
      Creates a new bind result using the provided result.
      Parameters:
      result - The result.
      Returns:
      The new bind result.
    • newBindResult

      public static BindResult newBindResult(ResultCode resultCode, ByteString credentials, SaslServer saslServer)
      Creates a new bind result using the provided result code.
      Parameters:
      resultCode - The result code.
      credentials - The server SASL credentials associated with this bind result, which may be null indicating that none was provided.
      saslServer - The SaslServer to use by the underlying connection, or null if SASL integrity and/or privacy protection must not be enabled.
      Returns:
      The new bind result.
    • newBindResult

      public static BindResult newBindResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, Throwable cause)
      Creates a new bind result using the provided result code.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      cause - The throwable cause, which may be null indicating that none was provided.
      Returns:
      The new bind result.
    • newBindResult

      public static BindResult newBindResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, ByteString credentials, Throwable cause, SaslServer saslServer)
      Creates a new bind result using the provided result code.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      credentials - The server SASL credentials associated with this bind result, which may be null indicating that none was provided.
      cause - The throwable cause, which may be null indicating that none was provided.
      saslServer - The SaslServer to use by the underlying connection, or null if SASL integrity and/or privacy protection must not be enabled.
      Returns:
      The new bind result.
    • newBindResult

      public static BindResult newBindResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, List<String> referralUris, ByteString credentials, List<Control> controls, Throwable cause, SaslServer saslServer)
      Creates a new bind result using the provided result code.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      referralUris - The optional referrals are present in a BindResult if the result code is set to ResultCode.REFERRAL, and they are absent with all other result codes.
      credentials - The server SASL credentials associated with this bind result, which may be null indicating that none was provided.
      controls - the List containing the controls.
      cause - The throwable cause, which may be null indicating that none was provided.
      saslServer - The SaslServer to use by the underlying connection, or null if SASL integrity and/or privacy protection must not be enabled.
      Returns:
      The new bind result.
    • newCompareResult

      public static CompareResult newCompareResult(ResultCode resultCode)
      Creates a new compare result using the provided result code.
      Parameters:
      resultCode - The result code.
      Returns:
      The new compare result.
    • newCompareResult

      public static CompareResult newCompareResult(Result result)
      Creates a new compare result using the provided result.
      Parameters:
      result - The result.
      Returns:
      The new compare result.
    • newCompareResult

      public static CompareResult newCompareResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, List<String> referralUris, Throwable cause)
      Creates a new compare result using the provided result code.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      referralUris - The optional referrals are present in a CompareResult if the result code is set to ResultCode.REFERRAL, and they are absent with all other result codes.
      cause - The throwable cause, which may be null indicating that none was provided.
      Returns:
      The new compare result.
    • newGenericExtendedResult

      public static GenericExtendedResult newGenericExtendedResult(ResultCode resultCode)
      Creates a new generic extended result using the provided result code.
      Parameters:
      resultCode - The result code.
      Returns:
      The new generic extended result.
    • newGenericExtendedResult

      public static GenericExtendedResult newGenericExtendedResult(ExtendedResult result)
      Creates a new generic extended result using the provided extended result data.
      Parameters:
      result - The extended result to be used for copy.
      Returns:
      The new generic extended result.
    • newGenericExtendedResult

      public static GenericExtendedResult newGenericExtendedResult(ResultCode resultCode, String responseName, ByteString responseValue)
      Creates a new generic extended result using the provided result code.
      Parameters:
      resultCode - The result code.
      responseName - The numeric OID associated with this extended result, or null if there is no value.
      responseValue - The value associated with this extended result, or null if there is no value.
      Returns:
      The new generic extended result.
    • newGenericExtendedResult

      public static GenericExtendedResult newGenericExtendedResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, String responseName, ByteString responseValue)
      Creates a new generic extended result using the provided result code.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      responseName - The numeric OID associated with this extended result, or null if there is no value.
      responseValue - The value associated with this extended result, or null if there is no value.
      Returns:
      The new generic extended result.
    • newGenericExtendedResult

      public static GenericExtendedResult newGenericExtendedResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, List<String> referralUris, String responseName, ByteString responseValue, List<Control> controls)
      Creates a new generic extended result using the provided result code.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      referralUris - The optional referrals are present in a GenericExtendedResult if the result code is set to ResultCode.REFERRAL, and they are absent with all other result codes.
      responseName - The numeric OID associated with this extended result, or null if there is no value.
      responseValue - The value associated with this extended result, or null if there is no value.
      controls - the List containing the controls.
      Returns:
      The new generic extended result.
    • newIntermediateResponse

      public static IntermediateResponse newIntermediateResponse(String oid, Object value)
      Creates a new intermediate response using the provided response name and value.

      If the response value is not an instance of ByteString then it will be converted using the ByteString.valueOfObject(Object) method.

      Parameters:
      oid - The dotted-decimal representation of the unique OID corresponding to this intermediate response, which may be null indicating that none was provided.
      value - The response value associated with this intermediate response, which may be null indicating that none was provided.
      Returns:
      The new intermediate response.
    • newPasswordModifyExtendedResult

      public static PasswordModifyExtendedResult newPasswordModifyExtendedResult(ResultCode resultCode, ByteString password)
      Creates a new password modify extended result using the provided result code, and no generated password.
      Parameters:
      resultCode - The result code.
      password - The generated password, or null if there is no generated password associated with this result.
      Returns:
      The new password modify extended result.
    • newPasswordModifyExtendedResult

      public static PasswordModifyExtendedResult newPasswordModifyExtendedResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, ByteString password)
      Creates a new password modify extended result using the provided result code, and no generated password.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      password - The generated password, or null if there is no generated password associated with this result.
      Returns:
      The new password modify extended result.
    • newResult

      public static Result newResult(ResultCode resultCode)
      Creates a new result using the provided result code.
      Parameters:
      resultCode - The result code.
      Returns:
      The new result.
    • newResult

      public static Result newResult(ResultCode resultCode, CharSequence diagnosticMessage)
      Creates a new result using the provided result code, the cause, the diagnostic message and the matched DN.
      Parameters:
      resultCode - The result code.
      diagnosticMessage - The diagnostic message, which may be empty or null indicating that none was provided.
      Returns:
      The new result.
    • newResult

      public static Result newResult(ResultCode resultCode, Dn matchedDn, CharSequence diagnosticMessage)
      Creates a new result using the provided result code, the cause, the diagnostic message and the matched DN.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null indicating that none was provided.
      Returns:
      The new result.
    • newResult

      public static Result newResult(ResultCode resultCode, Dn matchedDn, CharSequence diagnosticMessage, Throwable cause)
      Creates a new result using the provided result code, the cause, the diagnostic message and the matched DN.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null indicating that none was provided.
      cause - The throwable cause, which may be null indicating that none was provided.
      Returns:
      The new result.
    • newResult

      public static Result newResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, List<String> referralUris, Throwable cause)
      Creates a new result using the provided result code, the cause, the diagnostic message and the matched DN.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null indicating that none was provided.
      referralUris - The optional referrals are present in a ResultImpl if the result code is set to ResultCode.REFERRAL, and they are absent with all other result codes.
      cause - The throwable cause, which may be null indicating that none was provided.
      Returns:
      The new result.
    • newResult

      public static Result newResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, List<String> referralUris, List<Control> controls, Throwable cause)
      Creates a new result using the provided result code, the cause, the diagnostic message and the matched DN.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null indicating that none was provided.
      referralUris - The optional referrals are present in a ResultImpl if the result code is set to ResultCode.REFERRAL, and they are absent with all other result codes.
      controls - the List containing the controls.
      cause - The throwable cause, which may be null indicating that none was provided.
      Returns:
      The new result.
    • newSearchResultEntry

      public static SearchResultEntry newSearchResultEntry(Dn name)
      Creates a new search result entry using the provided distinguished name.
      Parameters:
      name - The distinguished name of the entry.
      Returns:
      The new search result entry.
    • newSearchResultEntry

      public static SearchResultEntry newSearchResultEntry(Entry entry)
      Creates a new search result entry backed by the provided entry. Modifications made to entry will be reflected in the returned search result entry. The returned search result entry supports updates to its list of controls, as well as updates to the name and attributes if the underlying entry allows.
      Parameters:
      entry - The entry.
      Returns:
      The new search result entry.
    • newSearchResultEntry

      public static SearchResultEntry newSearchResultEntry(String name)
      Creates a new search result entry using the provided distinguished name decoded using the default schema.
      Parameters:
      name - The distinguished name of the entry.
      Returns:
      The new search result entry.
    • newSearchResultEntry

      public static SearchResultEntry newSearchResultEntry(String... ldifLines)
      Creates a new search result entry using the provided lines of LDIF decoded using the default schema.
      Parameters:
      ldifLines - Lines of LDIF containing an LDIF add change record or an LDIF entry record.
      Returns:
      The new search result entry.
    • newSearchResultReference

      public static SearchResultReference newSearchResultReference(String uri)
      Creates a new search result reference using the provided continuation reference URI.
      Parameters:
      uri - The first continuation reference URI to be added to this search result reference.
      Returns:
      The new search result reference.
      Throws:
      NullPointerException - If uri was null.
    • newSearchResultReference

      public static SearchResultReference newSearchResultReference(List<String> uris)
      Creates a new search result reference using the provided continuation reference URIs.
      Parameters:
      uris - The reference URIs to be added to this search result reference.
      Returns:
      The new search result reference.
    • newStartTlsExtendedResult

      public static StartTlsExtendedResult newStartTlsExtendedResult(ResultCode resultCode, SslOptions sslOptions)
      Creates a new start TLS extended result which will use the provided SSL context.
      Parameters:
      resultCode - The result code.
      sslOptions - The SslOptions which should be used to secure the connection on TLS layer.
      Returns:
      The new start TLS extended request.
    • newStartTlsExtendedResult

      public static StartTlsExtendedResult newStartTlsExtendedResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, List<Control> controls, Throwable cause, SslOptions sslOptions)
      Creates a new start TLS extended result which will use the provided SSL context.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null indicating that none was provided.
      controls - The List containing the controls.
      cause - The throwable cause, which may be null indicating that none was provided.
      sslOptions - The SslOptions which should be used to secure the connection on TLS layer.
      Returns:
      The new start TLS extended request.
    • newWhoAmIExtendedResult

      public static WhoAmIExtendedResult newWhoAmIExtendedResult(ResultCode resultCode, String matchedDn, CharSequence diagnosticMessage, String authorizationId)
      Creates a new who am I extended result with the provided result code, diagnosticMessage and matchedDn.
      Parameters:
      resultCode - The result code.
      matchedDn - The matched DN associated, which may be empty or null indicating that none was provided.
      diagnosticMessage - The diagnostic message, which may be empty or null.
      authorizationId - The authorization ID of the user, that usually has the form "dn:" immediately followed by the distinguished name of the user, or "u:" followed by a user ID string, but other forms are permitted. The authorization ID may be null or empty if this result does not contain an authorization ID.
      Returns:
      The new who am I extended result.