public static UserModel addLocalUser( KeycloakSession session, RealmModel realm, String username, String email, String password) { UserModel user = session.userStorage().addUser(realm, username); user.setEmail(email); user.setEnabled(true); UserCredentialModel creds = new UserCredentialModel(); creds.setType(CredentialRepresentation.PASSWORD); creds.setValue(password); session.userCredentialManager().updateCredential(realm, user, creds); return user; }
private boolean isConfigured(KeycloakSession session, RealmModel realm, UserModel user) { return session .userCredentialManager() .isConfiguredFor(realm, user, realm.getOTPPolicy().getType()); }