hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1724851 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth: GGSSchemeBase.java KerberosScheme.java SPNegoScheme.java
Date Fri, 15 Jan 2016 16:37:48 GMT
Author: olegk
Date: Fri Jan 15 16:37:48 2016
New Revision: 1724851

URL: http://svn.apache.org/viewvc?rev=1724851&view=rev
Log:
HTTPCLIENT-1712: SPNego schemes to take service scheme into account when generating auth token
Contributed by Georg Romstorfer <georg.romstorfer at gmail.com>

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java?rev=1724851&r1=1724850&r2=1724851&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
Fri Jan 15 16:37:48 2016
@@ -28,6 +28,7 @@ package org.apache.http.impl.auth;
 
 import java.net.UnknownHostException;
 import java.security.Principal;
+import java.util.Locale;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.logging.Log;
@@ -129,13 +130,14 @@ public abstract class GGSSchemeBase impl
     /**
      * @since 4.4
      */
-    protected byte[] generateGSSToken(final byte[] input, final Oid oid, final String authServer)
throws GSSException {
+    protected byte[] generateGSSToken(
+            final byte[] input, final Oid oid, final String serviceName, final String authServer)
throws GSSException {
         byte[] inputBuff = input;
         if (inputBuff == null) {
             inputBuff = new byte[0];
         }
         final GSSManager manager = getManager();
-        final GSSName serverName = manager.createName("HTTP@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
+        final GSSName serverName = manager.createName(serviceName + "@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
 
         final GSSContext gssContext = manager.createContext(
                 serverName.canonicalize(oid), oid, gssCredential, GSSContext.DEFAULT_LIFETIME);
@@ -147,7 +149,7 @@ public abstract class GGSSchemeBase impl
     /**
      * @since 4.4
      */
-    protected abstract byte[] generateToken(byte[] input, String authServer) throws GSSException;
+    protected abstract byte[] generateToken(byte[] input, String serviceName, String authServer)
throws GSSException;
 
     @Override
     public boolean isChallengeComplete() {
@@ -204,11 +206,12 @@ public abstract class GGSSchemeBase impl
                 } else {
                     authServer = hostname + ":" + host.getPort();
                 }
+                final String serviceName = host.getSchemeName().toUpperCase(Locale.ROOT);
 
                 if (log.isDebugEnabled()) {
                     log.debug("init " + authServer);
                 }
-                token = generateToken(token, authServer);
+                token = generateToken(token, serviceName, authServer);
                 state = State.TOKEN_GENERATED;
             } catch (final GSSException gsse) {
                 state = State.FAILED;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java?rev=1724851&r1=1724850&r2=1724851&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
Fri Jan 15 16:37:48 2016
@@ -62,8 +62,8 @@ public class KerberosScheme extends GGSS
     }
 
     @Override
-    protected byte[] generateToken(final byte[] input, final String authServer) throws GSSException
{
-        return generateGSSToken(input, new Oid(KERBEROS_OID), authServer);
+    protected byte[] generateToken(final byte[] input, final String serviceName, final String
authServer) throws GSSException {
+        return generateGSSToken(input, new Oid(KERBEROS_OID), serviceName, authServer);
     }
 
     @Override

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java?rev=1724851&r1=1724850&r2=1724851&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
Fri Jan 15 16:37:48 2016
@@ -63,8 +63,8 @@ public class SPNegoScheme extends GGSSch
     }
 
     @Override
-    protected byte[] generateToken(final byte[] input, final String authServer) throws GSSException
{
-        return generateGSSToken(input, new Oid(SPNEGO_OID), authServer);
+    protected byte[] generateToken(final byte[] input, final String serviceName, final String
authServer) throws GSSException {
+        return generateGSSToken(input, new Oid(SPNEGO_OID), serviceName, authServer);
     }
 
     @Override



Mime
View raw message