|
@@ -1,6 +1,7 @@
|
|
|
package de.tudarmstadt.informatik.hostage.protocol.cifs;
|
|
|
|
|
|
//import org.alfresco.config.ConfigElement;
|
|
|
+import org.alfresco.jlan.server.NetworkServer;
|
|
|
import org.alfresco.jlan.server.SrvSession;
|
|
|
import org.alfresco.jlan.server.core.DeviceContext;
|
|
|
import org.alfresco.jlan.server.core.DeviceContextException;
|
|
@@ -16,6 +17,7 @@ import org.alfresco.jlan.server.filesys.FileSystem;
|
|
|
import org.alfresco.jlan.server.filesys.NetworkFile;
|
|
|
import org.alfresco.jlan.server.filesys.SearchContext;
|
|
|
import org.alfresco.jlan.server.filesys.TreeConnection;
|
|
|
+import org.alfresco.jlan.smb.server.disk.JavaNetworkFile;
|
|
|
import org.springframework.extensions.config.ConfigElement;
|
|
|
|
|
|
import java.io.File;
|
|
@@ -72,6 +74,7 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
|
|
|
|
|
|
@Override
|
|
|
public void closeFile(SrvSession srvSession, TreeConnection treeConnection, NetworkFile networkFile) throws IOException {
|
|
|
+ networkFile.closeFile();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -95,20 +98,19 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
|
|
|
|
|
|
@Override
|
|
|
public int fileExists(SrvSession srvSession, TreeConnection treeConnection, String s) {
|
|
|
+
|
|
|
DeviceContext ctx = treeConnection.getContext();
|
|
|
String filename = FileName.buildPath(ctx.getDeviceName(), s, null, File.separatorChar);
|
|
|
|
|
|
File chkFile = new File(filename);
|
|
|
- if(chkFile.exists()){
|
|
|
+
|
|
|
if(chkFile.isFile()){
|
|
|
return FileStatus.FileExists;
|
|
|
}
|
|
|
else {
|
|
|
return FileStatus.DirectoryExists;
|
|
|
}
|
|
|
- }
|
|
|
- return FileStatus.NotExist;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void flushFile(SrvSession srvSession, TreeConnection treeConnection, NetworkFile networkFile) throws IOException {
|
|
@@ -116,12 +118,21 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public FileInfo getFileInformation(SrvSession srvSession, TreeConnection treeConnection, String s) throws IOException {
|
|
|
- FileInfo finfo = new FileInfo(s, 12, FileAttribute.ReadOnly);
|
|
|
+ public FileInfo getFileInformation(SrvSession srvSession, TreeConnection treeConnection, String name) throws IOException {
|
|
|
+ //String path = FileName.buildPath(treeConnection.getContext().getDeviceName(), "/", "jlan", java.io.File.separatorChar);
|
|
|
+
|
|
|
+ //File file = new File(treeConnection.getContext().getDeviceName(), "jlan");
|
|
|
+
|
|
|
+ //int fattr = FileAttribute.ReadOnly;
|
|
|
+
|
|
|
+ String path = FileName.buildPath(treeConnection.getContext().getDeviceName(), name, null, java.io.File.separatorChar);
|
|
|
+ System.out.println("PATH::::"+path);
|
|
|
+ int fattr = FileAttribute.Directory;
|
|
|
+
|
|
|
+ FileInfo finfo = new FileInfo(path, 0, fattr);
|
|
|
long fdate = System.currentTimeMillis();
|
|
|
finfo.setModifyDateTime(fdate);
|
|
|
- finfo.setAllocationSize((12 + 512L) & 0xFFFFFFFFFFFFFE00L);
|
|
|
- finfo.setFileId(s.hashCode());
|
|
|
+ finfo.setFileId(path.hashCode());
|
|
|
|
|
|
finfo.setCreationDateTime(fdate - 1000);
|
|
|
finfo.setChangeDateTime(fdate);
|
|
@@ -135,13 +146,25 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
|
|
|
|
|
|
@Override
|
|
|
public NetworkFile openFile(SrvSession srvSession, TreeConnection treeConnection, FileOpenParams fileOpenParams) throws IOException {
|
|
|
- System.out.println(srvSession + " - " + treeConnection + " - " + fileOpenParams);
|
|
|
- NetworkFile netFile = new PseudoNetworkFile("Test");
|
|
|
+ System.out.println("openFile method::::"+srvSession + " - " + treeConnection + " - " + fileOpenParams);
|
|
|
+ String fname = FileName.buildPath(treeConnection.getContext().getDeviceName(), fileOpenParams.getPath(), null, java.io.File.separatorChar);
|
|
|
+ File file = new File(fname);
|
|
|
+ File subFile = new File("/jlan/test.txt");
|
|
|
+
|
|
|
+ NetworkFile netFile = new JavaNetworkFile(file,fname);
|
|
|
+ netFile.setGrantedAccess(fileOpenParams.getAttributes());
|
|
|
+ netFile.setAttributes(FileAttribute.Directory);
|
|
|
+
|
|
|
+ NetworkFile subNetFile = new JavaNetworkFile(subFile, "/jlan/test.txt");
|
|
|
+ subNetFile.setGrantedAccess(NetworkFile.READONLY);
|
|
|
+ subNetFile.setAttributes(FileAttribute.ReadOnly);
|
|
|
+
|
|
|
return netFile;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int readFile(SrvSession srvSession, TreeConnection treeConnection, NetworkFile networkFile, byte[] bytes, int i, int i2, long l) throws IOException {
|
|
|
+ System.out.println("readFile method::::"+srvSession + " - " + treeConnection + " - "+networkFile);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -152,6 +175,7 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
|
|
|
|
|
|
@Override
|
|
|
public long seekFile(SrvSession srvSession, TreeConnection treeConnection, NetworkFile networkFile, long l, int i) throws IOException {
|
|
|
+ System.out.println("seekFile method::::"+srvSession + " - " + treeConnection + " - "+networkFile);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -186,7 +210,8 @@ public class PseudoCIFSDiskDriver implements DiskInterface {
|
|
|
|
|
|
@Override
|
|
|
public void treeOpened(SrvSession srvSession, TreeConnection treeConnection) {
|
|
|
-
|
|
|
+ System.out.println("treeOpened method::::"+srvSession + " - " + treeConnection);
|
|
|
+ System.out.println("treeOpened method::::"+treeConnection.getContext().getDeviceName());
|
|
|
}
|
|
|
|
|
|
@Override
|