federation/kerberos/src/main/java/org/keycloak/federation/kerberos/KerberosFederationProvider.java
/**
     * Called after successful authentication
     *
     * @param realm realm
     * @param username username without realm prefix
     * @return user if found or successfully created. Null if user with same username already exists, but is not linked to this provider
     */
Called after successful authentication
@param realm realm
@param username username without realm prefix
@return user if found or successfully created. Null if user with same username already exists, but is not linked to this provider
Called after successful authentication @param realm realm @param username username without realm prefix @return user if found or successfully created . Null if user with same username already exists but is not linked to this provider
protected UserModel findOrCreateAuthenticatedUser(RealmModel realm, String username) {
        UserModel user = session.userStorage().getUserByUsername(username, realm);
        if (user != null) {
            logger.debug("Kerberos authenticated user " + username + " found in Keycloak storage");
            if (!model.getId().equals(user.getFederationLink())) {
                logger.warn("User with username " + username + " already exists, but is not linked to provider [" + model.getDisplayName() + "]");
                return null;
            } else {
                UserModel proxied = validateAndProxy(realm, user);
                if (proxied != null) {
                    return proxied;
                } else {
                    logger.warn("User with username " + username + " already exists and is linked to provider [" + model.getDisplayName() +
                            "] but kerberos principal is not correct. Kerberos principal on user is: " + user.getAttribute(KERBEROS_PRINCIPAL));
                    logger.warn("Will re-create user");
                    session.userStorage().removeUser(realm, user);
                }
            }
        }
        logger.debug("Kerberos authenticated user " + username + " not in Keycloak storage. Creating him");
        return importUserToKeycloak(realm, username);
    }
protected UserModel findOrCreateAuthenticatedUser ( RealmModel realm , String username ) { UserModel user = session . userStorage ( ) . getUserByUsername ( username , realm ) ; if ( user != null ) { logger . debug ( "Kerberos authenticated user " + username + " found in Keycloak storage" ) ; if ( ! model . getId ( ) . equals ( user . getFederationLink ( ) ) ) { logger . warn ( "User with username " + username + " already exists, but is not linked to provider [" + model . getDisplayName ( ) + "]" ) ; return null ; } else { UserModel proxied = validateAndProxy ( realm , user ) ; if ( proxied != null ) { return proxied ; } else { logger . warn ( "User with username " + username + " already exists and is linked to provider [" + model . getDisplayName ( ) + "] but kerberos principal is not correct. Kerberos principal on user is: " + user . getAttribute ( KERBEROS_PRINCIPAL ) ) ; logger . warn ( "Will re-create user" ) ; session . userStorage ( ) . removeUser ( realm , user ) ; } } } logger . debug ( "Kerberos authenticated user " + username + " not in Keycloak storage. Creating him" ) ; return importUserToKeycloak ( realm , username ) ; }
Called after successful authentication
 @param realm realm
 @param username username without realm prefix
 @return user if found or successfully created.
Called after successful authentication @param realm realm @param username username without realm prefix @return user if found or successfully created .