use of org.pac4j.kerberos.credentials.authenticator.KerberosAuthenticator in project pac4j by pac4j.
the class KerberosClientTests method testAuthentication.
@Test
public void testAuthentication() {
when(krbValidator.validateTicket(any())).thenReturn(new KerberosTicketValidation("garry", null, null, null));
final DirectKerberosClient client = new DirectKerberosClient(new KerberosAuthenticator(krbValidator));
final MockWebContext context = MockWebContext.create();
context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER, "Negotiate " + new String(KERBEROS_TICKET, StandardCharsets.UTF_8));
final KerberosCredentials credentials = client.getCredentials(context);
assertEquals(new String(Base64.getDecoder().decode(KERBEROS_TICKET), StandardCharsets.UTF_8), new String(credentials.getKerberosTicket(), StandardCharsets.UTF_8));
final CommonProfile profile = client.getUserProfile(credentials, context);
assertEquals("garry", profile.getId());
}
use of org.pac4j.kerberos.credentials.authenticator.KerberosAuthenticator in project pac4j by pac4j.
the class KerberosClientTests method testMissingKerberosHeader.
@Test
public void testMissingKerberosHeader() {
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
final DirectKerberosClient client = new DirectKerberosClient(new KerberosAuthenticator(krbValidator));
KerberosCredentials credentials = client.getCredentials(new J2EContext(request, response));
assertNull(credentials);
}
use of org.pac4j.kerberos.credentials.authenticator.KerberosAuthenticator in project pac4j by pac4j.
the class KerberosClientsKerbyTests method setupIndirectKerberosClient.
private IndirectKerberosClient setupIndirectKerberosClient() {
IndirectKerberosClient client = new IndirectKerberosClient(new KerberosAuthenticator(getKerberosValidator()));
client.setCallbackUrl("http://dummy.com/");
return client;
}
Aggregations