RemoteUserFederationProvider implements UserFederationProvider { @Override public boolean validCredentials(RealmModel realm, UserModel user, List<UserCredentialModel> input) { LOG.infof("Validating credentials for %s", user.getUsername()); if (input == null || input.isEmpty()) { throw new IllegalArgumentException("UserCredentialModel list is empty or null!"); } UserCredentialModel credentials = input.get(0); Response response = federatedUserService.validateLogin(user.getUsername(), new UserCredentialsDto(credentials.getValue())); boolean valid = HttpStatus.SC_OK == response.getStatus(); if (valid) { user.updateCredential(credentials); user.setFederationLink(null); } return valid; } RemoteUserFederationProvider(KeycloakSession session, UserFederationProviderModel model, String uri); protected  RemoteUserFederationProvider(KeycloakSession session, UserFederationProviderModel model, FederatedUserService federatedUserService); @Override boolean synchronizeRegistrations(); @Override UserModel register(RealmModel realm, UserModel user); @Override boolean removeUser(RealmModel realm, UserModel user); @Override UserModel getUserByUsername(RealmModel realm, String username); @Override UserModel getUserByEmail(RealmModel realm, String email); @Override List<UserModel> searchByAttributes(Map<String, String> attributes, RealmModel realm, int maxResults); @Override void preRemove(RealmModel realm); @Override void preRemove(RealmModel realm, RoleModel role); @Override void preRemove(RealmModel realm, GroupModel group); @Override Set<String> getSupportedCredentialTypes(UserModel user); @Override Set<String> getSupportedCredentialTypes(); @Override boolean validCredentials(RealmModel realm, UserModel user, List<UserCredentialModel> input); @Override boolean validCredentials(RealmModel realm, UserModel user, UserCredentialModel... input); @Override CredentialValidationOutput validCredentials(RealmModel realm, UserCredentialModel credential); @Override UserModel validateAndProxy(RealmModel realm, UserModel local); @Override boolean isValid(RealmModel realm, UserModel local); @Override void close();  }
@Test public void testValidCredentialsVarArg() throws Exception { assertTrue(provider.validCredentials(realmModel, userModel, UserCredentialModel.password(FEDERATED_USER_KNOWN_PASSWORD))); }
@Test public void testValidCredentialsList() throws Exception { assertFalse(provider.validCredentials(realmModel, userModel, Arrays.asList(UserCredentialModel.password(UUID.randomUUID().toString())))); assertTrue(provider.validCredentials(realmModel, userModel, Arrays.asList(UserCredentialModel.password(FEDERATED_USER_KNOWN_PASSWORD)))); }
@Test public void testValidCredentialsListInvalid() throws Exception { assertFalse(provider.validCredentials(realmModel, userModel, Arrays.asList(UserCredentialModel.password(UUID.randomUUID().toString())))); }
@Test public void testValidCredentialsNoUser() throws Exception { CredentialValidationOutput result = provider.validCredentials(realmModel, UserCredentialModel.password(UUID.randomUUID().toString())); assertEquals(CredentialValidationOutput.failed().getAuthStatus(), result.getAuthStatus()); }