I'm testing @DonManfred 's SMB client (https://www.b4x.com/android/forum/threads/jcifs-ng-smb-client-smb2.104561/), both the B4A and B4J versions. B4A works fine, and so does B4J on Linux. On Windows 10 and 11 however, I'm getting the below error and have no clue what to do; the library used is jcifs-ng version 0.33. The system containing the share is a QNAP NAS.
I tried to attach the small test project but the forum seemed to think the zip file (3.3K) was empty, so I've added the code to the post as well.
Any pointers would be greatly appreciated!
I tried to attach the small test project but the forum seemed to think the zip file (3.3K) was empty, so I've added the code to the post as well.
Any pointers would be greatly appreciated!
SMBClient_Resource(true,OK,smb://192.168.1.2/testshare,smb://192.168.1.2/testshare)
Check 1
Check 2
Check 3
Check 4
jcifs.smb.SmbException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MD4, provider: BC, class: org.bouncycastle.jcajce.provider.digest.MD4$Digest)
at b4j/jcifs.smb.NtlmContext.makeAuthenticate(Unknown Source)
at b4j/jcifs.smb.NtlmContext.initSecContext(Unknown Source)
at b4j/jcifs.smb.SpnegoContext.negotitate(Unknown Source)
at b4j/jcifs.smb.SpnegoContext.initSecContext(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.createToken(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.sessionSetupSMB2(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.sessionSetup(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.send(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.send(Unknown Source)
at b4j/jcifs.smb.SmbTreeImpl.treeConnect(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectTree(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectHost(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectHost(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connect(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectWrapException(Unknown Source)
at b4j/jcifs.smb.SmbFile.ensureTreeConnected(Unknown Source)
at b4j/jcifs.smb.SmbEnumerationUtil.doEnum(Unknown Source)
at b4j/jcifs.smb.SmbEnumerationUtil.listFiles(Unknown Source)
at b4j/jcifs.smb.SmbFile.listFiles(Unknown Source)
at b4j/de.donmanfred.SMBClientwrapper$11.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: jcifs.CIFSUnsupportedCryptoException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MD4, provider: BC, class: org.bouncycastle.jcajce.provider.digest.MD4$Digest)
at b4j/jcifs.util.Crypto.getMD4(Unknown Source)
at b4j/jcifs.smb.NtlmUtil.nTOWFv2(Unknown Source)
at b4j/jcifs.ntlmssp.Type3Message.<init>(Unknown Source)
... 25 more
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MD4, provider: BC, class: org.bouncycastle.jcajce.provider.digest.MD4$Digest)
at java.base/java.security.Provider$Service.newInstance(Unknown Source)
at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.base/java.security.Security.getImpl(Unknown Source)
at java.base/java.security.MessageDigest.getInstance(Unknown Source)
... 28 more
Caused by: java.lang.IllegalAccessException: class java.security.Provider (in module java.base) cannot access class org.bouncycastle.jcajce.provider.digest.MD4$Digest (in module b4j) because module b4j does not export org.bouncycastle.jcajce.provider.digest to module java.base
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Unknown Source)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.base/java.security.Provider.newInstanceUtil(Unknown Source)
... 33 more
Check 1
Check 2
Check 3
Check 4
jcifs.smb.SmbException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MD4, provider: BC, class: org.bouncycastle.jcajce.provider.digest.MD4$Digest)
at b4j/jcifs.smb.NtlmContext.makeAuthenticate(Unknown Source)
at b4j/jcifs.smb.NtlmContext.initSecContext(Unknown Source)
at b4j/jcifs.smb.SpnegoContext.negotitate(Unknown Source)
at b4j/jcifs.smb.SpnegoContext.initSecContext(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.createToken(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.sessionSetupSMB2(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.sessionSetup(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.send(Unknown Source)
at b4j/jcifs.smb.SmbSessionImpl.send(Unknown Source)
at b4j/jcifs.smb.SmbTreeImpl.treeConnect(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectTree(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectHost(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectHost(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connect(Unknown Source)
at b4j/jcifs.smb.SmbTreeConnection.connectWrapException(Unknown Source)
at b4j/jcifs.smb.SmbFile.ensureTreeConnected(Unknown Source)
at b4j/jcifs.smb.SmbEnumerationUtil.doEnum(Unknown Source)
at b4j/jcifs.smb.SmbEnumerationUtil.listFiles(Unknown Source)
at b4j/jcifs.smb.SmbFile.listFiles(Unknown Source)
at b4j/de.donmanfred.SMBClientwrapper$11.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: jcifs.CIFSUnsupportedCryptoException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MD4, provider: BC, class: org.bouncycastle.jcajce.provider.digest.MD4$Digest)
at b4j/jcifs.util.Crypto.getMD4(Unknown Source)
at b4j/jcifs.smb.NtlmUtil.nTOWFv2(Unknown Source)
at b4j/jcifs.ntlmssp.Type3Message.<init>(Unknown Source)
... 25 more
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: MD4, provider: BC, class: org.bouncycastle.jcajce.provider.digest.MD4$Digest)
at java.base/java.security.Provider$Service.newInstance(Unknown Source)
at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.base/java.security.Security.getImpl(Unknown Source)
at java.base/java.security.MessageDigest.getInstance(Unknown Source)
... 28 more
Caused by: java.lang.IllegalAccessException: class java.security.Provider (in module java.base) cannot access class org.bouncycastle.jcajce.provider.digest.MD4$Digest (in module b4j) because module b4j does not export org.bouncycastle.jcajce.provider.digest to module java.base
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Unknown Source)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.base/java.security.Provider.newInstanceUtil(Unknown Source)
... 33 more
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: slf4j-api-1.7.25.jar
#AdditionalJar: bctls-jdk15on-1.58.0.0.jar
#AdditionalJar: bcprov-jdk15on-1.59.jar
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Public smbClient As SMBClient
Public glRes As SMBResource
Type SMBCred(Domain As String, Username As String, Password As String, Share As String)
Private edt_Domain As TextField
Private edt_Username As TextField
Private edt_Password As TextField
Private edt_Share As TextField
Private btn_Init As Button
Dim credentials As SMBCred
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
credentials.Initialize
credentials.Domain = "192.168..."
credentials.Username = ""
credentials.Password = ""
credentials.Share = "smb://192.168.../SHARENAME"
edt_Domain.Text = credentials.Domain
edt_Username.Text = credentials.Username
edt_Password.Text = credentials.Password
edt_Share.Text = credentials.Share
End Sub
'Sub CheckEditfields
'
' btn_Init.Enabled = False
' If edt_Domain.Text.Trim.Length > 0 And edt_Username.Text.Trim.Length > 0 And edt_Password.Text.Trim.Length > 0 And edt_Share.Text.Trim.Length > 0 Then
' btn_Init.Enabled = True
' End If
'
'End Sub
Sub btn_Init_Click
Dim credentials As SMBCred
credentials.Initialize
credentials.Domain = edt_Domain.Text.Trim ' E.g.: 192.168.1.1
credentials.Username = edt_Username.Text.Trim ' E.g.: myuser
credentials.Password = edt_Password.Text.Trim ' E.g.: mypassword
credentials.Share = edt_Share.Text.Trim ' E.g.: smb://192.168.1.1/sharename/
SMBInit(credentials)
End Sub
Sub SMBInit(cred As SMBCred)
smbClient.Initialize("SMBClient", cred.Domain, cred.Username, cred.Password, cred.Share)
Wait For SMBClient_Resource(success As Boolean, smbobjres As Object, smbobj As Object, info As String)
Log($"SMBClient_Resource(${success},${info},${smbobjres},${smbobj})"$)
If (smbobjres = Null) Or (smbobj = Null) Or (info <> "OK") Then Return
Try
Log("Check 1")
Dim smbResource As SMBResource = smbobjres
Log("Check 2")
glRes = smbResource
Log("Check 3")
smbClient.listFiles(smbResource)
Log("Check 4") ' <----- This point is reached, but then the error occurs (it goes straight to stdout/stderr, does not throw an exception)
Catch
Log("SMBInit: " & LastException)
End Try
End Sub
Sub SMBClient_ListFiles(filelist As List)
Log("SMBClient_ListFiles") ' <----- This doesn't appear
Log($"SMBClient_ListFiles(${filelist})"$)
End Sub