In this POC ,I tried creating folder inside a share folder with anonymous access. I am able to create with all SMB 2 dialects but when I use any of SMB 3 dialect, I am getting null pointer exception.
Here is the POC to connect to share using smbj.
package org.jitterbit.connector.smb.executor;
import com.hierynomus.smbj.auth.*;
import com.hierynomus.smbj.share.*;
public class SMBAnonymousConnect {
public static void main(String[] args) {
com.hierynomus.smbj.SmbConfig config = com.hierynomus.smbj.SmbConfig.builder()
.withMultiProtocolNegotiate(true)
.withDialects(com.hierynomus.mssmb2.SMB2Dialect.SMB_3_0)
.build();
com.hierynomus.smbj.connection.Connection connection = null;
com.hierynomus.smbj.SMBClient client = new com.hierynomus.smbj.SMBClient(config);
try
{
System.out.println("connecting...");
connection = client.connect("WSAMZN-M7UV272O");
System.out.println("connected");
AuthenticationContext ac = AuthenticationContext.anonymous();
com.hierynomus.smbj.session.Session session = connection.authenticate(ac);
System.out.printf("Authenticated");
boolean isConnected = connection.isConnected();
Boolean b = new Boolean(isConnected);
System.out.printf(b.toString());
try (com.hierynomus.smbj.share.DiskShare share =(com.hierynomus.smbj.share.DiskShare) session.connectShare("sample_connector")) {
share.mkdir("new_folder3");
} catch (java.io.IOException e) {
throw new RuntimeException(e);
}
} catch (Exception e) {
System.out.println("Message : " + e.getMessage());
System.out.printf(e.getLocalizedMessage());
System.out.println("Cause :" + e.getCause());
}
}
}
The response I got with SMB 3 dialect and it is working fine with all SMB 2 dialect.
"C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\bin\java.exe" "-javaagent:D:\Users\chetna.pal\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2023.3\lib\idea_rt.jar=57013:D:\Users\chetna.pal\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2023.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\charsets.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\access-bridge-64.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\cldrdata.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\dnsns.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\jaccess.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\jfxrt.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\localedata.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\nashorn.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\sunec.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\sunjce_provider.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\sunmscapi.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\sunpkcs11.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\ext\zipfs.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\jce.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\jfr.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\jfxswt.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\jsse.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\management-agent.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\resources.jar;C:\Program Files\OpenJDK\jdk-8.0.362.09-hotspot\jre\lib\rt.jar;D:\Jitterbit\Connector_Repo\Ms-dynamics(Update)\connectors\smb-connector\target\classes;D:\Jitterbit\Connector_Repo\Ms-dynamics(Update)\connectors\connectors-common\lib\jitterbit-connector-sdk-1.0.0-SNAPSHOT.jar;D:\Jitterbit\Connector_Repo\Ms-dynamics(Update)\connectors\connectors-common\target\classes;D:\Users\chetna.pal\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.10.4\jackson-core-2.10.4.jar;D:\Users\chetna.pal\.m2\repository\org\apache\httpcomponents\client5\httpclient5\5.1.3\httpclient5-5.1.3.jar;D:\Users\chetna.pal\.m2\repository\org\apache\httpcomponents\core5\httpcore5\5.1.3\httpcore5-5.1.3.jar;D:\Users\chetna.pal\.m2\repository\org\apache\httpcomponents\core5\httpcore5-h2\5.1.3\httpcore5-h2-5.1.3.jar;D:\Users\chetna.pal\.m2\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;D:\Users\chetna.pal\.m2\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;D:\Users\chetna.pal\.m2\repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;D:\Users\chetna.pal\.m2\repository\org\apache\logging\log4j\log4j-api\2.19.0\log4j-api-2.19.0.jar;D:\Users\chetna.pal\.m2\repository\org\slf4j\log4j-over-slf4j\2.0.6\log4j-over-slf4j-2.0.6.jar;D:\Users\chetna.pal\.m2\repository\org\slf4j\slf4j-api\2.0.6\slf4j-api-2.0.6.jar;D:\Users\chetna.pal\.m2\repository\org\slf4j\slf4j-simple\2.0.6\slf4j-simple-2.0.6.jar;D:\Users\chetna.pal\.m2\repository\org\codelibs\jcifs\2.1.37\jcifs-2.1.37.jar;D:\Users\chetna.pal\.m2\repository\org\bouncycastle\bcprov-jdk18on\1.76\bcprov-jdk18on-1.76.jar;D:\Users\chetna.pal\.m2\repository\jcifs\jcifs\1.3.17\jcifs-1.3.17.jar;D:\Users\chetna.pal\.m2\repository\javax\servlet\servlet-api\2.4\servlet-api-2.4.jar;D:\Users\chetna.pal\.m2\repository\com\hierynomus\smbj\0.13.0\smbj-0.13.0.jar;D:\Users\chetna.pal\.m2\repository\net\engio\mbassador\1.3.0\mbassador-1.3.0.jar;D:\Users\chetna.pal\.m2\repository\com\hierynomus\asn-one\0.6.0\asn-one-0.6.0.jar;D:\Users\chetna.pal\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\Users\chetna.pal\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;D:\Users\chetna.pal\.m2\repository\org\apache\logging\log4j\log4j-core\2.19.0\log4j-core-2.19.0.jar;D:\Users\chetna.pal\.m2\repository\org\json\json\20210307\json-20210307.jar;D:\Users\chetna.pal\.m2\repository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;D:\Users\chetna.pal\.m2\repository\javax\ws\rs\javax.ws.rs-api\2.1.1\javax.ws.rs-api-2.1.1.jar;D:\Users\chetna.pal\.m2\repository\com\sun\jersey\jersey-bundle\1.19.1\jersey-bundle-1.19.1.jar;D:\Users\chetna.pal\.m2\repository\org\glassfish\jersey\jax-rs-ri\2.0-rc1\jax-rs-ri-2.0-rc1.jar;D:\Users\chetna.pal\.m2\repository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;D:\Users\chetna.pal\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.4\jackson-annotations-2.10.4.jar;D:\Users\chetna.pal\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.10.4\jackson-databind-2.10.4.jar;D:\Users\chetna.pal\.m2\repository\com\google\guava\guava\28.2-jre\guava-28.2-jre.jar;D:\Users\chetna.pal\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;D:\Users\chetna.pal\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;D:\Users\chetna.pal\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;D:\Users\chetna.pal\.m2\repository\org\checkerframework\checker-qual\2.10.0\checker-qual-2.10.0.jar;D:\Users\chetna.pal\.m2\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;D:\Users\chetna.pal\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;D:\Users\chetna.pal\.m2\repository\org\apache\kafka\kafka-clients\3.2.3\kafka-clients-3.2.3.jar;D:\Users\chetna.pal\.m2\repository\com\github\luben\zstd-jni\1.5.2-1\zstd-jni-1.5.2-1.jar;D:\Users\chetna.pal\.m2\repository\org\lz4\lz4-java\1.8.0\lz4-java-1.8.0.jar;D:\Users\chetna.pal\.m2\repository\org\xerial\snappy\snappy-java\1.1.8.4\snappy-java-1.1.8.4.jar" org.jitterbit.connector.smb.executor.SMBAnonymousConnect
connecting...
[main] INFO com.hierynomus.smbj.connection.PacketEncryptor - Initialized PacketEncryptor with Cipher << AES_128_CCM >>
[main] INFO com.hierynomus.smbj.connection.Connection - Successfully connected to: WSAMZN-M7UV272O
connected
Message : null
Exception in thread "main" java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
at java.util.regex.Matcher.reset(Matcher.java:309)
at java.util.regex.Matcher.<init>(Matcher.java:229)
at java.util.regex.Pattern.matcher(Pattern.java:1093)
at java.util.Formatter.parse(Formatter.java:2547)
at java.util.Formatter.format(Formatter.java:2501)
at java.io.PrintStream.format(PrintStream.java:970)
at java.io.PrintStream.printf(PrintStream.java:871)
at org.jitterbit.connector.smb.executor.SMBAnonymousConnect.main(SMBAnonymousConnect.java:34)
Process finished with exit code 1