Search in sources :

Example 1 with KerberosProfile

use of org.pac4j.kerberos.profile.KerberosProfile in project pac4j by pac4j.

the class KerberosClientsKerbyTests method checkWithGoodTicket.

private void checkWithGoodTicket(Client<KerberosCredentials, KerberosProfile> client) throws Exception {
    String spnegoWebTicket = SpnegoServiceTicketHelper.getGSSTicket(clientPrincipal, clientPassword, serviceName);
    // mock web request
    final MockWebContext context = mockWebRequestContext(spnegoWebTicket);
    final KerberosCredentials credentials = client.getCredentials(context);
    assertNotNull(credentials);
    System.out.println(credentials);
    final KerberosProfile profile = client.getUserProfile(credentials, context);
    assertNotNull(profile);
    assertEquals(clientPrincipal, profile.getId());
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) KerberosProfile(org.pac4j.kerberos.profile.KerberosProfile) KerberosCredentials(org.pac4j.kerberos.credentials.KerberosCredentials)

Example 2 with KerberosProfile

use of org.pac4j.kerberos.profile.KerberosProfile in project pac4j by pac4j.

the class KerberosAuthenticator method validate.

@Override
public void validate(KerberosCredentials credentials, WebContext context) {
    logger.trace("Try to validate Kerberos Token:" + credentials.getKerberosTicketAsString());
    KerberosTicketValidation ticketValidation = this.ticketValidator.validateTicket(credentials.getKerberosTicket());
    logger.debug("Kerberos Token validated");
    String subject = ticketValidation.username();
    logger.debug("Succesfully validated " + subject);
    KerberosProfile profile = new KerberosProfile(ticketValidation.getGssContext());
    profile.setId(subject);
    credentials.setUserProfile(profile);
}
Also used : KerberosProfile(org.pac4j.kerberos.profile.KerberosProfile)

Aggregations

KerberosProfile (org.pac4j.kerberos.profile.KerberosProfile)2 MockWebContext (org.pac4j.core.context.MockWebContext)1 KerberosCredentials (org.pac4j.kerberos.credentials.KerberosCredentials)1