use of net.jforum.security.RoleValueCollection in project jforum2 by rafaelsteil.
the class CategoryAction method insertSave.
// A new one
public void insertSave() {
Category c = new Category();
c.setName(this.request.getParameter("category_name"));
c.setModerated("1".equals(this.request.getParameter("moderated")));
int categoryId = this.cm.addNew(c);
c.setId(categoryId);
ForumRepository.addCategory(c);
String[] groups = this.request.getParameterValues("groups");
if (groups != null) {
GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO();
PermissionControl pc = new PermissionControl();
pc.setSecurityModel(gmodel);
Role role = new Role();
role.setName(SecurityConstants.PERM_CATEGORY);
for (int i = 0; i < groups.length; i++) {
int groupId = Integer.parseInt(groups[i]);
RoleValueCollection roleValues = new RoleValueCollection();
RoleValue rv = new RoleValue();
rv.setValue(Integer.toString(categoryId));
roleValues.add(rv);
pc.addRoleValue(groupId, role, roleValues);
}
SecurityRepository.clean();
RolesRepository.clear();
}
this.list();
}
use of net.jforum.security.RoleValueCollection in project jforum2 by rafaelsteil.
the class ForumAction method addRole.
private void addRole(PermissionControl pc, String roleName, int forumId, String[] groups) {
Role role = new Role();
role.setName(roleName);
for (int i = 0; i < groups.length; i++) {
int groupId = Integer.parseInt(groups[i]);
RoleValueCollection roleValues = new RoleValueCollection();
RoleValue rv = new RoleValue();
rv.setValue(Integer.toString(forumId));
roleValues.add(rv);
pc.addRoleValue(groupId, role, roleValues);
}
}
use of net.jforum.security.RoleValueCollection in project jforum2 by rafaelsteil.
the class PermissionProcessHelper method processData.
public void processData() {
RequestContext request = JForumExecutionContext.getRequest();
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String paramName = (String) e.nextElement();
if (paramName.startsWith("perm_")) {
if (paramName.endsWith("$single")) {
String paramValue = request.getParameter(paramName);
if (paramValue.equals("deny")) {
continue;
}
paramName = paramName.substring(0, paramName.indexOf('$'));
Role role = new Role();
role.setName(paramName);
this.pc.addRole(this.groupId, role);
} else {
String[] paramValues = request.getParameterValues(paramName);
RoleValueCollection roleValues = new RoleValueCollection();
if ("all".equals(paramValues[0])) {
this.addRoleValues(roleValues, this.getSplitedValues("all" + paramName));
} else {
List allowList = new ArrayList(Arrays.asList(this.getSplitedValues("all" + paramName)));
allowList.removeAll(Arrays.asList(paramValues));
this.addRoleValues(roleValues, allowList.toArray());
}
Role role = new Role();
role.setName(paramName);
this.pc.addRole(this.groupId, role, roleValues);
}
}
}
}
Aggregations