hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From micha...@apache.org
Subject svn commit: r1671769 - /httpcomponents/httpclient/branches/HTTPCLIENT-1625/src/main/java/org/apache/http/impl/auth/GSSBasedScheme.java
Date Tue, 07 Apr 2015 09:19:03 GMT
Author: michaelo
Date: Tue Apr  7 09:19:02 2015
New Revision: 1671769

URL: http://svn.apache.org/r1671769
Log:
Adding some more logging to GSSBasedScheme

Modified:
    httpcomponents/httpclient/branches/HTTPCLIENT-1625/src/main/java/org/apache/http/impl/auth/GSSBasedScheme.java

Modified: httpcomponents/httpclient/branches/HTTPCLIENT-1625/src/main/java/org/apache/http/impl/auth/GSSBasedScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/HTTPCLIENT-1625/src/main/java/org/apache/http/impl/auth/GSSBasedScheme.java?rev=1671769&r1=1671768&r2=1671769&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/HTTPCLIENT-1625/src/main/java/org/apache/http/impl/auth/GSSBasedScheme.java
(original)
+++ httpcomponents/httpclient/branches/HTTPCLIENT-1625/src/main/java/org/apache/http/impl/auth/GSSBasedScheme.java
Tue Apr  7 09:19:02 2015
@@ -64,11 +64,11 @@ public class GSSBasedScheme extends Auth
     private static final String KERBEROS5_OID = "1.2.840.113554.1.2";
     private static final String SPNEGO_OID = "1.3.6.1.5.5.2";
 
-    private static final Map<String, String> schemesToMechOids = new HashMap<String,
String>(2);
+    private static final Map<String, String> SCHEMES_TO_MECH_OIDS = new HashMap<String,
String>(2);
 
     static {
-        schemesToMechOids.put(AuthSchemes.KERBEROS, KERBEROS5_OID);
-        schemesToMechOids.put(AuthSchemes.SPNEGO, SPNEGO_OID);
+    	SCHEMES_TO_MECH_OIDS.put(AuthSchemes.KERBEROS, KERBEROS5_OID);
+    	SCHEMES_TO_MECH_OIDS.put(AuthSchemes.SPNEGO, SPNEGO_OID);
     }
 
     enum State {
@@ -85,7 +85,7 @@ public class GSSBasedScheme extends Auth
     public GSSBasedScheme(final String scheme) {
         Args.notBlank(scheme, "scheme");
 
-        mechOidStr = schemesToMechOids.get(scheme);
+        mechOidStr = SCHEMES_TO_MECH_OIDS.get(scheme);
 
         if (mechOidStr == null)
             throw new IllegalArgumentException(String.format(
@@ -117,7 +117,7 @@ public class GSSBasedScheme extends Auth
 
     @Override
     public boolean isComplete() {
-        return state == State.COMPLETED;
+    	return state == State.COMPLETED;
     }
 
     @Override
@@ -130,14 +130,16 @@ public class GSSBasedScheme extends Auth
     @Override
     public Header authenticate(final Credentials credentials, final HttpRequest request,
final HttpContext context)
             throws AuthenticationException {
-    	logger.debug("Performing SPNEGO authentication");
+    	logger.debug("Using HttpContext " + context);
         switch (state) {
         case COMPLETED:
             // TODO implement me!
             state = State.NOT_STARTED;
+            logger.debug("Resetting scheme state to from " + State.COMPLETED + " to " + State.NOT_STARTED);
         case NOT_STARTED:
             final GSSManager gssManager = GSSManager.getInstance();
 
+            logger.debug(String.format("Starting GSS-based authentication for scheme '%s'
(%s)", scheme, mechOidStr));
             Oid mechOid;
             try {
                 mechOid = new Oid(mechOidStr);
@@ -166,10 +168,14 @@ public class GSSBasedScheme extends Auth
                 gssContext.requestCredDeleg(true);
                 gssContext.requestMutualAuth(true);
 
+                logger.debug(String.format("GSS context for %s host with SPN '%s' created",
isProxy()? "proxy" : "target", targetName));
+
                 byte[] outputToken = gssContext.initSecContext(inputToken, 0, inputToken.length);
                 inputToken = new byte[0];
                 state = gssContext.isEstablished() ? State.COMPLETED : State.IN_PROGRESS;
 
+                logger.debug("GSS context establishment is " + (state == State.COMPLETED
? "completed" : "in progress"));
+
                 final String base64OutputToken = Base64.encodeBase64String(outputToken);
                 outputToken = null;
 
@@ -199,6 +205,7 @@ public class GSSBasedScheme extends Auth
                 inputToken = new byte[0];
                 state = gssContext.isEstablished() ? State.COMPLETED : State.IN_PROGRESS;
 
+                logger.debug("GSS context establishment is " + (state == State.COMPLETED
? "completed" : "in progress"));
                 final String base64OutputToken = Base64.encodeBase64String(outputToken);
                 outputToken = null;
 
@@ -231,10 +238,11 @@ public class GSSBasedScheme extends Auth
             throws MalformedChallengeException {
         final String base64InputToken = buffer.substringTrimmed(beginIndex, endIndex);
 
-        logger.debug("Received SPNEGO token: " + base64InputToken);
-
         inputToken = Base64.decodeBase64(base64InputToken);
 
+        if(inputToken != null && inputToken.length != 0)
+        logger.debug("Received " + scheme + "token from server");
+
         if (inputToken == null)
             inputToken = new byte[0];
     }



Mime
View raw message