001: // @(#)ReaderWriterDecrypt.java 1.12 "@(#)ReaderWriterDecrypt.java 1.12 99/09/23 Sun Microsystems"
002:
003: package com.sun.portal.netlet.econnection;
004:
005: import java.io.InputStream;
006: import java.io.OutputStream;
007:
008: public class ReaderWriterDecrypt extends ReaderWriterCrypt implements
009: GWRunnable {
010:
011: /*
012: * Added for RFE 4492648
013: */
014: String threadName = null;
015:
016: private long activityTime = System.currentTimeMillis();
017: private long bytesTransferred = 0;
018:
019: public long getBytesTransferred() {
020: return bytesTransferred;
021: }
022:
023: public void resetTrafficInfo() {
024: bytesTransferred = 0;
025: }
026:
027: public ReaderWriterDecrypt(ReaderWriterLock l,
028: InputStream inStream, OutputStream outStream) {
029: super (l, inStream, outStream);
030: }
031:
032: public void run() {
033: threadName = Thread.currentThread().getName();
034: // System.out.println("ReaderWriterDecrypt running");
035: try {
036: DataCipherMsg dMsg = new DataCipherMsg();
037: byte[] buffer = new byte[MAXBUFFERSIZE];
038: dMsg.setDataByRef(buffer, 0);
039:
040: while (go) {
041: try {
042: if (dMsg.readMsg(in) == 0) {
043: // ****** don't remove. It's hack to make ftp work
044: // ****** in win98 with netscape4x
045: System.out.print("");
046:
047: if (dMsg.getMsgLen() > 0) {
048: int newsize = FindDynamicPort(buffer, dMsg
049: .getMsgLen());
050: if (newsize == 0)
051: out.write(buffer, 0, dMsg.getMsgLen());
052: else
053: out.write(buffer, 0, newsize);
054: out.flush();
055: sent = true;
056: activityTime = System.currentTimeMillis();
057: } else if (dMsg.getMsgLen() == -1) {
058: go = false;
059: }
060: } else {
061: go = false;
062: return;
063: }
064: } catch (Exception e) {
065: System.out
066: .println("ReaderWriterDecrypt caught exception");
067: e.printStackTrace();
068: go = false;
069: return;
070: }
071: }
072: } finally {
073: // System.out.println("ReaderWriterDecrypt exiting ...");
074: // JSS changes - implemented atomic methods to avoid JSS crashes
075: // stop();
076: rwLock.atomicStop(this );
077:
078: rwLock.notifyFinished(this );
079: rwLock = null;
080: // System.out.println("ReaderWriterDecrypt exited");
081: }
082: }
083:
084: public int FindDynamicPort(byte[] buffer, int len) {
085: return 0;
086: }
087:
088: /*
089: * Added by Rajesh T for RFE 4492648.
090: * @ returns the time in milliseconds when the last activity took place in
091: * this ReaderWriter
092: *
093: * @see com.sun.portal.netlet.eproxy.NetletGroup.
094: */
095: public long getLastActivityTime() {
096: return activityTime;
097: }
098:
099: //Methods of GWRunnable
100: public String getType() {
101: return RDR_WRITER_DECRYPT;
102: }
103:
104: //Methods of GWRunnable
105: public String getThreadName() {
106: return threadName;
107: }
108: }
|