public static boolean match(String expectedName,Principal principal){
  String hostName=getServerName(principal);
  return (expectedName.equalsIgnoreCase(hostName));
}

public static boolean match ( String expectedName , Principal principal ) { String hostName = getServerName ( principal ) ; return ( expectedName . equalsIgnoreCase ( hostName ) ) ; }
perform the check for kerberos .
