[jcifs] jcifs-0.7.19 released
andrea.lanza at frameweb.it
andrea.lanza at frameweb.it
Mon Jan 26 09:45:39 GMT 2004
well....
I was not able to find MkCopy.java....... (!)
So I write down a servlet by myserlf, doing what You asked for.
this is the source
package frame.samba;
/**
*
* Classe MkCopyServlet for signing errors test
* Creata da Andrea Lanza, 2004
*
*/
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import jcifs.*;
import jcifs.smb.*;
public class MkCopyServlet extends HttpServlet {
private javax.servlet.http.HttpServletRequest req;
private javax.servlet.http.HttpServletResponse res;
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException {
req=request;
res=response;
doTutto();
} // end of method
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws IOException {
req=request;
res=response;
doTutto();
} // end of method
public void doTutto() throws IOException {
jcifs.smb.NtlmPasswordAuthentication MyAuth = null;
java.lang.String myDomain="";
java.lang.String myUserName="SmbUser";
java.lang.String myPassword="SmbPassword$1";
jcifs.smb.SmbFile sourceFile=null;
jcifs.smb.SmbFile destFile=null;
jcifs.smb.SmbFileInputStream in;
jcifs.smb.SmbFileOutputStream out;
java.lang.String strtmp="";
PrintWriter pw=null;
try {
MyAuth = new jcifs.smb.NtlmPasswordAuthentication(myDomain,
myUserName, myPassword);
strtmp = "" + req.getParameter("url");
sourceFile= new jcifs.smb.SmbFile(strtmp,MyAuth);
destFile= new jcifs.smb.SmbFile(strtmp + ".copy",MyAuth);
in = new SmbFileInputStream(sourceFile);
out = new SmbFileOutputStream(destFile);
int len;
byte[] buffer = new byte[16384];
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
} // fine while
out.close();
in.close();
destFile=null;
sourceFile=null;
res.setContentType("text/html");
pw=res.getWriter();
pw.println("end of copy");
res.flushBuffer();
} // fine try
catch (Exception e) {
System.out.println("Eccezione in MkCopyServlet.doTutto: " +
e.toString());
}
} // end of method
} // end of class
In this class I hardcoded the credentials, in the real application you
log-on via an applet and then the
credentials are stored in a cookie and the servlet-server get those back
everytime you ask for something
You invoke this servlet passing it an "url" parameter
http://localhost:8081/Samba/servlet/frame.samba.MkCopyServlet?url=smb://srvge03/boldo/robocopy.exe
this servlet reads the file pointed by the "url" and creates a new file
appendig ".copy" to the file name.
the result:
If I try it on a server Win2000 is OK
If I try it on a server W2k3 it IS NOT OK !
this is the error:
Eccezione in MkCopyServlet.doTutto: jcifs.smb.SmbException: Unverifiable
signature.
gen 26 10:40:19.696 - exception reading from socket input:
SRVGE03<20>/192.168.69.7
java.net.SocketException: socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at
jcifs.netbios.SessionServicePacket.readPacketType(SessionServicePacket.java:68)
at jcifs.netbios.SocketInputStream.read(SocketInputStream.java:73)
at jcifs.netbios.SocketInputStream.read(SocketInputStream.java:39)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at java.io.PushbackInputStream.read(PushbackInputStream.java:120)
at jcifs.smb.SmbTransport.run(SmbTransport.java:341)
at java.lang.Thread.run(Thread.java:534)
jcifs.smb.SmbException: Unverifiable signature.
at jcifs.smb.SmbTransport.send(SmbTransport.java:676)
at jcifs.smb.SmbSession.send(SmbSession.java:107)
at jcifs.smb.SmbTree.send(SmbTree.java:93)
at jcifs.smb.SmbFile.send(SmbFile.java:532)
at jcifs.smb.SmbFileInputStream.read(SmbFileInputStream.java:140)
at jcifs.smb.SmbFileInputStream.read(SmbFileInputStream.java:105)
at frame.samba.MkCopyServlet.doTutto(MkCopyServlet.java:60)
at frame.samba.MkCopyServlet.doGet(MkCopyServlet.java:24)
Eccezione in MkCopyServlet.doTutto: jcifs.smb.SmbException: Unverifiable
signature.
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:226)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.netbeans.modules.web.monitor.catalina.MonitorValve.invoke(MonitorValve.java:148)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)
If you go and see the server, you find a new file colled
robocopy.exe.copy: its size is 16384 bytes (actually the buffer size)
So the problem is really the second read, not the first write.
I tryed this on my tomcat server on my machine (the tomcat server boundled
with j2 1.4.2 + netbeans 3.51) and my op. sys. in W2k Professional.
So the problem appears not to be the NT4sp6 server
I did not try this example on the other tomcat server, acting on NT4sp6 ,
already having the problem on w2k Professional.
I am using jcifs 0.7.19.
So Mike is right, still some problems exist !
I never copyed a file from a server to the some server, actually I only
upload-download from my intranet server to some browser client
passing throw my "samba-gateway".
hope this helps,
Andrea
More information about the jcifs
mailing list