use of org.jaffa.security.securityrolesdomain.Role 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;
}
use of org.jaffa.security.securityrolesdomain.Role in project jaffa-framework by jaffa-projects.
the class RoleManager method unregisterResource.
/**
* unregisterResource - Unregisters the roles from the role repository using the roles.xml files found in META-INF/roles.xml
* that exist in the classpath. This is used to return the repository to its original state before a custom
* configuration was added.
* @param resource the object that contains the xml config file.
* @param context key with which config file to be registered.
* @throws JAXBException
* @throws SAXException
* @throws IOException
*/
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
Roles roles = JAXBHelper.unmarshalConfigFile(Roles.class, resource, CONFIGURATION_SCHEMA_FILE);
if (roles.getRole() != null) {
for (final Role role : roles.getRole()) {
ContextKey key = new ContextKey(role.getName(), resource.getURI().toString(), variation, context);
unregisterRole(key);
}
}
}
use of org.jaffa.security.securityrolesdomain.Role in project jaffa-framework by jaffa-projects.
the class RoleManager method buildRoleMap.
/**
* buildRoleMap - Builds a hashmap of name-grantfunctionAccess lists for use in the PolicyCache.
*
* @return A Map of Role names as keys and values that contain a List of GrantFunctionAccess.
*/
public Map<String, List<String>> buildRoleMap() {
Map<String, List<String>> nameGrantFunctionAccessMap = new HashMap<>();
List<Role> roleList = getAllRoles();
for (Role role : roleList) {
if (log.isDebugEnabled())
log.debug("Processing Role: " + role.getName());
List<GrantFunctionAccess> access = role.getGrantFunctionAccess();
List<String> funcs = null;
if (access != null) {
funcs = new LinkedList<>();
// Add all the names in all of the GrantAccess objects to the list.
for (GrantFunctionAccess gfa : access) {
funcs.add(gfa.getName());
if (log.isDebugEnabled())
log.debug("Processing Role: " + role.getName() + " has function " + gfa.getName());
}
}
// If there are some functions, add it to the master Map
if (funcs != null)
nameGrantFunctionAccessMap.put(role.getName(), funcs);
}
return nameGrantFunctionAccessMap;
}
use of org.jaffa.security.securityrolesdomain.Role in project jaffa-framework by jaffa-projects.
the class CheckPolicyComponent method getRoleMap.
/**
* This creates a HashMap of role and list bussiness-functions for that role
*/
static HashMap getRoleMap() {
// Get the roles, throws exceptions if there are issues
Roles roles = PolicyCache.getRoles();
m_roleBFMap.clear();
List roleList = roles.getRole();
// Bail if there are no roles....
if (roleList == null) {
return m_roleBFMap;
}
// Loop of all the role objects
for (Iterator it = roleList.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
if (log.isDebugEnabled()) {
log.debug("Processing Role: " + role.getName());
}
List access = role.getGrantFunctionAccess();
List funcs = null;
if (access != null) {
funcs = new ArrayList();
// Add all the names in all of the GrantAccess objects to the list.
for (Iterator it2 = access.iterator(); it2.hasNext(); ) {
GrantFunctionAccess gfa = (GrantFunctionAccess) it2.next();
funcs.add(gfa.getName());
if (log.isDebugEnabled()) {
log.debug("Processing Role: " + role.getName() + " has function " + gfa.getName());
}
}
}
// If there are some functions, add it to the master hashmap
if (funcs != null) {
m_roleBFMap.put(role.getName(), funcs);
}
}
// Return the construsted Map
return m_roleBFMap;
}
Aggregations