KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > jcifs > smb > SmbComSessionSetupAndXResponse


1 /* jcifs smb client library in Java
2  * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package com.knowgate.jcifs.smb;
20
21 import java.io.IOException JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.io.UnsupportedEncodingException JavaDoc;
24
25 import com.knowgate.debug.*;
26
27 class SmbComSessionSetupAndXResponse extends AndXServerMessageBlock {
28
29     private String JavaDoc nativeOs = "";
30     private String JavaDoc nativeLanMan = "";
31     private String JavaDoc primaryDomain = "";
32
33     boolean isLoggedInAsGuest;
34
35     SmbComSessionSetupAndXResponse( ServerMessageBlock andx ) {
36         super( andx );
37     }
38
39     int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
40         return 0;
41     }
42     int writeBytesWireFormat( byte[] dst, int dstIndex ) {
43         return 0;
44     }
45     int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
46         isLoggedInAsGuest = ( buffer[bufferIndex] & 0x01 ) == 0x01 ? true : false;
47         return 2;
48     }
49     int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
50         int start = bufferIndex;
51
52         nativeOs = readString( buffer, bufferIndex );
53         bufferIndex += stringWireLength( nativeOs, bufferIndex );
54         nativeLanMan = readString( buffer, bufferIndex );
55         bufferIndex += stringWireLength( nativeLanMan, bufferIndex );
56
57         if( useUnicode ) {
58             int len;
59
60             if((( bufferIndex - headerStart ) % 2 ) != 0 ) {
61                 bufferIndex++;
62             }
63
64             len = 0;
65             while( buffer[bufferIndex + len] != (byte)0x00 ) {
66                 len += 2;
67                 if( len > 256 ) {
68                     throw new RuntimeException JavaDoc( "zero termination not found" );
69                 }
70             }
71             try {
72                 primaryDomain = new String JavaDoc( buffer, bufferIndex, len, "UnicodeLittle" );
73             } catch( UnsupportedEncodingException JavaDoc uee ) {
74                 if( DebugFile.trace )
75                     new ErrorHandler(uee);
76             }
77             bufferIndex += len;
78         } else {
79             primaryDomain = readString( buffer, bufferIndex );
80             bufferIndex += stringWireLength( primaryDomain, bufferIndex );
81         }
82
83         return bufferIndex - start;
84     }
85     int readBytesDirectWireFormat( InputStream JavaDoc in, int byteCount,
86                 byte[] buffer, int bufferIndex ) throws IOException JavaDoc {
87         return 0;
88     }
89     public String JavaDoc toString() {
90         String JavaDoc result = new String JavaDoc( "SmbComSessionSetupAndXResponse[" +
91             super.toString() +
92             ",isLoggedInAsGuest=" + isLoggedInAsGuest +
93             ",nativeOs=" + nativeOs +
94             ",nativeLanMan=" + nativeLanMan +
95             ",primaryDomain=" + primaryDomain + "]" );
96         return result;
97     }
98 }
99
100
Popular Tags