use of org.pac4j.kerberos.credentials.authenticator.KerberosTicketValidation 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());
}
Aggregations