0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License, Version 1.0 only
0N/A * (the "License"). You may not use this file except in compliance
0N/A * with the License.
0N/A *
6983N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6983N/A * or http://forgerock.org/license/CDDLv1.0.html.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
6983N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
6983N/A * If applicable, add the following below this CDDL HEADER, with the
6983N/A * fields enclosed by brackets "[]" replaced with your own identifying
6983N/A * information:
0N/A * Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A *
0N/A *
3231N/A * Copyright 2006-2008 Sun Microsystems, Inc.
0N/A */
0N/Apackage org.opends.server.protocols.ldap;
0N/A
0N/A
4134N/Aimport java.io.IOException;
0N/A
4134N/Aimport org.opends.server.protocols.asn1.*;
4134N/Aimport org.opends.server.types.ByteString;
0N/A
1177N/Aimport static org.opends.server.loggers.debug.DebugLogger.*;
1400N/Aimport org.opends.server.loggers.debug.DebugTracer;
0N/Aimport static org.opends.server.protocols.ldap.LDAPConstants.*;
0N/Aimport static org.opends.server.util.ServerConstants.*;
0N/A
0N/A
0N/A/**
0N/A * This class defines the structures and methods for an LDAP compare request
0N/A * protocol op, which is used to determine whether a particular entry contains
0N/A * a specified attribute value.
0N/A */
0N/Apublic class CompareRequestProtocolOp
0N/A extends ProtocolOp
0N/A{
1400N/A /**
1400N/A * The tracer object for the debug logger.
1400N/A */
1400N/A private static final DebugTracer TRACER = getTracer();
1400N/A
0N/A // The assertion value for this compare request.
4134N/A private ByteString assertionValue;
0N/A
0N/A // The DN for this compare request.
4134N/A private ByteString dn;
0N/A
0N/A // The attribute type for this compare request.
0N/A private String attributeType;
0N/A
0N/A
0N/A
0N/A /**
0N/A * Creates a new compare request protocol op with the provided information.
0N/A *
0N/A * @param dn The DN for this compare request.
0N/A * @param attributeType The attribute type for this compare request.
0N/A * @param assertionValue The assertion value for this compare request.
0N/A */
4134N/A public CompareRequestProtocolOp(ByteString dn, String attributeType,
4134N/A ByteString assertionValue)
0N/A {
0N/A this.dn = dn;
0N/A this.attributeType = attributeType;
0N/A this.assertionValue = assertionValue;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the DN for this compare request.
0N/A *
0N/A * @return The DN for this compare request.
0N/A */
4134N/A public ByteString getDN()
0N/A {
0N/A return dn;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the attribute type for this compare request.
0N/A *
0N/A * @return The attribute type for this compare request.
0N/A */
0N/A public String getAttributeType()
0N/A {
0N/A return attributeType;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the assertion value for this compare request.
0N/A *
0N/A * @return The assertion value for this compare request.
0N/A */
4134N/A public ByteString getAssertionValue()
0N/A {
0N/A return assertionValue;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the BER type for this protocol op.
0N/A *
0N/A * @return The BER type for this protocol op.
0N/A */
0N/A public byte getType()
0N/A {
0N/A return OP_TYPE_COMPARE_REQUEST;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the name for this protocol op type.
0N/A *
0N/A * @return The name for this protocol op type.
0N/A */
0N/A public String getProtocolOpName()
0N/A {
0N/A return "Compare Request";
0N/A }
0N/A
0N/A /**
4134N/A * Writes this protocol op to an ASN.1 output stream.
0N/A *
4134N/A * @param stream The ASN.1 output stream to write to.
4134N/A * @throws IOException If a problem occurs while writing to the stream.
0N/A */
4134N/A public void write(ASN1Writer stream) throws IOException
0N/A {
4134N/A stream.writeStartSequence(OP_TYPE_COMPARE_REQUEST);
4134N/A stream.writeOctetString(dn);
0N/A
4134N/A stream.writeStartSequence();
4134N/A stream.writeOctetString(attributeType);
4134N/A stream.writeOctetString(assertionValue);
4134N/A stream.writeEndSequence();
0N/A
4134N/A stream.writeEndSequence();
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Appends a string representation of this LDAP protocol op to the provided
0N/A * buffer.
0N/A *
0N/A * @param buffer The buffer to which the string should be appended.
0N/A */
0N/A public void toString(StringBuilder buffer)
0N/A {
0N/A buffer.append("CompareRequest(dn=");
4134N/A buffer.append(dn.toString());
0N/A buffer.append(", attribute=");
0N/A buffer.append(attributeType);
0N/A buffer.append(", value=");
4134N/A buffer.append(assertionValue.toString());
0N/A buffer.append(")");
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Appends a multi-line string representation of this LDAP protocol op to the
0N/A * provided buffer.
0N/A *
0N/A * @param buffer The buffer to which the information should be appended.
0N/A * @param indent The number of spaces from the margin that the lines should
0N/A * be indented.
0N/A */
0N/A public void toString(StringBuilder buffer, int indent)
0N/A {
0N/A StringBuilder indentBuf = new StringBuilder(indent);
0N/A for (int i=0 ; i < indent; i++)
0N/A {
0N/A indentBuf.append(' ');
0N/A }
0N/A
0N/A buffer.append(indentBuf);
0N/A buffer.append("Compare Request");
0N/A buffer.append(EOL);
0N/A
0N/A buffer.append(indentBuf);
0N/A buffer.append(" Target DN: ");
4134N/A buffer.append(dn.toString());
0N/A buffer.append(EOL);
0N/A
0N/A buffer.append(indentBuf);
0N/A buffer.append(" Attribute Type: ");
0N/A buffer.append(attributeType);
0N/A buffer.append(EOL);
0N/A
0N/A buffer.append(indentBuf);
0N/A buffer.append(" Assertion Value:");
0N/A buffer.append(EOL);
4134N/A assertionValue.toHexPlusAscii(buffer, indent+4);
0N/A }
0N/A}
0N/A