From 369592d333fb7fea719e7033b6f9b58bde303817 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 22 Oct 2018 13:08:58 -0600 Subject: [PATCH] [HTTPCLIENT-1947] Update JNA from 4.5.2 to 5.0.0. --- RELEASE_NOTES.txt | 3 +++ .../hc/client5/http/impl/win/WindowsNegotiateScheme.java | 9 +++++---- pom.xml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 057d39e56..bee1b368b 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -15,6 +15,9 @@ Changelog: * HTTPCLIENT-1939: Update Apache Commons Codec from 1.10 to 1.11 Contributed by Gary Gregory + +* HTTPCLIENT-1947: Update JNA from 4.5.2 to 5.0.0 + Contributed by Gary Gregory Release 5.0-BETA1 ------------------- diff --git a/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java b/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java index dd9c39bb5..85fcba40d 100644 --- a/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java +++ b/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java @@ -55,6 +55,7 @@ import com.sun.jna.platform.win32.Sspi.CredHandle; import com.sun.jna.platform.win32.Sspi.CtxtHandle; import com.sun.jna.platform.win32.Sspi.SecBufferDesc; import com.sun.jna.platform.win32.Sspi.TimeStamp; +import com.sun.jna.platform.win32.SspiUtil.ManagedSecBufferDesc; import com.sun.jna.platform.win32.Win32Exception; import com.sun.jna.platform.win32.WinError; import com.sun.jna.ptr.IntByReference; @@ -207,8 +208,8 @@ public class WindowsNegotiateScheme implements AuthScheme { } else { try { final byte[] continueTokenBytes = Base64.decodeBase64(challenge); - final SecBufferDesc continueTokenBuffer = new SecBufferDesc( - Sspi.SECBUFFER_TOKEN, continueTokenBytes); + final SecBufferDesc continueTokenBuffer = new ManagedSecBufferDesc( + Sspi.SECBUFFER_TOKEN, continueTokenBytes); final String targetName = getServicePrincipalName(request, clientContext); response = getToken(this.sspiContext, continueTokenBuffer, targetName); } catch (final RuntimeException ex) { @@ -270,7 +271,7 @@ public class WindowsNegotiateScheme implements AuthScheme { final SecBufferDesc continueToken, final String targetName) { final IntByReference attr = new IntByReference(); - final SecBufferDesc token = new SecBufferDesc( + final ManagedSecBufferDesc token = new ManagedSecBufferDesc( Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); sspiContext = new CtxtHandle(); @@ -290,7 +291,7 @@ public class WindowsNegotiateScheme implements AuthScheme { dispose(); throw new Win32Exception(rc); } - return Base64.encodeBase64String(token.getBytes()); + return Base64.encodeBase64String(token.getBuffer(0).getBytes()); } @Override diff --git a/pom.xml b/pom.xml index d6b95db60..33db00085 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 4.12 3.2 2.21.0 - 4.5.2 + 5.0.0 1 2.2.2