federation/kerberos/src/main/java/org/keycloak/federation/kerberos/impl/KerberosUsernamePasswordAuthenticator.java
/**
     * Returns true if user with given username exists in kerberos database
     *
     * @param username username without Kerberos realm attached or with correct realm attached
     * @return true if user available
     */
Returns true if user with given username exists in kerberos database
@param username username without Kerberos realm attached or with correct realm attached
@return true if user available
Returns true if user with given username exists in kerberos database @param username username without Kerberos realm attached or with correct realm attached @return true if user available
public boolean isUserAvailable(String username) {
        logger.debug("Checking existence of user: " + username);
        try {
            String principal = getKerberosPrincipal(username);
            loginContext = new LoginContext("does-not-matter", null,
                    createJaasCallbackHandler(principal, "fake-password-which-nobody-has"),
                    createJaasConfiguration());
            loginContext.login();
            throw new IllegalStateException("Didn't expect to end here");
        } catch (LoginException le) {
            String message = le.getMessage();
            logger.debug("Message from kerberos: " + message);
            boolean exists = (!message.contains("Client not found"));
            return exists;
        }
    }
public boolean isUserAvailable ( String username ) { logger . debug ( "Checking existence of user: " + username ) ; try { String principal = getKerberosPrincipal ( username ) ; loginContext = new LoginContext ( "does-not-matter" , null , createJaasCallbackHandler ( principal , "fake-password-which-nobody-has" ) , createJaasConfiguration ( ) ) ; loginContext . login ( ) ; throw new IllegalStateException ( "Didn't expect to end here" ) ; } catch ( LoginException le ) { String message = le . getMessage ( ) ; logger . debug ( "Message from kerberos: " + message ) ; boolean exists = ( ! message . contains ( "Client not found" ) ) ; return exists ; } }
Returns true if user with given username exists in kerberos database
 @param username username without Kerberos realm attached or with correct realm attached
 @return true if user available
Returns true if user with given username exists in kerberos database @param username username without Kerberos realm attached or with correct realm attached @return true if user available
// Bit cumbersome, but seems to work with tested kerberos servers