Source Code Cross Referenced for SmbComTreeConnectAndX.java in  » Net » jCIFS » jcifs » smb » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » jCIFS » jcifs.smb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* jcifs smb client library in Java
002:         * Copyright (C) 2000  "Michael B. Allen" <jcifs at samba dot org>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package jcifs.smb;
020:
021:        import jcifs.Config;
022:        import java.io.IOException;
023:        import java.io.InputStream;
024:        import java.io.UnsupportedEncodingException;
025:        import jcifs.util.Hexdump;
026:
027:        class SmbComTreeConnectAndX extends AndXServerMessageBlock {
028:
029:            private static final boolean DISABLE_PLAIN_TEXT_PASSWORDS = Config
030:                    .getBoolean("jcifs.smb.client.disablePlainTextPasswords",
031:                            true);
032:
033:            private SmbSession session;
034:            private boolean disconnectTid = false;
035:            private String path, service;
036:            private byte[] password;
037:            private int passwordLength;
038:
039:            /* batchLimits indecies
040:             *
041:             * 0 = SMB_COM_CHECK_DIRECTORY
042:             * 2 = SMB_COM_CREATE_DIRECTORY
043:             * 3 = SMB_COM_DELETE
044:             * 4 = SMB_COM_DELETE_DIRECTORY
045:             * 5 = SMB_COM_OPEN_ANDX
046:             * 6 = SMB_COM_RENAME
047:             * 7 = SMB_COM_TRANSACTION
048:             * 8 = SMB_COM_QUERY_INFORMATION
049:             */
050:
051:            /* All batch limits are single batch only until further notice
052:             */
053:
054:            private static byte[] batchLimits = { 1, 1, 1, 1, 1, 1, 1, 1, 0 };
055:
056:            static {
057:                String s;
058:
059:                if ((s = Config
060:                        .getProperty("jcifs.smb.client.TreeConnectAndX.CheckDirectory")) != null) {
061:                    batchLimits[0] = Byte.parseByte(s);
062:                }
063:                if ((s = Config
064:                        .getProperty("jcifs.smb.client.TreeConnectAndX.CreateDirectory")) != null) {
065:                    batchLimits[2] = Byte.parseByte(s);
066:                }
067:                if ((s = Config
068:                        .getProperty("jcifs.smb.client.TreeConnectAndX.Delete")) != null) {
069:                    batchLimits[3] = Byte.parseByte(s);
070:                }
071:                if ((s = Config
072:                        .getProperty("jcifs.smb.client.TreeConnectAndX.DeleteDirectory")) != null) {
073:                    batchLimits[4] = Byte.parseByte(s);
074:                }
075:                if ((s = Config
076:                        .getProperty("jcifs.smb.client.TreeConnectAndX.OpenAndX")) != null) {
077:                    batchLimits[5] = Byte.parseByte(s);
078:                }
079:                if ((s = Config
080:                        .getProperty("jcifs.smb.client.TreeConnectAndX.Rename")) != null) {
081:                    batchLimits[6] = Byte.parseByte(s);
082:                }
083:                if ((s = Config
084:                        .getProperty("jcifs.smb.client.TreeConnectAndX.Transaction")) != null) {
085:                    batchLimits[7] = Byte.parseByte(s);
086:                }
087:                if ((s = Config
088:                        .getProperty("jcifs.smb.client.TreeConnectAndX.QueryInformation")) != null) {
089:                    batchLimits[8] = Byte.parseByte(s);
090:                }
091:            }
092:
093:            SmbComTreeConnectAndX(SmbSession session, String path,
094:                    String service, ServerMessageBlock andx) {
095:                super (andx);
096:                this .session = session;
097:                this .path = path;
098:                this .service = service;
099:                command = SMB_COM_TREE_CONNECT_ANDX;
100:            }
101:
102:            int getBatchLimit(byte command) {
103:                int c = (int) (command & 0xFF);
104:                // why isn't this just return batchLimits[c]?
105:                switch (c) {
106:                case SMB_COM_CHECK_DIRECTORY:
107:                    return batchLimits[0];
108:                case SMB_COM_CREATE_DIRECTORY:
109:                    return batchLimits[2];
110:                case SMB_COM_DELETE:
111:                    return batchLimits[3];
112:                case SMB_COM_DELETE_DIRECTORY:
113:                    return batchLimits[4];
114:                case SMB_COM_OPEN_ANDX:
115:                    return batchLimits[5];
116:                case SMB_COM_RENAME:
117:                    return batchLimits[6];
118:                case SMB_COM_TRANSACTION:
119:                    return batchLimits[7];
120:                case SMB_COM_QUERY_INFORMATION:
121:                    return batchLimits[8];
122:                }
123:                return 0;
124:            }
125:
126:            int writeParameterWordsWireFormat(byte[] dst, int dstIndex) {
127:
128:                if (session.transport.server.security == SECURITY_SHARE
129:                        && (session.auth.hashesExternal || session.auth.password
130:                                .length() > 0)) {
131:
132:                    if (session.transport.server.encryptedPasswords) {
133:                        // encrypted
134:                        password = session.auth
135:                                .getAnsiHash(session.transport.server.encryptionKey);
136:                        passwordLength = password.length;
137:                    } else if (DISABLE_PLAIN_TEXT_PASSWORDS) {
138:                        throw new RuntimeException(
139:                                "Plain text passwords are disabled");
140:                    } else {
141:                        // plain text
142:                        password = new byte[(session.auth.password.length() + 1) * 2];
143:                        passwordLength = writeString(session.auth.password,
144:                                password, 0);
145:                    }
146:                } else {
147:                    // no password in tree connect
148:                    passwordLength = 1;
149:                }
150:
151:                dst[dstIndex++] = disconnectTid ? (byte) 0x01 : (byte) 0x00;
152:                dst[dstIndex++] = (byte) 0x00;
153:                writeInt2(passwordLength, dst, dstIndex);
154:                return 4;
155:            }
156:
157:            int writeBytesWireFormat(byte[] dst, int dstIndex) {
158:                int start = dstIndex;
159:
160:                if (session.transport.server.security == SECURITY_SHARE
161:                        && (session.auth.hashesExternal || session.auth.password
162:                                .length() > 0)) {
163:                    System
164:                            .arraycopy(password, 0, dst, dstIndex,
165:                                    passwordLength);
166:                    dstIndex += passwordLength;
167:                } else {
168:                    // no password in tree connect
169:                    dst[dstIndex++] = (byte) 0x00;
170:                }
171:                dstIndex += writeString(path, dst, dstIndex);
172:                try {
173:                    System.arraycopy(service.getBytes("ASCII"), 0, dst,
174:                            dstIndex, service.length());
175:                } catch (UnsupportedEncodingException uee) {
176:                    return 0;
177:                }
178:                dstIndex += service.length();
179:                dst[dstIndex++] = (byte) '\0';
180:
181:                return dstIndex - start;
182:            }
183:
184:            int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) {
185:                return 0;
186:            }
187:
188:            int readBytesWireFormat(byte[] buffer, int bufferIndex) {
189:                return 0;
190:            }
191:
192:            int readBytesDirectWireFormat(InputStream in, int byteCount,
193:                    byte[] buffer, int bufferIndex) throws IOException {
194:                return 0;
195:            }
196:
197:            public String toString() {
198:                String result = new String("SmbComTreeConnectAndX["
199:                        + super .toString() + ",disconnectTid=" + disconnectTid
200:                        + ",passwordLength=" + passwordLength + ",password="
201:                        + Hexdump.toHexString(password, passwordLength, 0)
202:                        + ",path=" + path + ",service=" + service + "]");
203:                return result;
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.