Search in sources :

Example 71 with KerberosPrincipal

use of javax.security.auth.kerberos.KerberosPrincipal in project qpid-broker-j by apache.

the class KerberosAuthenticationManagerTest method testCreateSaslNegotiator.

@Test
public void testCreateSaslNegotiator() throws Exception {
    final SaslSettings saslSettings = mock(SaslSettings.class);
    when(saslSettings.getLocalFQDN()).thenReturn(HOST_NAME);
    final SaslNegotiator negotiator = _kerberosAuthenticationProvider.createSaslNegotiator(GSSAPI_MECHANISM, saslSettings, null);
    assertNotNull("Could not create SASL negotiator", negotiator);
    try {
        final AuthenticationResult result = authenticate(negotiator);
        assertEquals(AuthenticationResult.AuthenticationStatus.SUCCESS, result.getStatus());
        assertEquals(new KerberosPrincipal(CLIENT_PRINCIPAL_FULL_NAME).getName(), result.getMainPrincipal().getName());
    } finally {
        negotiator.dispose();
    }
}
Also used : SaslSettings(org.apache.qpid.server.security.auth.sasl.SaslSettings) KerberosPrincipal(javax.security.auth.kerberos.KerberosPrincipal) SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult) Test(org.junit.Test)

Aggregations

KerberosPrincipal (javax.security.auth.kerberos.KerberosPrincipal)71 Principal (java.security.Principal)36 Subject (javax.security.auth.Subject)31 HashSet (java.util.HashSet)21 LoginContext (javax.security.auth.login.LoginContext)20 Test (org.junit.Test)14 X500Principal (javax.security.auth.x500.X500Principal)13 KerberosTicket (javax.security.auth.kerberos.KerberosTicket)11 IOException (java.io.IOException)10 File (java.io.File)9 KerberosKey (javax.security.auth.kerberos.KerberosKey)9 PrivilegedActionException (java.security.PrivilegedActionException)8 StringTokenizer (java.util.StringTokenizer)6 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Properties (java.util.Properties)3 CallbackHandler (javax.security.auth.callback.CallbackHandler)3 KeyTab (javax.security.auth.kerberos.KeyTab)3