KickJava   Java API By Example, From Geeks To Geeks.

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