01: package com.sun.portal.netlet.client.jnlp.connect;
02:
03: import java.io.IOException;
04: import com.sun.portal.log.common.PortalLogger;
05: import java.io.OutputStream;
06:
07: public class PSessionMsg {
08: protected byte[] id = new byte[Constants.PMSG_ID_SIZE];
09:
10: public PSessionMsg() {
11: }
12:
13: public PSessionMsg(byte[] i) {
14: System.arraycopy(i, 0, id, 0, i.length);
15: }
16:
17: public int writeMsg(OutputStream out, String host, int port) {
18: int rc = 0;
19:
20: // Message format
21: // PP1.0CONNECT openssl.org:443 \r\n\r\n
22: String pMsg = Constants.PMSG_ID + "CONNECT " + host + ":"
23: + port + "\r\n\r\n";
24: //String pMsg = "CONNECT " + host + ":" + port + "\r\n\r\n";
25:
26: System.out.println("End to end message " + pMsg);
27: try {
28: out.write(pMsg.getBytes(), 0, pMsg.length());
29: out.flush();
30: } catch (IOException e) {
31: System.out
32: .println("PSessionMsg caught exception when writing:");
33: e.printStackTrace();
34: rc = -1;
35: }
36: return (rc);
37: }
38:
39: public byte[] getPSessionId() {
40: if (id != null) {
41: byte[] i = new byte[id.length];
42: System.arraycopy(id, 0, i, 0, id.length);
43: return (i);
44: } else {
45: return (null);
46: }
47: }
48: }
|