Replaced uses of StringBuilder.append(Utils.joinAsString(String, Collection)) with the more efficient Utils.joinAsString(StringBuilder, String, Collection).
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public AddResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | return referralURLs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_ADD_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Add Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_ADD_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("AddResponse(resultCode="); |
| | |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public BindResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | serverSASLCredentials = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | serverSASLCredentials = null; |
| | | } |
| | | |
| | | |
| | |
| | | this.errorMessage = errorMessage; |
| | | this.matchedDN = matchedDN; |
| | | this.referralURLs = referralURLs; |
| | | |
| | | serverSASLCredentials = null; |
| | | } |
| | | |
| | | |
| | |
| | | return serverSASLCredentials; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_BIND_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Bind Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_BIND_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("BindResponse(resultCode="); |
| | |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public CompareResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | return referralURLs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_COMPARE_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Compare Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_COMPARE_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("CompareResponse(resultCode="); |
| | |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public DeleteResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | return referralURLs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_DELETE_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Delete Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_DELETE_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("DeleteResponse(resultCode="); |
| | |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public ExtendedResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | oid = null; |
| | | value = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | oid = null; |
| | | value = null; |
| | | } |
| | | |
| | | |
| | |
| | | this.errorMessage = errorMessage; |
| | | this.matchedDN = matchedDN; |
| | | this.referralURLs = referralURLs; |
| | | |
| | | oid = null; |
| | | value = null; |
| | | } |
| | | |
| | | |
| | |
| | | return value; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_EXTENDED_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Extended Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_EXTENDED_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("ExtendedResponse(resultCode="); |
| | |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | if (oid != null && oid.length() > 0) |
| | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public ModifyDNResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | return referralURLs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_MODIFY_DN_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Modify DN Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_MODIFY_DN_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("ModifyDNResponse(resultCode="); |
| | |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public ModifyResponseProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | return referralURLs; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_MODIFY_RESPONSE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Modify Response"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_MODIFY_RESPONSE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("ModifyResponse(resultCode="); |
| | |
| | | if (referralURLs != null && ! referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.RawFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.RawFilter; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | return attributes; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_SEARCH_REQUEST; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Search Request"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | |
| | | |
| | | if (attributes != null && ! attributes.isEmpty()) |
| | | { |
| | | buffer.append(Utils.joinAsString(", ", attributes)); |
| | | Utils.joinAsString(buffer, ", ", attributes); |
| | | } |
| | | |
| | | buffer.append("})"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | /** The matched DN for this response. */ |
| | | private DN matchedDN; |
| | | |
| | | /** The result code for this response. */ |
| | | private int resultCode; |
| | | |
| | | /** The set of referral URLs for this response. */ |
| | | private List<String> referralURLs; |
| | | |
| | | /** The error message for this response. */ |
| | | private LocalizableMessage errorMessage; |
| | | |
| | |
| | | public SearchResultDoneProtocolOp(int resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | | |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.resultCode = resultCode; |
| | | this.errorMessage = errorMessage; |
| | | |
| | | matchedDN = null; |
| | | referralURLs = null; |
| | | } |
| | | |
| | | |
| | |
| | | return referralURLs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the BER type for this protocol op. |
| | | * |
| | | * @return The BER type for this protocol op. |
| | | */ |
| | | @Override |
| | | public byte getType() |
| | | { |
| | | return OP_TYPE_SEARCH_RESULT_DONE; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name for this protocol op type. |
| | | * |
| | | * @return The name for this protocol op type. |
| | | */ |
| | | @Override |
| | | public String getProtocolOpName() |
| | | { |
| | | return "Search Result Done"; |
| | | } |
| | | |
| | | /** |
| | | * Writes this protocol op to an ASN.1 output stream. |
| | | * |
| | | * @param stream The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void write(ASN1Writer stream) throws IOException |
| | | { |
| | | stream.writeStartSequence(OP_TYPE_SEARCH_RESULT_DONE); |
| | |
| | | stream.writeEndSequence(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this LDAP protocol op to the provided |
| | | * buffer. |
| | | * |
| | | * @param buffer The buffer to which the string should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("SearchResultDone(resultCode="); |
| | |
| | | if (referralURLs != null && !referralURLs.isEmpty()) |
| | | { |
| | | buffer.append(", referralURLs={"); |
| | | buffer.append(Utils.joinAsString(", ", referralURLs)); |
| | | Utils.joinAsString(buffer, ", ", referralURLs); |
| | | buffer.append("}"); |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a multi-line string representation of this LDAP protocol op to the |
| | | * provided buffer. |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | * @param indent The number of spaces from the margin that the lines should |
| | | * be indented. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | buffer.append("Attribute("); |
| | | buffer.append(getNameWithOptions()); |
| | | buffer.append(", {"); |
| | | buffer.append(Utils.joinAsString(", ", values)); |
| | | Utils.joinAsString(buffer, ", ", values); |
| | | buffer.append("})"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | this.normalizedOptions = normalizedOptions; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getOptions() |
| | | { |
| | | return options; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | |
| | | return normalizedOptions.contains(s); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | |
| | | super(attributeType, name, values); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getNameWithOptions() |
| | | { |
| | | return getName(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getOptions() |
| | | { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasAllOptions(Collection<String> options) |
| | | { |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean optionsEqual(Set<String> options) |
| | | { |
| | |
| | | this.normalizedOption = toLowerCase(option); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getOptions() |
| | | { |
| | | return option; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | |
| | | return normalizedOption.equals(s); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | |
| | | return CollectionUtils.newArrayList(toAttribute()); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | |
| | | builder.append("AttributeBuilder("); |
| | | builder.append(name); |
| | | |
| | |
| | | } |
| | | |
| | | builder.append(", {"); |
| | | builder.append(Utils.joinAsString(", ", values)); |
| | | Utils.joinAsString(builder, ", ", values); |
| | | builder.append("})"); |
| | | |
| | | return builder.toString(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | |
| | | /** The attribute type. */ |
| | | private final AttributeType attributeType; |
| | | |
| | | /** The entry with which this virtual attribute is associated. */ |
| | | private final Entry entry; |
| | | |
| | | /** The virtual attribute provider for this virtual attribute. */ |
| | | private final VirtualAttributeProvider<?> provider; |
| | | |
| | | /** The virtual attribute rule for this virtual attribute. */ |
| | | private final VirtualAttributeRule rule; |
| | | |
| | |
| | | this.provider = rule.getProvider(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult approximatelyEqualTo(ByteString assertionValue) |
| | | { |
| | | return provider.approximatelyEqualTo(entry, rule, assertionValue); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean contains(ByteString value) |
| | | { |
| | | return provider.hasValue(entry, rule, value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean containsAll(Collection<ByteString> values) |
| | | { |
| | | return provider.hasAllValues(entry, rule, values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult matchesEqualityAssertion(ByteString assertionValue) |
| | | { |
| | | return provider.matchesEqualityAssertion(entry, rule, assertionValue); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType getAttributeType() |
| | | { |
| | | return attributeType; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getNameWithOptions() |
| | | { |
| | | return getName(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getOptions() |
| | | { |
| | |
| | | return rule; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult greaterThanOrEqualTo(ByteString assertionValue) |
| | | { |
| | | return provider.greaterThanOrEqualTo(entry, rule, assertionValue); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasAllOptions(Collection<String> options) |
| | | { |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isEmpty() |
| | | { |
| | | return !provider.hasValue(entry, rule); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isVirtual() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterator<ByteString> iterator() |
| | | { |
| | | return provider.getValues(entry, rule).iterator(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult lessThanOrEqualTo(ByteString assertionValue) |
| | | { |
| | | return provider.lessThanOrEqualTo(entry, rule, assertionValue); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult matchesSubstring(ByteString subInitial, |
| | | List<ByteString> subAny, ByteString subFinal) |
| | |
| | | return provider.matchesSubstring(entry, rule, subInitial, subAny, subFinal); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean optionsEqual(Set<String> options) |
| | | { |
| | | return options == null || options.isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int size() |
| | | { |
| | |
| | | return provider.hasValue(entry, rule) ? 1 : 0; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("VirtualAttribute("); |
| | | buffer.append(getAttributeType().getNameOrOID()); |
| | | buffer.append(", {"); |
| | | buffer.append(Utils.joinAsString(", ", this)); |
| | | Utils.joinAsString(buffer, ", ", this); |
| | | buffer.append("})"); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Set; |
| | | |
| | |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | /** |
| | | * This class defines a virtual attribute rule, which associates a |
| | | * virtual attribute provider with its associated configuration, |
| | |
| | | |
| | | /** The attribute type for which the values should be generated. */ |
| | | private final AttributeType attributeType; |
| | | |
| | | /** |
| | | * The set of base DNs for branches that are eligible to have this virtual |
| | | * attribute. |
| | | */ |
| | | /** The set of base DNs for branches that are eligible to have this virtual attribute. */ |
| | | private final Set<DN> baseDNs; |
| | | |
| | | /** |
| | | * The scope of entries eligible to have this virtual attribute, under the |
| | | * base DNs. |
| | | */ |
| | | /** The scope of entries eligible to have this virtual attribute, under the base DNs. */ |
| | | private final SearchScope scope; |
| | | |
| | | /** |
| | | * The set of DNs for groups whose members are eligible to have this virtual |
| | | * attribute. |
| | | */ |
| | | /** The set of DNs for groups whose members are eligible to have this virtual attribute. */ |
| | | private final Set<DN> groupDNs; |
| | | |
| | | /** |
| | | * The set of search filters for entries that are eligible to have this |
| | | * virtual attribute. |
| | | */ |
| | | /** The set of search filters for entries that are eligible to have this virtual attribute. */ |
| | | private final Set<SearchFilter> filters; |
| | | |
| | | /** The virtual attribute provider used to generate the values. */ |
| | | private final VirtualAttributeProvider< |
| | | ? extends VirtualAttributeCfg> provider; |
| | | |
| | | private final VirtualAttributeProvider<? extends VirtualAttributeCfg> provider; |
| | | /** |
| | | * The behavior that should be exhibited for entries that already have real |
| | | * values for the target attribute. |
| | | */ |
| | | private final VirtualAttributeCfgDefn.ConflictBehavior |
| | | conflictBehavior; |
| | | |
| | | |
| | | private final VirtualAttributeCfgDefn.ConflictBehavior conflictBehavior; |
| | | |
| | | /** |
| | | * Creates a new virtual attribute rule with the provided information. |
| | |
| | | this.conflictBehavior = conflictBehavior; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute type for which the values should be generated. |
| | | * |
| | |
| | | return attributeType; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * |
| | | * Retrieves the virtual attribute provider used to generate the values. |
| | | * |
| | | * @return The virtual attribute provider to use to generate the values. |
| | |
| | | return provider; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of base DNs for branches that are eligible to |
| | | * have this virtual attribute. |
| | |
| | | return baseDNs; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Retrieves the scope of entries in the base DNs that are eligible |
| | | * to have this virtual attribute. |
| | |
| | | return scope; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of DNs for groups whose members are eligible to |
| | | * have this virtual attribute. |
| | |
| | | return groupDNs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of search filters for entries that are eligible |
| | | * to have this virtual attribute. |
| | |
| | | return filters; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the behavior that the server should exhibit for entries |
| | | * that already have one or more real values for the target attribute. |
| | |
| | | return conflictBehavior; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this virtual attribute rule applies to the |
| | | * provided entry, taking into account the eligibility requirements |
| | |
| | | return false; |
| | | } |
| | | |
| | | // If there are any base DNs defined, then the entry must be below |
| | | // one of them. |
| | | DN entryDN = entry.getName(); |
| | | if (! baseDNs.isEmpty()) |
| | | { |
| | | boolean found = false; |
| | | for (DN dn : baseDNs) |
| | | { |
| | | if (entryDN.matchesBaseAndScope(dn , scope)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (! found) |
| | | // If there are any base DNs defined, then the entry must be below one of them. |
| | | if (!baseDNs.isEmpty() && !matchesAnyBaseDN(entry.getName())) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // If there are any search filters defined, then the entry must |
| | | // match one of them. |
| | | if (! filters.isEmpty()) |
| | | { |
| | | boolean found = false; |
| | | for (SearchFilter filter : filters) |
| | | { |
| | | try |
| | | { |
| | | if (filter.matchesEntry(entry)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | | if (! found) |
| | | // If there are any search filters defined, then the entry must match one of them. |
| | | if (!filters.isEmpty() && !matchesAnyFilter(entry)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // If there are any group memberships defined, then the entry must |
| | | // be a member of one of them. |
| | | if (! groupDNs.isEmpty()) |
| | | { |
| | | boolean found = false; |
| | | for (DN dn : groupDNs) |
| | | { |
| | | try |
| | | { |
| | | Group group = |
| | | DirectoryServer.getGroupManager().getGroupInstance(dn); |
| | | if (group != null && group.isMember(entry)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | | if (! found) |
| | | if (!groupDNs.isEmpty() && !isMemberOfAnyGroup(entry)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // If we've gotten here, then the rule is applicable. |
| | | return true; |
| | | } |
| | | |
| | | private boolean matchesAnyBaseDN(DN entryDN) |
| | | { |
| | | for (DN dn : baseDNs) |
| | | { |
| | | if (entryDN.matchesBaseAndScope(dn, scope)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean matchesAnyFilter(Entry entry) |
| | | { |
| | | for (SearchFilter filter : filters) |
| | | { |
| | | try |
| | | { |
| | | if (filter.matchesEntry(entry)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a string representation of this virtual attribute rule. |
| | | * |
| | | * @return A string representation of this virtual attribute rule. |
| | | */ |
| | | private boolean isMemberOfAnyGroup(Entry entry) |
| | | { |
| | | for (DN dn : groupDNs) |
| | | { |
| | | try |
| | | { |
| | | Group<?> group = DirectoryServer.getGroupManager().getGroupInstance(dn); |
| | | if (group != null && group.isMember(entry)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() |
| | | { |
| | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a string representation of this virtual attribute rule to |
| | | * the provided buffer. |
| | |
| | | if (!col.isEmpty()) |
| | | { |
| | | buffer.append("\""); |
| | | buffer.append(Utils.joinAsString("\", \"", col)); |
| | | Utils.joinAsString(buffer, "\", \"", col); |
| | | buffer.append("\""); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.util.Utils; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | else |
| | | { |
| | | definition.append("( '"); |
| | | definition.append(Utils.joinAsString("' '", nameSet)); |
| | | Utils.joinAsString(definition, "' '", nameSet); |
| | | definition.append("' )"); |
| | | } |
| | | } |
| | |
| | | else |
| | | { |
| | | definition.append("( '"); |
| | | definition.append(Utils.joinAsString("' '", nameSet)); |
| | | Utils.joinAsString(definition, "' '", nameSet); |
| | | definition.append("' )"); |
| | | } |
| | | } |