01: // @(#)SessionRequest.java 1.4 "@(#)SessionRequest.java 1.4 99/09/23 Sun Microsystems"
02:
03: package com.sun.portal.netlet.eproxy;
04:
05: import java.io.DataInputStream;
06: import java.util.NoSuchElementException;
07: import java.util.Properties;
08: import java.util.StringTokenizer;
09:
10: import com.sun.portal.netlet.econnection.KeyConstants;
11: import com.sun.portal.netlet.econnection.SessionCipherMsg;
12:
13: // public class SessionRequest extends SessionCipherMsg implements Authenticatable {
14:
15: public class SessionRequest extends SessionCipherMsg {
16:
17: private String sessionID;
18:
19: private String algo;
20:
21: public SessionRequest() {
22: super ();
23: }
24:
25: public SessionRequest(byte[] sid, int sidlen) {
26: super (sid, sidlen);
27: sessionID = new String(sessId); // keep a string version for Auth
28: }
29:
30: public SessionRequest(String sid) {
31: super (sid.getBytes(), sid.getBytes().length);
32: sessionID = new String(sid);
33: }
34:
35: public int readMsg(DataInputStream in) {
36: int rc;
37:
38: rc = super .readMsg(in);
39: if (rc == 0) {
40: sessionID = new String(sessId);
41: StringTokenizer stz = new StringTokenizer(sessionID, "|");
42: try {
43: sessionID = stz.nextToken();
44: algo = stz.nextToken();
45: } catch (NoSuchElementException ne) {
46: sessionID = new String(sessId);
47: }
48: // System.out.println("Got The Cipher........"+algo);
49: } else {
50: sessionID = null;
51: rc = -1;
52: }
53: return (rc);
54: }
55:
56: public void setSessionID(String sid) {
57: sessionID = new String(sid);
58: sessId = sid.getBytes();
59: }
60:
61: public String getSessionID() {
62: // System.out.println("Returning Inside SessionRequest...."+sessionID);
63: return (sessionID);
64: }
65:
66: /*
67: * Added by Rajesh T Decodes the algorithm information from the session
68: * information @ returns default aglorithm if none is specified @ see
69: * RWGroupCrypt.encryptSessionID() @ see KeyConstants.DEFAULT_CIPHER
70: */
71:
72: public String getAlgorithm() {
73: if (algo == null)
74: return KeyConstants.DEFAULT_CIPHER;
75: return algo;
76: }
77:
78: public Properties getNetworkInfo() {
79: return null;
80: }
81:
82: public byte[] getCertificate() {
83: return null;
84: }
85:
86: public byte[] getSessionIDBytes() {
87: return (super .getSessionId());
88: }
89:
90: public void setSessionIDBytes(byte[] id, int id_len) {
91: super .setSessionId(id, id_len);
92: sessionID = new String(sessId);
93: }
94:
95: }
|