private static void verifyServiceTicket( ChangePasswordContext changepwContext ) throws KerberosException
{
ChangePasswordConfig config = changepwContext.getConfig();
Ticket ticket = changepwContext.getTicket();
String primaryRealm = config.getPrimaryRealm();
KerberosPrincipal changepwPrincipal = config.getServicePrincipal();
KerberosPrincipal serverPrincipal = KerberosUtils.getKerberosPrincipal( ticket.getSName(), ticket.getRealm() );
// for some reason kpassword is setting the pricnipaltype value as 1 for ticket.getSName()
// hence changing to string based comparison for server and changepw principals
// instead of serverPrincipal.equals( changepwPrincipal )
if ( !ticket.getRealm().equals( primaryRealm ) || !serverPrincipal.getName().equals( changepwPrincipal.getName() ) )
{
throw new KerberosException( org.apache.directory.shared.kerberos.exceptions.ErrorType.KRB_AP_ERR_NOT_US );
}
}