use of org.keycloak.component.ComponentValidationException in project keycloak by keycloak.
the class CustomUserProfileTest method testInvalidConfiguration.
private static void testInvalidConfiguration(KeycloakSession session) {
DeclarativeUserProfileProvider provider = getDynamicUserProfileProvider(session);
try {
provider.setConfiguration("{\"validateConfigAttribute\": true}");
fail("Should fail validation");
} catch (ComponentValidationException ve) {
// OK
}
}
use of org.keycloak.component.ComponentValidationException in project keycloak by keycloak.
the class ConfigurationValidationHelper method checkInt.
public ConfigurationValidationHelper checkInt(String key, String label, boolean required) throws ComponentValidationException {
checkSingle(key, label, required);
String val = model.getConfig().getFirst(key);
if (val != null) {
try {
Integer.parseInt(val);
} catch (NumberFormatException e) {
throw new ComponentValidationException("''{0}'' should be a number", label);
}
}
return this;
}
use of org.keycloak.component.ComponentValidationException in project keycloak by keycloak.
the class DeclarativeUserProfileProvider method validateConfiguration.
@Override
public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel model) throws ComponentValidationException {
String upConfigJson = getConfigJsonFromComponentModel(model);
if (!isBlank(upConfigJson)) {
try {
UPConfig upc = readConfig(new ByteArrayInputStream(upConfigJson.getBytes("UTF-8")));
List<String> errors = UPConfigUtils.validate(session, upc);
if (!errors.isEmpty()) {
throw new ComponentValidationException(errors.toString());
}
} catch (IOException e) {
throw new ComponentValidationException(e.getMessage(), e);
}
}
// throught #configureUserProfile(metadata, session)
if (model != null) {
model.removeNote(PARSED_CONFIG_COMPONENT_KEY);
}
}
use of org.keycloak.component.ComponentValidationException in project keycloak by keycloak.
the class UserPropertyFileStorageFactory method validateConfiguration.
@Override
public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel config) throws ComponentValidationException {
String fp = config.getConfig().getFirst(PROPERTY_FILE);
if (fp == null) {
throw new ComponentValidationException(VALIDATION_PROP_FILE_NOT_CONFIGURED);
}
fp = EnvUtil.replace(fp);
File file = new File(fp);
if (!file.exists()) {
throw new ComponentValidationException(VALIDATION_PROP_FILE_DOESNT_EXIST);
}
}
Aggregations