use of org.openremote.model.http.ConstraintViolationReport in project openremote by openremote.
the class TenantResourceImpl method isIllegalMasterRealmDeletion.
protected ConstraintViolationReport isIllegalMasterRealmDeletion(String realm) {
if (!realm.equals(MASTER_REALM))
return null;
ResourceBundle validationMessages = getContainer().getService(I18NService.class).getValidationMessages();
List<ConstraintViolation> violations = new ArrayList<>();
ConstraintViolation violation = new ConstraintViolation();
violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
violation.setMessage(validationMessages.getString("Tenant.masterDeleted"));
violations.add(violation);
ConstraintViolationReport report = new ConstraintViolationReport();
report.setParameterViolations(violations.toArray(new ConstraintViolation[violations.size()]));
return report;
}
use of org.openremote.model.http.ConstraintViolationReport in project openremote by openremote.
the class TenantResourceImpl method isIllegalMasterRealmMutation.
protected ConstraintViolationReport isIllegalMasterRealmMutation(String realm, Tenant tenant) {
if (!realm.equals(MASTER_REALM))
return null;
ResourceBundle validationMessages = getContainer().getService(I18NService.class).getValidationMessages();
List<ConstraintViolation> violations = new ArrayList<>();
if (tenant.getEnabled() == null || !tenant.getEnabled()) {
ConstraintViolation violation = new ConstraintViolation();
violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
violation.setPath("Tenant.enabled");
violation.setMessage(validationMessages.getString("Tenant.masterDisabled"));
violations.add(violation);
}
if (tenant.getRealm() == null || !tenant.getRealm().equals(MASTER_REALM)) {
ConstraintViolation violation = new ConstraintViolation();
violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
violation.setPath("Tenant.realm");
violation.setMessage(validationMessages.getString("Tenant.masterRealmChanged"));
violations.add(violation);
}
if (violations.size() > 0) {
ConstraintViolationReport report = new ConstraintViolationReport();
report.setParameterViolations(violations.toArray(new ConstraintViolation[violations.size()]));
return report;
}
return null;
}
use of org.openremote.model.http.ConstraintViolationReport in project openremote by openremote.
the class UserResourceImpl method isIllegalMasterAdminUserDeletion.
protected ConstraintViolationReport isIllegalMasterAdminUserDeletion(RequestParams requestParams, String realm, String userId) {
if (!realm.equals(MASTER_REALM))
return null;
if (!identityService.getIdentityProvider().isMasterRealmAdmin(new ClientRequestInfo(getClientRemoteAddress(), requestParams.getBearerAuth()), userId))
return null;
ResourceBundle validationMessages = getContainer().getService(I18NService.class).getValidationMessages();
List<ConstraintViolation> violations = new ArrayList<>();
ConstraintViolation violation = new ConstraintViolation();
violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
violation.setMessage(validationMessages.getString("User.masterAdminDeleted"));
violations.add(violation);
ConstraintViolationReport report = new ConstraintViolationReport();
report.setParameterViolations(violations.toArray(new ConstraintViolation[violations.size()]));
return report;
}
use of org.openremote.model.http.ConstraintViolationReport in project openremote by openremote.
the class UserResourceImpl method isIllegalMasterAdminUserMutation.
protected ConstraintViolationReport isIllegalMasterAdminUserMutation(RequestParams requestParams, String realm, User user) {
if (!realm.equals(MASTER_REALM))
return null;
if (!identityService.getIdentityProvider().isMasterRealmAdmin(new ClientRequestInfo(getClientRemoteAddress(), requestParams.getBearerAuth()), user.getId()))
return null;
ResourceBundle validationMessages = getContainer().getService(I18NService.class).getValidationMessages();
List<ConstraintViolation> violations = new ArrayList<>();
if (user.getEnabled() == null || !user.getEnabled()) {
ConstraintViolation violation = new ConstraintViolation();
violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
violation.setPath("User.enabled");
violation.setMessage(validationMessages.getString("User.masterAdminDisabled"));
violations.add(violation);
}
if (violations.size() > 0) {
ConstraintViolationReport report = new ConstraintViolationReport();
report.setParameterViolations(violations.toArray(new ConstraintViolation[violations.size()]));
return report;
}
return null;
}
Aggregations