From a1e1d79652f6ed174f6233a346dc388090ff0465 Mon Sep 17 00:00:00 2001 From: Jeroen van Erp Date: Tue, 26 Sep 2023 10:37:25 +0200 Subject: [PATCH] Set sessionKey whenever we have it from authentication (Fixes #792) This should fix the NPE that occurs when authenticating with guest or anonymous credentials and the server treating it as a regular account --- .../java/com/hierynomus/smbj/connection/SMBSessionBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hierynomus/smbj/connection/SMBSessionBuilder.java b/src/main/java/com/hierynomus/smbj/connection/SMBSessionBuilder.java index 65b6eb74..54f47484 100644 --- a/src/main/java/com/hierynomus/smbj/connection/SMBSessionBuilder.java +++ b/src/main/java/com/hierynomus/smbj/connection/SMBSessionBuilder.java @@ -163,7 +163,7 @@ private Session setupSession(BuilderContext ctx) throws IOException { SessionContext context = session.getSessionContext(); processAuthenticationToken(ctx, response.getSecurityBuffer()); - if (!ctx.authContext.isAnonymous() && !ctx.authContext.isGuest()) { + if (ctx.sessionKey != null) { context.setSessionKey(new SecretKeySpec(ctx.sessionKey, HMAC_SHA256_ALGORITHM)); } if (dialect == SMB2Dialect.SMB_3_1_1) {