This is an automated email from the ASF dual-hosted git repository.
orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/master by this push:
new 4d68b03 NO-JIRA: Add debug logging into tests for kerberos
authentication
4d68b03 is described below
commit 4d68b03ac7f68dd02806911c13556bda74c9e123
Author: Alex Rudyy <[email protected]>
AuthorDate: Thu Dec 5 15:17:48 2019 +0000
NO-JIRA: Add debug logging into tests for kerberos authentication
---
.../manager/KerberosAuthenticationManagerTest.java | 29 +-----------
.../apache/qpid/server/test/KerberosUtilities.java | 54 ++++++++++++++++++++++
2 files changed, 56 insertions(+), 27 deletions(-)
diff --git
a/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerTest.java
b/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerTest.java
index e0ede79..1232367 100644
---
a/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerTest.java
+++
b/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerTest.java
@@ -62,7 +62,6 @@ import
org.apache.qpid.server.security.auth.sasl.SaslNegotiator;
import org.apache.qpid.server.security.auth.sasl.SaslSettings;
import org.apache.qpid.server.test.EmbeddedKdcResource;
import org.apache.qpid.server.test.KerberosUtilities;
-import org.apache.qpid.server.util.FileUtils;
import org.apache.qpid.server.util.StringUtil;
import org.apache.qpid.test.utils.JvmVendor;
import org.apache.qpid.test.utils.SystemPropertySetter;
@@ -120,27 +119,7 @@ public class KerberosAuthenticationManagerTest extends
UnitTestBase
when(_broker.getChildren(AuthenticationProvider.class))
.thenReturn(Collections.singleton(_kerberosAuthenticationProvider));
- if (LOGGER.isDebugEnabled())
- {
- final String krb5Conf =
System.getProperty("java.security.krb5.conf");
- if (krb5Conf != null)
- {
- final File file = new File(krb5Conf);
- if (file.exists())
- {
- String config = FileUtils.readFileAsString(file);
- debug("Kerberos config: {}", config);
- }
- else
- {
- LOGGER.warn("Kerberos config file was not found in the
expected location at '{}'", krb5Conf);
- }
- }
- else
- {
- LOGGER.warn("JVM system property 'java.security.krb5.conf' is
not set");
- }
- }
+ UTILS.debugConfig();
}
@Test
@@ -238,11 +217,7 @@ public class KerberosAuthenticationManagerTest extends
UnitTestBase
private void debug(String message, Object... args)
{
- LOGGER.debug(message, args);
- if
(Boolean.TRUE.toString().equalsIgnoreCase(System.getProperty("sun.security.krb5.debug")))
- {
- System.out.println(String.format(message.replace("{}", "%s"),
args));
- }
+ UTILS.debug(message, args);
}
private AuthenticationResult performNegotiation(final Subject
clientSubject,
diff --git
a/broker-core/src/test/java/org/apache/qpid/server/test/KerberosUtilities.java
b/broker-core/src/test/java/org/apache/qpid/server/test/KerberosUtilities.java
index 182df06..74cb2d2 100644
---
a/broker-core/src/test/java/org/apache/qpid/server/test/KerberosUtilities.java
+++
b/broker-core/src/test/java/org/apache/qpid/server/test/KerberosUtilities.java
@@ -47,6 +47,8 @@ import org.ietf.jgss.Oid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.qpid.server.util.FileUtils;
+
public class KerberosUtilities
{
private static final Logger LOGGER =
LoggerFactory.getLogger(KerberosUtilities.class);
@@ -57,6 +59,12 @@ public class KerberosUtilities
public byte[] buildToken(String clientPrincipalName, String
targetServerPrincipalName) throws GSSException
{
+ debugConfig();
+
+ debug("Building token for client principal '{}' and server principal
'{}'",
+ clientPrincipalName,
+ targetServerPrincipalName);
+
final GSSManager manager = GSSManager.getInstance();
final GSSName clientName = manager.createName(clientPrincipalName,
GSSName.NT_USER_NAME);
final GSSCredential credential = manager.createCredential(clientName,
@@ -64,17 +72,28 @@ public class KerberosUtilities
new
Oid("1.2.840.113554.1.2.2"),
GSSCredential.INITIATE_ONLY);
+ debug("Client credential '{}'", credential);
+
final GSSName serverName =
manager.createName(targetServerPrincipalName, GSSName.NT_USER_NAME);
final Oid spnegoMechOid = new Oid("1.3.6.1.5.5.2");
final GSSContext clientContext =
manager.createContext(serverName.canonicalize(spnegoMechOid),
spnegoMechOid,
credential,
GSSContext.DEFAULT_LIFETIME);
+
+ debug("Requesting ticket using initiator's credentials");
+
try
{
clientContext.requestCredDeleg(true);
+ debug("Requesting ticket");
return clientContext.initSecContext(new byte[]{}, 0, 0);
}
+ catch (GSSException e)
+ {
+ debug("Failure to request token", e);
+ throw e;
+ }
finally
{
clientContext.dispose();
@@ -186,4 +205,39 @@ public class KerberosUtilities
return new AppConfigurationEntry[0];
}
}
+
+ public static void debugConfig()
+ {
+ if (LOGGER.isDebugEnabled())
+ {
+ final String krb5Conf =
System.getProperty("java.security.krb5.conf");
+ if (krb5Conf != null)
+ {
+ final File file = new File(krb5Conf);
+ if (file.exists())
+ {
+ String config = FileUtils.readFileAsString(file);
+ debug("Kerberos config: {}", config);
+ }
+ else
+ {
+ LOGGER.warn("Kerberos config file was not found in the
expected location at '{}'", krb5Conf);
+ }
+ }
+ else
+ {
+ LOGGER.warn("JVM system property 'java.security.krb5.conf' is
not set");
+ }
+ }
+ }
+
+ public static void debug(String message, Object... args)
+ {
+ LOGGER.debug(message, args);
+ if
(Boolean.TRUE.toString().equalsIgnoreCase(System.getProperty("sun.security.krb5.debug")))
+ {
+ System.out.println(String.format(message.replace("{}", "%s"),
args));
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]