use of org.jaffa.security.securityrolesdomain.Exclude in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method performUserRoleValidations.
private void performUserRoleValidations(String[] userRole, User domain) throws ApplicationExceptions {
ApplicationExceptions appExps = null;
boolean foundExcludedRole = false;
Roles root = PolicyCache.getRoles();
if (root != null) {
List roleObjects = root.getRole();
if (roleObjects != null) {
for (Iterator it = roleObjects.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
if (Arrays.binarySearch(userRole, role.getName()) >= 0) {
List includes = role.getInclude();
if (includes != null) {
for (Iterator it2 = includes.iterator(); it2.hasNext(); ) {
Include includedObject = (Include) it2.next();
String includeName = includedObject.getName();
if (Arrays.binarySearch(userRole, includeName) < 0) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_INCLUDED_ROLE_MISSING, role.getName(), includeName));
}
}
}
List excludes = role.getExclude();
if (excludes != null && !foundExcludedRole) {
for (Iterator it2 = excludes.iterator(); it2.hasNext(); ) {
Exclude excludedObject = (Exclude) it2.next();
String excludeName = excludedObject.getName();
if (Arrays.binarySearch(userRole, excludeName) >= 0) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_EXCLUDED_ROLE_PRESENT, role.getName(), excludeName));
foundExcludedRole = true;
}
}
}
}
}
}
}
if (appExps != null && appExps.size() > 0)
throw appExps;
}
use of org.jaffa.security.securityrolesdomain.Exclude in project jaffa-framework by jaffa-projects.
the class UserMaintenanceForm method processExcludes.
private boolean processExcludes(HttpServletRequest request, Collection userRole) {
boolean valid = true;
boolean foundExcludedRole = false;
Roles root = PolicyCache.getRoles();
if (root != null) {
List roleObjects = root.getRole();
if (roleObjects != null) {
for (Iterator it = roleObjects.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
if (userRole.contains(role.getName())) {
List excludes = role.getExclude();
if ((excludes != null) && (!foundExcludedRole)) {
StringBuffer excludedRoles = new StringBuffer();
for (Iterator it2 = excludes.iterator(); it2.hasNext(); ) {
Exclude excludedObject = (Exclude) it2.next();
String excludeName = excludedObject.getName();
if (userRole.contains(excludeName)) {
foundExcludedRole = true;
valid = false;
}
if (excludedRoles.length() == 0)
excludedRoles.append(excludeName);
else
excludedRoles.append("," + excludeName);
}
if (foundExcludedRole)
raiseError(request, "roles", new ActionMessage("error.Jaffa.Admin.UserMaintenance.ExcludedRolesSelection", "" + role.getName(), "" + excludedRoles));
}
}
}
}
}
return valid;
}
Aggregations