I am trying to read a file from a samba share. For this I want to use the jcifs-ng lib. Threfore I got the jcifs-ng jar (version 2.1.10) and added it to my build path and wrote the following code:
SmbFile folder = SMBFileFactory.produceFileWithGuestCredentials(Constants.SMB_PATH_IMPORT_DIRECTORY);
if(folder == null)
return null;
try {
return folder.listFiles(new SmbFilenameFilter() {
whereas
public static SmbFile produceFileWithGuestCredentials(String path) {
try {
BaseContext bc = null;
Properties p = new Properties();
bc = new BaseContext(new PropertyConfiguration(p));
CIFSContext cc = bc.withGuestCrendentials();
SmbFile file = new SmbFile(path, cc);
return file;
}catch(MalformedURLException | CIFSException e) {
Logger.logExceptionSysOutEncapsulated(e, SMBFileFactory.class);
return null;
}
}
After testing, I recognized, that a bouncy castle lib is needed to get jcifs-ng running. So I got the bcprov jar (version 1.78.1) and added it as well to my build path. Another test now runs into the following error at the folder.listFiles call:
Exception in thread "main" java.lang.ClassCastException: class org.bouncycastle.asn1.DLApplicationSpecific cannot be cast to class org.bouncycastle.asn1.ASN1TaggedObject (org.bouncycastle.asn1.DLApplicationSpecific and org.bouncycastle.asn1.ASN1TaggedObject are in unnamed module of loader 'app')
at jcifs.spnego.NegTokenInit.parse(NegTokenInit.java:159)
at jcifs.spnego.NegTokenInit.<init>(NegTokenInit.java:66)
at jcifs.smb.NtlmPasswordAuthenticator.createContext(NtlmPasswordAuthenticator.java:243)
at jcifs.smb.SmbSessionImpl.createContext(SmbSessionImpl.java:706)
at jcifs.smb.SmbSessionImpl.sessionSetupSMB2(SmbSessionImpl.java:544)
at jcifs.smb.SmbSessionImpl.sessionSetup(SmbSessionImpl.java:491)
at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:369)
at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:347)
at jcifs.smb.SmbTreeImpl.treeConnect(SmbTreeImpl.java:611)
at jcifs.smb.SmbTreeConnection.connectTree(SmbTreeConnection.java:614)
at jcifs.smb.SmbTreeConnection.connectHost(SmbTreeConnection.java:568)
at jcifs.smb.SmbTreeConnection.connectHost(SmbTreeConnection.java:489)
at jcifs.smb.SmbTreeConnection.connect(SmbTreeConnection.java:465)
at jcifs.smb.SmbTreeConnection.connectWrapException(SmbTreeConnection.java:426)
at jcifs.smb.SmbFile.ensureTreeConnected(SmbFile.java:559)
at jcifs.smb.SmbEnumerationUtil.doEnum(SmbEnumerationUtil.java:221)
at jcifs.smb.SmbEnumerationUtil.listFiles(SmbEnumerationUtil.java:279)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1270)
at com.ffleuchten.billparser.FileHandler.loadFilesFromSMB(FileHandler.java:24)
at com.ffleuchten.billparser.BillParser.run(BillParser.java:40)
at com.ffleuchten.billparser.KickStarter.main(KickStarter.java:14)
After a little googling, I just found out, that I should use the “right” version of bprov… But what is the right version, if not the latest(1.78.1)?
Anyone know what my issue is?