hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1583331 - in /httpcomponents/httpclient/trunk: ./ httpclient-win/src/main/java/org/apache/http/impl/auth/win/
Date Mon, 31 Mar 2014 14:04:34 GMT
Author: olegk
Date: Mon Mar 31 14:04:34 2014
New Revision: 1583331

URL: http://svn.apache.org/r1583331
Log:
HTTPCLIENT-1491: Enable provision of Service Principal Name in Windows native auth scheme
Contributed by Malcolm Smith <malcolmfsmith at gmail.com>

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
    httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
    httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1583331&r1=1583330&r2=1583331&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Mon Mar 31 14:04:34 2014
@@ -4,6 +4,10 @@ Changes for 4.4-alpha1
 Changelog:
 -------------------
 
+* [HTTPCLIENT-1491] Enable provision of Service Principal Name in Windows native
+  auth scheme.
+  Contributed by Malcolm Smith <malcolmfsmith at gmail.com>
+
 * [HTTPCLIENT-1484] GzipCompressingEntity should not close the underlying output stream
   if the entity has not been fully written out due to an exception.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java?rev=1583331&r1=1583330&r2=1583331&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
Mon Mar 31 14:04:34 2014
@@ -44,9 +44,16 @@ import org.apache.http.protocol.HttpCont
 @Immutable
 public class WindowsNTLMSchemeFactory implements AuthSchemeProvider {
 
+    private String servicePrincipalName;
+
+    public WindowsNTLMSchemeFactory(final String servicePrincipalName) {
+        super();
+        this.servicePrincipalName = servicePrincipalName;
+    }
+
     @Override
     public AuthScheme create(final HttpContext context) {
-        return new WindowsNegotiateScheme(AuthSchemes.NTLM);
+        return new WindowsNegotiateScheme(AuthSchemes.NTLM, servicePrincipalName);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java?rev=1583331&r1=1583330&r2=1583331&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
Mon Mar 31 14:04:34 2014
@@ -85,13 +85,15 @@ public class WindowsNegotiateScheme exte
     private CtxtHandle sppicontext;
     private boolean continueNeeded;
     private String challenge;
+    private String servicePrincipalName;
 
-    public WindowsNegotiateScheme(final String scheme) {
+    public WindowsNegotiateScheme(final String scheme, final String servicePrincipalName)
{
         super();
 
         this.scheme = (scheme == null) ? AuthSchemes.SPNEGO : scheme;
         this.challenge = null;
         this.continueNeeded = true;
+        this.servicePrincipalName = servicePrincipalName;
     }
 
     public void dispose() {
@@ -187,7 +189,8 @@ public class WindowsNegotiateScheme exte
                     throw new Win32Exception(rc);
                 }
 
-                response = getToken(null, null, username);
+                response = getToken(null, null,
+                        this.servicePrincipalName != null ? this.servicePrincipalName : username);
             } catch (Throwable t) {
                 dispose();
                 throw new AuthenticationException("Authentication Failed", t);
@@ -200,7 +203,8 @@ public class WindowsNegotiateScheme exte
                 final byte[] continueTokenBytes = Base64.decodeBase64(this.challenge);
                 final SecBufferDesc continueTokenBuffer = new SecBufferDesc(
                         Sspi.SECBUFFER_TOKEN, continueTokenBytes);
-                response = getToken(this.sppicontext, continueTokenBuffer, "localhost");
+                response = getToken(this.sppicontext, continueTokenBuffer,
+                        this.servicePrincipalName != null ? this.servicePrincipalName : "localhost");
             } catch (Throwable t) {
                 dispose();
                 throw new AuthenticationException("Authentication Failed", t);

Modified: httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java?rev=1583331&r1=1583330&r2=1583331&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java
Mon Mar 31 14:04:34 2014
@@ -44,9 +44,16 @@ import org.apache.http.protocol.HttpCont
 @Immutable
 public class WindowsNegotiateSchemeFactory implements AuthSchemeProvider {
 
+    private String servicePrincipalName;
+
+    public WindowsNegotiateSchemeFactory(final String servicePrincipalName) {
+        super();
+        this.servicePrincipalName = servicePrincipalName;
+    }
+
     @Override
     public AuthScheme create(final HttpContext context) {
-        return new WindowsNegotiateScheme(AuthSchemes.SPNEGO);
+        return new WindowsNegotiateScheme(AuthSchemes.SPNEGO, servicePrincipalName);
     }
 
 }



Mime
View raw message