Source Code Cross Referenced for SmbComNTCreateAndX.java in  » Groupware » hipergate » com » knowgate » 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 » Groupware » hipergate » com.knowgate.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 com.knowgate.jcifs.smb;
020:
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:
024:        import com.knowgate.misc.Gadgets;
025:
026:        class SmbComNTCreateAndX extends AndXServerMessageBlock {
027:
028:            // access mask encoding
029:            static final int FILE_READ_DATA = 0x00000001; // 1
030:            static final int FILE_WRITE_DATA = 0x00000002; // 2
031:            static final int FILE_APPEND_DATA = 0x00000004; // 3
032:            static final int FILE_READ_EA = 0x00000008; // 4
033:            static final int FILE_WRITE_EA = 0x00000010; // 5
034:            static final int FILE_EXECUTE = 0x00000020; // 6
035:            static final int FILE_DELETE = 0x00000040; // 7
036:            static final int FILE_READ_ATTRIBUTES = 0x00000080; // 8
037:            static final int FILE_WRITE_ATTRIBUTES = 0x00000100; // 9
038:            static final int DELETE = 0x00010000; // 16
039:            static final int READ_CONTROL = 0x00020000; // 17
040:            static final int WRITE_DAC = 0x00040000; // 18
041:            static final int WRITE_OWNER = 0x00080000; // 19
042:            static final int SYNCHRONIZE = 0x00100000; // 20
043:            static final int GENERIC_ALL = 0x10000000; // 28
044:            static final int GENERIC_EXECUTE = 0x20000000; // 29
045:            static final int GENERIC_WRITE = 0x40000000; // 30
046:            static final int GENERIC_READ = 0x80000000; // 31
047:
048:            // share access specified in SmbFile
049:
050:            // create disposition
051:
052:            /* Creates a new file or supersedes the existing one
053:             */
054:
055:            static final int FILE_SUPERSEDE = 0x0;
056:
057:            /* Open the file or fail if it does not exist
058:             * aka OPEN_EXISTING
059:             */
060:
061:            static final int FILE_OPEN = 0x1;
062:
063:            /* Create the file or fail if it does not exist
064:             * aka CREATE_NEW
065:             */
066:
067:            static final int FILE_CREATE = 0x2;
068:
069:            /* Open the file or create it if it does not exist
070:             * aka OPEN_ALWAYS
071:             */
072:
073:            static final int FILE_OPEN_IF = 0x3;
074:
075:            /* Open the file and overwrite it's contents or fail if it does not exist
076:             * aka TRUNCATE_EXISTING
077:             */
078:
079:            static final int FILE_OVERWRITE = 0x4;
080:
081:            /* Open the file and overwrite it's contents or create it if it does not exist
082:             * aka CREATE_ALWAYS (according to the wire when calling CreateFile)
083:             */
084:
085:            static final int FILE_OVERWRITE_IF = 0x5;
086:
087:            // create options
088:            static final int FILE_WRITE_THROUGH = 0x00000002;
089:            static final int FILE_SEQUENTIAL_ONLY = 0x00000004;
090:            static final int FILE_SYNCHRONOUS_IO_ALERT = 0x00000010;
091:            static final int FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020;
092:
093:            // security flags
094:            static final int SECURITY_CONTEXT_TRACKING = 0x01;
095:            static final int SECURITY_EFFECTIVE_ONLY = 0x02;
096:
097:            private int flags, rootDirectoryFid, desiredAccess,
098:                    extFileAttributes, shareAccess, createDisposition,
099:                    createOptions, impersonationLevel;
100:            private long allocationSize;
101:            private byte securityFlags;
102:
103:            SmbComNTCreateAndX(String name, int flags, int shareAccess,
104:                    int extFileAttributes, int createOptions,
105:                    ServerMessageBlock andx) {
106:                super (andx);
107:                this .path = name;
108:                command = SMB_COM_NT_CREATE_ANDX;
109:
110:                // desiredAccess
111:                desiredAccess = (flags >>> 16) & 0xFFFF;
112:                desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES;
113:
114:                // extFileAttributes
115:                this .extFileAttributes = extFileAttributes;
116:
117:                // shareAccess
118:                this .shareAccess = shareAccess;
119:
120:                // createDisposition
121:                if ((flags & SmbFile.O_TRUNC) == SmbFile.O_TRUNC) {
122:                    // truncate the file
123:                    if ((flags & SmbFile.O_CREAT) == SmbFile.O_CREAT) {
124:                        // create it if necessary
125:                        createDisposition = FILE_OVERWRITE_IF;
126:                    } else {
127:                        createDisposition = FILE_OVERWRITE;
128:                    }
129:                } else {
130:                    // don't truncate the file
131:                    if ((flags & SmbFile.O_CREAT) == SmbFile.O_CREAT) {
132:                        // create it if necessary
133:                        if ((flags & SmbFile.O_EXCL) == SmbFile.O_EXCL) {
134:                            // fail if already exists
135:                            createDisposition = FILE_CREATE;
136:                        } else {
137:                            createDisposition = FILE_OPEN_IF;
138:                        }
139:                    } else {
140:                        createDisposition = FILE_OPEN;
141:                    }
142:                }
143:
144:                if ((createOptions & 0x01) == 0) {
145:                    this .createOptions = createOptions | 0x0040;
146:                } else {
147:                    this .createOptions = createOptions;
148:                }
149:                impersonationLevel = 0x02; // As seen on NT :~)
150:                securityFlags = (byte) 0x03; // SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY
151:            }
152:
153:            int writeParameterWordsWireFormat(byte[] dst, int dstIndex) {
154:                int start = dstIndex;
155:
156:                dst[dstIndex++] = (byte) 0x00;
157:                // name length without counting null termination
158:                writeInt2((useUnicode ? path.length() * 2 : path.length()),
159:                        dst, dstIndex);
160:                dstIndex += 2;
161:                writeInt4(flags, dst, dstIndex);
162:                dstIndex += 4;
163:                writeInt4(rootDirectoryFid, dst, dstIndex);
164:                dstIndex += 4;
165:                writeInt4(desiredAccess, dst, dstIndex);
166:                dstIndex += 4;
167:                writeInt8(allocationSize, dst, dstIndex);
168:                dstIndex += 8;
169:                writeInt4(extFileAttributes, dst, dstIndex);
170:                dstIndex += 4;
171:                writeInt4(shareAccess, dst, dstIndex);
172:                dstIndex += 4;
173:                writeInt4(createDisposition, dst, dstIndex);
174:                dstIndex += 4;
175:                writeInt4(createOptions, dst, dstIndex);
176:                dstIndex += 4;
177:                writeInt4(impersonationLevel, dst, dstIndex);
178:                dstIndex += 4;
179:                dst[dstIndex++] = securityFlags;
180:
181:                return dstIndex - start;
182:            }
183:
184:            int writeBytesWireFormat(byte[] dst, int dstIndex) {
185:                return writeString(path, dst, dstIndex);
186:            }
187:
188:            int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) {
189:                return 0;
190:            }
191:
192:            int readBytesWireFormat(byte[] buffer, int bufferIndex) {
193:                return 0;
194:            }
195:
196:            int readBytesDirectWireFormat(InputStream in, int byteCount,
197:                    byte[] buffer, int bufferIndex) throws IOException {
198:                return 0;
199:            }
200:
201:            public String toString() {
202:                return new String("SmbComNTCreateAndX[" + super .toString()
203:                        + ",flags=0x" + Gadgets.toHexString(flags, 2)
204:                        + ",rootDirectoryFid=" + rootDirectoryFid
205:                        + ",desiredAccess=0x"
206:                        + Gadgets.toHexString(desiredAccess, 4)
207:                        + ",allocationSize=" + allocationSize
208:                        + ",extFileAttributes=0x"
209:                        + Gadgets.toHexString(extFileAttributes, 4)
210:                        + ",shareAccess=0x"
211:                        + Gadgets.toHexString(shareAccess, 4)
212:                        + ",createDisposition=0x"
213:                        + Gadgets.toHexString(createDisposition, 4)
214:                        + ",createOptions=0x"
215:                        + Gadgets.toHexString(createOptions, 8)
216:                        + ",impersonationLevel=0x"
217:                        + Gadgets.toHexString(impersonationLevel, 4)
218:                        + ",securityFlags=0x"
219:                        + Gadgets.toHexString(securityFlags, 2) + ",name="
220:                        + path + "]");
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.