mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

pgamba
01.21.2008 05d24dcca61eed7921987a98bb94d94a4aa030cd
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartMessage.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.replication.protocol;
@@ -54,6 +54,7 @@
  private int maxReceiveDelay;
  private int maxSendDelay;
  private int windowSize;
  private boolean handshakeOnly;
  private ServerState serverState = null;
  /**
@@ -87,6 +88,8 @@
   * @param generationId The generationId for this server.
   * @param sslEncryption Whether to continue using SSL to encrypt messages
   *                      after the start messages have been exchanged.
   * @param handshakeOnly Whether this message is only to get an handshake
   *                      with the server or not.
   */
  public ServerStartMessage(short serverId, DN baseDn, int maxReceiveDelay,
                            int maxReceiveQueue, int maxSendDelay,
@@ -95,7 +98,8 @@
                            ServerState serverState,
                            short protocolVersion,
                            long generationId,
                            boolean sslEncryption)
                            boolean sslEncryption,
                            boolean handshakeOnly)
  {
    super(protocolVersion, generationId);
@@ -109,6 +113,7 @@
    this.heartbeatInterval = heartbeatInterval;
    this.sslEncryption = sslEncryption;
    this.serverState = serverState;
    this.handshakeOnly = handshakeOnly;
    try
    {
@@ -209,10 +214,19 @@
      sslEncryption = Boolean.valueOf(new String(in, pos, length, "UTF-8"));
      pos += length +1;
      /*
       * read the handshakeOnly flag
       */
      length = getNextLength(in, pos);
      handshakeOnly = Boolean.valueOf(new String(in, pos, length, "UTF-8"));
      pos += length +1;
      /*
      * read the ServerState
      */
      serverState = new ServerState(in, pos, in.length-1);
    } catch (UnsupportedEncodingException e)
    {
      throw new DataFormatException("UTF-8 is not supported by this jvm.");
@@ -322,6 +336,8 @@
      byte[] byteSSLEncryption =
                     String.valueOf(sslEncryption).getBytes("UTF-8");
      byte[] byteServerState = serverState.getBytes();
      byte[] byteHandshakeOnly =
        String.valueOf(handshakeOnly).getBytes("UTF-8");
      int length = byteDn.length + 1 + byteServerId.length + 1 +
                   byteServerUrl.length + 1 +
@@ -332,6 +348,7 @@
                   byteWindowSize.length + 1 +
                   byteHeartbeatInterval.length + 1 +
                   byteSSLEncryption.length + 1 +
                   byteHandshakeOnly.length + 1 +
                   byteServerState.length + 1;
      /* encode the header in a byte[] large enough to also contain the mods */
@@ -358,6 +375,8 @@
      pos = addByteArray(byteSSLEncryption, resultByteArray, pos);
      pos = addByteArray(byteHandshakeOnly, resultByteArray, pos);
      pos = addByteArray(byteServerState, resultByteArray, pos);
      return resultByteArray;
@@ -401,4 +420,16 @@
  {
    return sslEncryption;
  }
  /**
   * Get the SSL encryption value for the ldap server that created the
   * message.
   *
   * @return The SSL encryption value for the ldap server that created the
   *         message.
   */
  public boolean isHandshakeOnly()
  {
    return handshakeOnly;
  }
}