My problem is when i try to download the file from the particular server path,it is giving me the access denied error.I have granted with access to the server path.
Using jcfs -1.3.18.jar
jcifs.smb.SmbAuthException: Access is denied.
My code is below:
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItteratorBindings = bindings.findIteratorBinding("FileDetailsVOIterator");
ViewObject voTableData = dcItteratorBindings.getViewObject();
Row rowSelected = voTableData.getCurrentRow();
NtlmPasswordAuthentication auth;
SmbFile dir;
SmbFileInputStream in;
BufferedInputStream buf;
String user ="Mydomain;shan:shan123";
String filePath = "smb://" + user + "@ad.com/DocumentManagement/Prod/";
String dbFileName = rowSelected.getAttribute("FileName").toString();
String folderName = rowSelected.getAttribute("ReferenceFolder").toString();
filePath = filePath + folderName + "/" + dbFileName;
ExternalContext econtext = facesContext.getExternalContext();
HttpServletResponse response = (HttpServletResponse)econtext.getResponse();
response.setContentType("application/force-download");
String filename = dbFileName;
try {
auth = new NtlmPasswordAuthentication(user);
dir = new SmbFile(filePath,auth);
buf = new BufferedInputStream(new SmbFileInputStream(dir)); ------->Getting error when try to access the path
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
int stream = 0;
while ((stream = buf.read()) != -1) {
outputStream.write(stream);
}
buf.close();
outputStream.flush();
outputStream.close();
;
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
showMessage(filename + " not found", "ERROR");
} catch (Exception e) {
e.printStackTrace();
}
Kindly help on the same.Thanks in advance.