directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r279903 - /directory/sandbox/trunk/proxy/src/java/main/org/apache/ldap/proxy/impl/ProxyConnection.java
Date Fri, 09 Sep 2005 22:52:09 GMT
Author: elecharny
Date: Fri Sep  9 15:52:04 2005
New Revision: 279903

URL: http://svn.apache.org/viewcvs?rev=279903&view=rev
Log:
Updated with Jocelyn modifications

Modified:
    directory/sandbox/trunk/proxy/src/java/main/org/apache/ldap/proxy/impl/ProxyConnection.java

Modified: directory/sandbox/trunk/proxy/src/java/main/org/apache/ldap/proxy/impl/ProxyConnection.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/proxy/src/java/main/org/apache/ldap/proxy/impl/ProxyConnection.java?rev=279903&r1=279902&r2=279903&view=diff
==============================================================================
--- directory/sandbox/trunk/proxy/src/java/main/org/apache/ldap/proxy/impl/ProxyConnection.java
(original)
+++ directory/sandbox/trunk/proxy/src/java/main/org/apache/ldap/proxy/impl/ProxyConnection.java
Fri Sep  9 15:52:04 2005
@@ -1,418 +1,415 @@
-/*
- *   Copyright 2005 The Apache Software Foundation
- *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- */
-
-package org.apache.ldap.proxy.impl;
-
-import java.io.BufferedOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.nio.ByteBuffer;
-
-import java.util.Date;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-
-import org.apache.asn1.codec.DecoderException;
-import org.apache.asn1new.ber.Asn1Decoder;
-import org.apache.asn1new.ber.containers.IAsn1Container;
-import org.apache.asn1new.ldap.codec.LdapDecoder;
-import org.apache.asn1new.ldap.codec.LdapMessageContainer;
-import org.apache.asn1new.ldap.pojo.LdapMessage;
-import org.apache.asn1new.util.StringUtils;
-import org.apache.ldap.proxy.gui.MainFrame;
-
-/**
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-class ProxyConnection extends Thread
-{
-
-    Socket                 fromClient;
-
-    String                 host;
-
-    int                    port;
-
-    long                   timeout;
-
-    MainFrame              mainFrame;
-
-    int                    lastMessageId = -1;
-
-    DefaultMutableTreeNode lastNode;
-
-    DefaultMutableTreeNode lastMessNode;
-
-    int                    currentCount  = 0;
-
-    ProxyConnection(Socket s, String host, int port, long timeout)
-    {
-        fromClient = s;
-        this.host = host;
-        this.port = port;
-        this.timeout = timeout;
-
-    }
-
-    private String decode( ByteBuffer buffer ) throws DecoderException
-    {
-        int position = buffer.position();
-
-        DefaultMutableTreeNode mess;
-
-        // DefaultMutableTreeNode messTrue;
-        DefaultMutableTreeNode messTrue;
-
-        Asn1Decoder ldapDecoder = new LdapDecoder();
-
-        // Allocate a LdapMessageContainer Container
-        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
-
-        // Decode the PDU
-        ldapDecoder.decode( buffer, ldapMessageContainer );
-        // Check that everything is OK
-        LdapMessage ldapmessage = ( (LdapMessageContainer) ldapMessageContainer ).getLdapMessage();
-        LdapMessageWithPDU message = new LdapMessageWithPDU();
-        
-
-        message.setLdapMessage( ldapmessage );
-        message.setMessageId( ldapmessage.getMessageId() );
-
-        // Ici on test pour ne pas cr�er 2 entr� avec le meme messageID;
-        if ( message.getMessageId() != lastMessageId )
-        {
-            mess = new DefaultMutableTreeNode( transformToStringType( ldapmessage.getMessageType()
) + " [Id = "
-                    + ( (LdapMessage) ldapmessage ).getMessageId() + " ]" );
-
-            messTrue = new DefaultMutableTreeNode( message );
-            lastNode = mess;
-            lastMessNode = messTrue;
-            lastMessageId = message.getMessageId();
-            // mainFrame.getTop().add(mess);
-            mainFrame.getTreeModel().insertNodeInto( mess, mainFrame.getTop(), mainFrame.getTop().getChildCount()
);
-            mainFrame.getLdapMessageTree().add( messTrue );
-            currentCount = 1;
-
-        }
-        else
-        {
-            mess = lastNode;
-            messTrue = lastMessNode;
-            currentCount++;
-        }
-
-        // String type = message.getProtocolOp().getClass().getSimpleName();
-        String type = transformToStringType( ldapmessage.getMessageType() );
-
-        // DefaultMutableTreeNode request = new DefaultMutableTreeNode(type +"
-        // ==>" + message.toString());
-        DefaultMutableTreeNode request = new DefaultMutableTreeNode( type + " N� " +
currentCount );
-        // mess.add(request);
-        mainFrame.getTreeModel().insertNodeInto( request, mess, mess.getChildCount() );
-
-        messTrue.add( new DefaultMutableTreeNode( message ) );
-
-        int pduLength = buffer.position() - position;
-        byte[] bytes = buffer.array();
-        byte[] newBytes = new byte[pduLength];
-        System.arraycopy(bytes, position, newBytes, 0, pduLength );
-        
-        message.setDumpBytes( org.apache.asn1new.util.StringUtils.dumpBytes( newBytes ) );
-
-        // mainFrame.repaint();
-        // mainFrame.getTreeModel().reload(mainFrame.getTop());
-        return message.getLdapMessage().toString();
-    }
-
-    public String transformToStringType( int type )
-    {
-        String stringType;
-
-        switch ( type )
-        {
-            case 0 :
-                stringType = "ABANDON REQUEST";
-                break;
-            case 1 :
-                stringType = "ADD REQUEST";
-                break;
-            case 2 :
-                stringType = "ADD RESPONSE";
-                break;
-            case 3 :
-                stringType = "BIND REQUEST";
-                break;
-            case 4 :
-                stringType = "BIND RESPONSE";
-                break;
-            case 5 :
-                stringType = "COMPARE REQUEST";
-                break;
-            case 6 :
-                stringType = "COMPARE RESPONSE";
-                break;
-            case 7 :
-                stringType = "DEL REQUEST";
-                break;
-            case 8 :
-                stringType = "DEL RESPONSE";
-                break;
-            case 9 :
-                stringType = "EXTENDED REQUEST";
-                break;
-            case 10 :
-                stringType = "EXTENDED RESPONSE";
-                break;
-            case 11 :
-                stringType = "MODIFYDN REQUEST";
-                break;
-            case 12 :
-                stringType = "MODIFYDN RESPONSE";
-                break;
-            case 13 :
-                stringType = "MODIFY REQUEST";
-                break;
-            case 14 :
-                stringType = "MODIFY RESPONSE";
-                break;
-            case 15 :
-                stringType = "SEARCH REQUEST";
-                break;
-            case 16 :
-                stringType = "SEARCH RESULT DONE";
-                break;
-            case 17 :
-                stringType = "SEARCH RESULT ENTRY";
-                break;
-            case 18 :
-                stringType = "SEARCH RESULT REFERENCE";
-                break;
-            case 19 :
-                stringType = "UNBIND REQUEST";
-                break;
-            case -1 :
-                stringType = "UNKNOWN";
-                break;
-
-            default :
-                stringType = "UNKNOWN";
-                break;
-        }
-        return stringType;
-    }
-
-    public void run()
-    {
-        InputStream clientIn = null;
-        OutputStream clientOut = null;
-        InputStream serverIn = null;
-        OutputStream serverOut = null;
-        Socket toServer = null;
-        int r0 = -1;
-        int r1 = -1;
-        int ch = -1;
-        int i = -1;
-        long time0 = System.currentTimeMillis();
-        long time1 = time0 + timeout;
-
-        try
-        {
-            toServer = new Socket( host, port );
-            System.out.println( "open connection to:" + toServer + "(timeout=" + timeout
+ " ms)" );
-            clientIn = fromClient.getInputStream();
-            clientOut = new BufferedOutputStream( fromClient.getOutputStream() );
-            serverIn = toServer.getInputStream();
-            serverOut = new BufferedOutputStream( toServer.getOutputStream() );
-
-            while ( r0 != 0 || r1 != 0 || ( time1 - time0 ) <= timeout )
-            {
-                r0 = clientIn.available();
-
-                if ( r0 != 0 )
-                {
-                    System.out.println( "" );
-                    // LdapProxy.setTextIn("<<<" + r0 + " bytes from client
-                    // \n","red");
-                    System.out.println( "" );
-                    System.out.println( "<<<" + r0 + " bytes from client" );
-                    System.out.println( "<<<" + r1 + " bytes from server" );
-                }
-
-                ByteBuffer bb = null;
-
-                while ( ( r0 = clientIn.available() ) > 0 )
-                {
-                    byte[] in = new byte[r0];
-                    int k = 0;
-
-                    for ( i = 0; i < r0; i++ )
-                    {
-                        ch = clientIn.read();
-
-                        if ( ch != -1 )
-                        {
-                            in[k++] = (byte) ch;
-                            serverOut.write( ch );
-                        }
-                        else
-                        {
-                            System.out.println( "client stream closed" );
-                            // LdapProxy.setTextIn("client stream closed
-                            // \n","redbold");
-                        }
-                    }
-
-                    bb = ByteBuffer.allocate( r0 );
-                    bb.put( in );
-                    bb.flip();
-                    
-                    while ( bb.hasRemaining() )
-                    {
-                        decode( bb );
-                    }
-                    
-                    /*
-                     * LdapProxy.setTextIn("--->>>\n", "regular");
-                     * LdapProxy.setTextIn(result, "regular");
-                     * LdapProxy.setTextIn("----------------------------------\n",
-                     * "regular");
-                     */
-
-                    time0 = System.currentTimeMillis();
-                    serverOut.flush();
-                }
-
-                bb = null;
-
-                while ( ( r1 = serverIn.available() ) > 0 )
-                {
-                    System.out.println( "" );
-                    System.out.println( ">>>" + r1 + " bytes from server" );
-                    // LdapProxy.setTextOut(">>>" + r1 + " bytes from server
-                    // \n","red");
-                    System.out.println( "" );
-                    System.out.println( ">>>" + r1 + " bytes from server" );
-
-                    byte[] out = new byte[r1];
-                    int k = 0;
-
-                    for ( i = 0; i < r1; i++ )
-                    {
-                        ch = serverIn.read();
-
-                        if ( ch != -1 )
-                        {
-                            out[k++] = (byte) ch;
-                        }
-                        else
-                        {
-                            System.out.println( "server stream closed" );
-                            // LdapProxy.setTextOut("server stream closed
-                            // \n","redbold");
-                            break;
-                        }
-
-                        clientOut.write( ch );
-                    }
-
-                    bb = ByteBuffer.allocate( r1 );
-                    bb.put( out );
-                    bb.flip();
-
-                    while ( true )
-                    {
-                        try
-                        {
-                            String result = decode( bb );
-                            System.out.println( result );
-                            /*
-                             * LdapProxy.setTextOut("<<<---\n", "blue");
-                             * LdapProxy.setTextOut(result, "blue");
-                             * LdapProxy.setTextOut("----------------------------------\n",
-                             * "regular");
-                             */
-                            if ( bb.hasRemaining() == false )
-                            {
-                                break;
-                            }
-                        }
-                        catch ( DecoderException de )
-                        {
-                            StringBuffer result = new StringBuffer();
-                            result.append( de.getMessage() ).append( '\n' );
-
-                            byte[] tmp = new byte[out.length - bb.position()];
-                            System.arraycopy( out, bb.position(), tmp, 0, out.length - bb.position()
);
-                            result.append( StringUtils.dumpBytes( tmp ) );
-
-                            System.out.println( result );
-                            /*
-                             * LdapProxy.setTextOut("<<<---\n", "regular");
-                             * LdapProxy.setTextOut(new String(tmp), "regular");
-                             * LdapProxy.setTextOut("----------------------------------\n",
-                             * "regular");
-                             */
-                            break;
-                        }
-                    }
-
-                    time0 = new Date().getTime();
-                    clientOut.flush();
-                }
-                if ( r0 == 0 && r1 == 0 )
-                {
-                    time1 = new Date().getTime();
-                    Thread.sleep( 100 );
-                    // Proxy.display("waiting:"+(time1-time0)+" ms");
-                }
-            }
-        }
-        catch ( Throwable t )
-        {
-            System.out.println( "i=" + i + " ch=" + ch );
-            t.printStackTrace( System.err );
-        }
-        finally
-        {
-            try
-            {
-                clientIn.close();
-                clientOut.close();
-                serverIn.close();
-                serverOut.close();
-                fromClient.close();
-                toServer.close();
-                LdapProxy.quit( time1 - time0 );
-            }
-            catch ( Exception e )
-            {
-                e.printStackTrace( System.err );
-            }
-        }
-    }
-
-    /*
-     * public void setTextIn(JTextPane textIn) { this.textIn = textIn; } public
-     * void setTextOut(JTextPane textOut) { this.textOut = textOut; }
-     */
-
-    public void setMainFrame( MainFrame mainframe )
-    {
-        this.mainFrame = mainframe;
-    }
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.ldap.proxy.impl;
+
+import java.io.BufferedOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+
+import java.util.Date;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.Asn1Decoder;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ldap.codec.LdapDecoder;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.apache.asn1new.util.StringUtils;
+import org.apache.ldap.proxy.gui.MainFrame;
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+class ProxyConnection extends Thread
+{
+
+    Socket                 fromClient;
+
+    String                 host;
+
+    int                    port;
+
+    long                   timeout;
+
+    MainFrame              mainFrame;
+
+    int                    lastMessageId = -1;
+
+    DefaultMutableTreeNode lastNode;
+
+    DefaultMutableTreeNode lastMessNode;
+
+    int                    currentCount  = 0;
+
+    ProxyConnection(Socket s, String host, int port, long timeout)
+    {
+        fromClient = s;
+        this.host = host;
+        this.port = port;
+        this.timeout = timeout;
+
+    }
+
+    private String decode( ByteBuffer buffer ) throws DecoderException
+    {
+        int position = buffer.position();
+
+        DefaultMutableTreeNode mess;
+
+        // DefaultMutableTreeNode messTrue;
+        DefaultMutableTreeNode messTrue;
+
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        // Allocate a LdapMessageContainer Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode the PDU
+        ldapDecoder.decode( buffer, ldapMessageContainer );
+        // Check that everything is OK
+        LdapMessage ldapmessage = ( (LdapMessageContainer) ldapMessageContainer ).getLdapMessage();
+        LdapMessageWithPDU message = new LdapMessageWithPDU();
+        
+
+        message.setLdapMessage( ldapmessage );
+        message.setMessageId( ldapmessage.getMessageId() );
+
+        // check the Id to verfy if it's a new Entry or not
+        if ( message.getMessageId() != lastMessageId )
+        {
+            mess = new DefaultMutableTreeNode( transformToStringType( ldapmessage.getMessageType()
) + " [Id = "
+                    + ( (LdapMessage) ldapmessage ).getMessageId() + " ]" );
+
+            messTrue = new DefaultMutableTreeNode( message );
+            lastNode = mess;
+            lastMessNode = messTrue;
+            lastMessageId = message.getMessageId();
+            // mainFrame.getTop().add(mess);
+            mainFrame.getTreeModel().insertNodeInto( mess, mainFrame.getTop(), mainFrame.getTop().getChildCount()
);
+            mainFrame.getLdapMessageTree().add( messTrue );
+            currentCount = 1;
+
+        }
+        else
+        {
+            mess = lastNode;
+            messTrue = lastMessNode;
+            currentCount++;
+        }
+
+          String type = transformToStringType( ldapmessage.getMessageType() );
+
+        DefaultMutableTreeNode request = new DefaultMutableTreeNode( type );
+        mainFrame.getTreeModel().insertNodeInto( request, mess, mess.getChildCount() );
+
+        messTrue.add( new DefaultMutableTreeNode( message ) );
+
+        int pduLength = buffer.position() - position;
+        byte[] bytes = buffer.array();
+        byte[] newBytes = new byte[pduLength];
+        System.arraycopy(bytes, position, newBytes, 0, pduLength );
+
+        //TODO only one methode to Dump including buffer and position.
+        message.setDumpBytes( org.apache.asn1new.util.StringUtils.dumpBytes( newBytes ) );
+
+        // mainFrame.repaint();
+        // mainFrame.getTreeModel().reload(mainFrame.getTop());
+        return message.getLdapMessage().toString();
+    }
+
+    public String transformToStringType( int type )
+    {
+        String stringType;
+
+        switch ( type )
+        {
+            case 0 :
+                stringType = "ABANDON REQUEST";
+                break;
+            case 1 :
+                stringType = "ADD REQUEST";
+                break;
+            case 2 :
+                stringType = "ADD RESPONSE";
+                break;
+            case 3 :
+                stringType = "BIND REQUEST";
+                break;
+            case 4 :
+                stringType = "BIND RESPONSE";
+                break;
+            case 5 :
+                stringType = "COMPARE REQUEST";
+                break;
+            case 6 :
+                stringType = "COMPARE RESPONSE";
+                break;
+            case 7 :
+                stringType = "DEL REQUEST";
+                break;
+            case 8 :
+                stringType = "DEL RESPONSE";
+                break;
+            case 9 :
+                stringType = "EXTENDED REQUEST";
+                break;
+            case 10 :
+                stringType = "EXTENDED RESPONSE";
+                break;
+            case 11 :
+                stringType = "MODIFYDN REQUEST";
+                break;
+            case 12 :
+                stringType = "MODIFYDN RESPONSE";
+                break;
+            case 13 :
+                stringType = "MODIFY REQUEST";
+                break;
+            case 14 :
+                stringType = "MODIFY RESPONSE";
+                break;
+            case 15 :
+                stringType = "SEARCH REQUEST";
+                break;
+            case 16 :
+                stringType = "SEARCH RESULT DONE";
+                break;
+            case 17 :
+                stringType = "SEARCH RESULT ENTRY";
+                break;
+            case 18 :
+                stringType = "SEARCH RESULT REFERENCE";
+                break;
+            case 19 :
+                stringType = "UNBIND REQUEST";
+                break;
+            case -1 :
+                stringType = "UNKNOWN";
+                break;
+
+            default :
+                stringType = "UNKNOWN";
+                break;
+        }
+        return stringType;
+    }
+
+    public void run()
+    {
+        InputStream clientIn = null;
+        OutputStream clientOut = null;
+        InputStream serverIn = null;
+        OutputStream serverOut = null;
+        Socket toServer = null;
+        int r0 = -1;
+        int r1 = -1;
+        int ch = -1;
+        int i = -1;
+        long time0 = System.currentTimeMillis();
+        long time1 = time0 + timeout;
+
+        try
+        {
+            toServer = new Socket( host, port );
+            System.out.println( "open connection to:" + toServer + "(timeout=" + timeout
+ " ms)" );
+            clientIn = fromClient.getInputStream();
+            clientOut = new BufferedOutputStream( fromClient.getOutputStream() );
+            serverIn = toServer.getInputStream();
+            serverOut = new BufferedOutputStream( toServer.getOutputStream() );
+
+            while ( r0 != 0 || r1 != 0 || ( time1 - time0 ) <= timeout )
+            {
+                r0 = clientIn.available();
+
+                if ( r0 != 0 )
+                {
+                    System.out.println( "" );
+                    // LdapProxy.setTextIn("<<<" + r0 + " bytes from client
+                    // \n","red");
+                    System.out.println( "" );
+                    System.out.println( "<<<" + r0 + " bytes from client" );
+                    System.out.println( "<<<" + r1 + " bytes from server" );
+                }
+
+                ByteBuffer bb = null;
+
+                while ( ( r0 = clientIn.available() ) > 0 )
+                {
+                    byte[] in = new byte[r0];
+                    int k = 0;
+
+                    for ( i = 0; i < r0; i++ )
+                    {
+                        ch = clientIn.read();
+
+                        if ( ch != -1 )
+                        {
+                            in[k++] = (byte) ch;
+                            serverOut.write( ch );
+                        }
+                        else
+                        {
+                            System.out.println( "client stream closed" );
+                            // LdapProxy.setTextIn("client stream closed
+                            // \n","redbold");
+                        }
+                    }
+
+                    bb = ByteBuffer.allocate( r0 );
+                    bb.put( in );
+                    bb.flip();
+                    
+                    while ( bb.hasRemaining() )
+                    {
+                        decode( bb );
+                    }
+                    
+                    /*
+                     * LdapProxy.setTextIn("--->>>\n", "regular");
+                     * LdapProxy.setTextIn(result, "regular");
+                     * LdapProxy.setTextIn("----------------------------------\n",
+                     * "regular");
+                     */
+
+                    time0 = System.currentTimeMillis();
+                    serverOut.flush();
+                }
+
+                bb = null;
+
+                while ( ( r1 = serverIn.available() ) > 0 )
+                {
+                    System.out.println( "" );
+                    System.out.println( ">>>" + r1 + " bytes from server" );
+                    // LdapProxy.setTextOut(">>>" + r1 + " bytes from server
+                    // \n","red");
+                    System.out.println( "" );
+                    System.out.println( ">>>" + r1 + " bytes from server" );
+
+                    byte[] out = new byte[r1];
+                    int k = 0;
+
+                    for ( i = 0; i < r1; i++ )
+                    {
+                        ch = serverIn.read();
+
+                        if ( ch != -1 )
+                        {
+                            out[k++] = (byte) ch;
+                        }
+                        else
+                        {
+                            System.out.println( "server stream closed" );
+                            // LdapProxy.setTextOut("server stream closed
+                            // \n","redbold");
+                            break;
+                        }
+
+                        clientOut.write( ch );
+                    }
+
+                    bb = ByteBuffer.allocate( r1 );
+                    bb.put( out );
+                    bb.flip();
+
+                    while ( true )
+                    {
+                        try
+                        {
+                            String result = decode( bb );
+                            System.out.println( result );
+                            /*
+                             * LdapProxy.setTextOut("<<<---\n", "blue");
+                             * LdapProxy.setTextOut(result, "blue");
+                             * LdapProxy.setTextOut("----------------------------------\n",
+                             * "regular");
+                             */
+                            if ( bb.hasRemaining() == false )
+                            {
+                                break;
+                            }
+                        }
+                        catch ( DecoderException de )
+                        {
+                            StringBuffer result = new StringBuffer();
+                            result.append( de.getMessage() ).append( '\n' );
+
+                            byte[] tmp = new byte[out.length - bb.position()];
+                            System.arraycopy( out, bb.position(), tmp, 0, out.length - bb.position()
);
+                            result.append( StringUtils.dumpBytes( tmp ) );
+
+                            System.out.println( result );
+                            /*
+                             * LdapProxy.setTextOut("<<<---\n", "regular");
+                             * LdapProxy.setTextOut(new String(tmp), "regular");
+                             * LdapProxy.setTextOut("----------------------------------\n",
+                             * "regular");
+                             */
+                            break;
+                        }
+                    }
+
+                    time0 = new Date().getTime();
+                    clientOut.flush();
+                }
+                if ( r0 == 0 && r1 == 0 )
+                {
+                    time1 = new Date().getTime();
+                    Thread.sleep( 100 );
+                    // Proxy.display("waiting:"+(time1-time0)+" ms");
+                }
+            }
+        }
+        catch ( Throwable t )
+        {
+            System.out.println( "i=" + i + " ch=" + ch );
+            t.printStackTrace( System.err );
+        }
+        finally
+        {
+            try
+            {
+                clientIn.close();
+                clientOut.close();
+                serverIn.close();
+                serverOut.close();
+                fromClient.close();
+                toServer.close();
+                LdapProxy.quit( time1 - time0 );
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace( System.err );
+            }
+        }
+    }
+
+    /*
+     * public void setTextIn(JTextPane textIn) { this.textIn = textIn; } public
+     * void setTextOut(JTextPane textOut) { this.textOut = textOut; }
+     */
+
+    public void setMainFrame( MainFrame mainframe )
+    {
+        this.mainFrame = mainframe;
+    }
 }



Mime
View raw message