use of org.keycloak.storage.UserStorageProviderModel in project keycloak by keycloak.
the class TestLDAPResource method removeLDAPUser.
/**
* Remove specified user directly just from the LDAP server
*/
@DELETE
@Path("/remove-ldap-user")
@Consumes(MediaType.APPLICATION_JSON)
public void removeLDAPUser(@QueryParam("username") String ldapUsername) {
ComponentModel ldapCompModel = LDAPTestUtils.getLdapProviderModel(realm);
UserStorageProviderModel ldapModel = new UserStorageProviderModel(ldapCompModel);
LDAPStorageProvider ldapProvider = LDAPTestUtils.getLdapProvider(session, ldapModel);
LDAPTestUtils.removeLDAPUserByUsername(ldapProvider, realm, ldapProvider.getLdapIdentityStore().getConfig(), ldapUsername);
}
use of org.keycloak.storage.UserStorageProviderModel in project keycloak by keycloak.
the class UserCredentialStoreManager method updateCredential.
@Override
public boolean updateCredential(RealmModel realm, UserModel user, CredentialInput input) {
String providerId = StorageId.isLocalStorage(user) ? user.getFederationLink() : StorageId.resolveProviderId(user);
if (!StorageId.isLocalStorage(user))
throwExceptionIfInvalidUser(user);
if (providerId != null) {
UserStorageProviderModel model = getStorageProviderModel(realm, providerId);
if (model == null || !model.isEnabled())
return false;
CredentialInputUpdater updater = getStorageProviderInstance(model, CredentialInputUpdater.class);
if (updater != null && updater.supportsCredentialType(input.getType())) {
if (updater.updateCredential(realm, user, input))
return true;
}
}
return getCredentialProviders(session, CredentialInputUpdater.class).filter(updater -> updater.supportsCredentialType(input.getType())).anyMatch(updater -> updater.updateCredential(realm, user, input));
}
use of org.keycloak.storage.UserStorageProviderModel in project keycloak by keycloak.
the class UserCredentialStoreManager method isConfiguredThroughUserStorage.
private UserStorageCredentialConfigured isConfiguredThroughUserStorage(RealmModel realm, UserModel user, String type) {
String providerId = StorageId.isLocalStorage(user) ? user.getFederationLink() : StorageId.resolveProviderId(user);
if (providerId != null) {
UserStorageProviderModel model = getStorageProviderModel(realm, providerId);
if (model == null || !model.isEnabled())
return UserStorageCredentialConfigured.USER_STORAGE_DISABLED;
CredentialInputValidator validator = getStorageProviderInstance(model, CredentialInputValidator.class);
if (validator != null && validator.supportsCredentialType(type) && validator.isConfiguredFor(realm, user, type)) {
return UserStorageCredentialConfigured.CONFIGURED;
}
}
return UserStorageCredentialConfigured.NOT_CONFIGURED;
}
use of org.keycloak.storage.UserStorageProviderModel in project keycloak by keycloak.
the class UserCredentialStoreManager method getDisableableCredentialTypesStream.
@Override
public Stream<String> getDisableableCredentialTypesStream(RealmModel realm, UserModel user) {
Stream<String> types = Stream.empty();
String providerId = StorageId.isLocalStorage(user) ? user.getFederationLink() : StorageId.resolveProviderId(user);
if (providerId != null) {
UserStorageProviderModel model = getStorageProviderModel(realm, providerId);
if (model == null || !model.isEnabled())
return types;
CredentialInputUpdater updater = getStorageProviderInstance(model, CredentialInputUpdater.class);
if (updater != null)
types = updater.getDisableableCredentialTypesStream(realm, user);
}
return Stream.concat(types, getCredentialProviders(session, CredentialInputUpdater.class).flatMap(updater -> updater.getDisableableCredentialTypesStream(realm, user))).distinct();
}
use of org.keycloak.storage.UserStorageProviderModel in project keycloak by keycloak.
the class UserCredentialStoreManager method isValid.
@Override
public boolean isValid(RealmModel realm, UserModel user, List<CredentialInput> inputs) {
if (!isValid(user)) {
return false;
}
List<CredentialInput> toValidate = new LinkedList<>(inputs);
String providerId = StorageId.isLocalStorage(user) ? user.getFederationLink() : StorageId.resolveProviderId(user);
if (providerId != null) {
UserStorageProviderModel model = getStorageProviderModel(realm, providerId);
if (model == null || !model.isEnabled())
return false;
CredentialInputValidator validator = getStorageProviderInstance(model, CredentialInputValidator.class);
if (validator != null) {
validate(realm, user, toValidate, validator);
}
}
if (toValidate.isEmpty())
return true;
getCredentialProviders(session, CredentialInputValidator.class).forEach(validator -> validate(realm, user, toValidate, validator));
return toValidate.isEmpty();
}
Aggregations