Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute based access control implementation #398

Merged
merged 148 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
731b115
abac cleaned, squashed
litvinovg Jun 6, 2023
0f7e0c0
and authorization request
litvinovg Jun 6, 2023
d25f027
reverted page controller modifications
litvinovg Jun 6, 2023
88d69c3
removed AccessRullStore with tests
litvinovg Jun 6, 2023
b1e033e
proximity checker fixes
litvinovg Jun 6, 2023
48532d2
fix for prev commit
litvinovg Jun 6, 2023
757825c
new rules in amdin update object property policy, debug statements
litvinovg Jun 6, 2023
6b81737
Created faux object/data property/property statement access objects
litvinovg Jun 7, 2023
fba625b
refactoring and cleanup
litvinovg Jun 7, 2023
63be928
implemented getUri methods in access objects
litvinovg Jun 7, 2023
84f599c
created editable pages policy
litvinovg Jun 7, 2023
f011d36
fixed update admin policies
litvinovg Jun 7, 2023
18d364c
fixed debug log in entity policy controller
litvinovg Jun 7, 2023
2321c49
Added migration script from upstream, faux property policies, tests
litvinovg Jun 8, 2023
c020408
RDFService
litvinovg Jun 9, 2023
72a1653
moved policy configurations from everytime
litvinovg Jun 9, 2023
6ee958b
fixed faux property policies, fixed faux property assignment in web i…
litvinovg Jun 9, 2023
fc1d998
created special graph for access control configurations
litvinovg Jun 12, 2023
0d7086f
remove values in annotation migration
litvinovg Jun 12, 2023
a98f5e0
refactoring AuthMigrator
litvinovg Jun 12, 2023
ffb6488
arm migration
litvinovg Jun 12, 2023
16505d9
fixed access rule name
litvinovg Jun 12, 2023
6a5284c
formatting cleanup
litvinovg Jun 12, 2023
6f713b7
renamed attributes
litvinovg Jun 12, 2023
b4adf12
migration fixes
litvinovg Jun 12, 2023
1ac6831
naming fixes
litvinovg Jun 12, 2023
ce24a54
provide empty uri if query template doesn't use person uri
litvinovg Jun 12, 2023
54a27e7
allow self editor access to related resource pages
litvinovg Jun 12, 2023
e5e9c10
Defined order for attribute computation. Compute less expensive attri…
litvinovg Jun 12, 2023
e1a8949
fix faux object property/data property policies
litvinovg Jun 13, 2023
2293b8c
Workaround for ARM conversion: all faux properties to policy datasets…
litvinovg Jun 13, 2023
0a0c515
more fixes for faux propery access objects
litvinovg Jun 13, 2023
9a58d9e
Removed debug statements
litvinovg Jun 13, 2023
b84cde1
Fixed formatting to match maven checkstyle rules
litvinovg Aug 22, 2023
9d9caa1
Removed not used access operation ANY and object type ANY
litvinovg Aug 22, 2023
d3b7aa4
removed duplicate lines
litvinovg Aug 29, 2023
0e854e0
fixed identation
litvinovg Aug 29, 2023
5ebcde2
fixed type
litvinovg Aug 29, 2023
9f01a7c
removed unused property
litvinovg Sep 1, 2023
56fae01
refact: extracted entity attribute name constants
litvinovg Sep 1, 2023
9170d10
refact: fixed typo in method name
litvinovg Sep 1, 2023
03b6f3c
removed dead code in HasProfileFactory
litvinovg Nov 7, 2023
f2db307
format: added empty lines at the end of new java classes
litvinovg Sep 1, 2023
5225533
refact: renamed variable
litvinovg Sep 1, 2023
e836f85
fix: uncommented debug call, removed rest commented out code
litvinovg Sep 1, 2023
d9600b1
formatting: identation fixes
litvinovg Sep 1, 2023
ddc2fdb
chore: added license lines in new java classes
litvinovg Sep 1, 2023
2b2c97d
refact: created enum for rule decisions
litvinovg Sep 1, 2023
7e1bc39
Renamed class ao:Test to ao:Operator, object property ao:test to ao:o…
litvinovg Sep 1, 2023
4afeebc
fix: changed filename in test changed in previous commit
litvinovg Sep 1, 2023
736d31d
policy templates draft
litvinovg Oct 16, 2023
e9bafe0
renamed variables
litvinovg Oct 17, 2023
1c53dd1
created policy templates for: simple permissions, simple entity polic…
litvinovg Oct 19, 2023
76a86bf
renamed simple permission dataset files
litvinovg Oct 19, 2023
e50e712
finished policy to template conversion
litvinovg Oct 19, 2023
d9b6652
refact: renamed Attribute to Check
litvinovg Oct 19, 2023
ed139e2
refact: renamed Attribute to Check
litvinovg Oct 19, 2023
87e03fa
refact: renamed Attribute to Check
litvinovg Oct 19, 2023
85a502b
refact: renamed Attribute to Check
litvinovg Oct 19, 2023
d30df24
refact: renamed Attribute to Check
litvinovg Oct 20, 2023
2269f17
clean up
litvinovg Oct 20, 2023
bdf1c69
refact: renamed AttributeType to Attribute
litvinovg Oct 20, 2023
2cd695e
clean ups
litvinovg Oct 20, 2023
6cf7c16
new functionality: create data set from data set template + custom ro…
litvinovg Oct 23, 2023
5fe62f6
test for custom roles
litvinovg Oct 24, 2023
63196ec
refact: renamed resources
litvinovg Oct 24, 2023
66f1dca
multiple fixes
litvinovg Oct 24, 2023
ae93353
revert renaming
litvinovg Oct 24, 2023
2550017
Clean up jsp files
litvinovg Oct 24, 2023
35d4935
style fixes
litvinovg Oct 24, 2023
271a0d5
reorganized non modifiable statements policy template files
litvinovg Oct 24, 2023
14b5c4f
fixed policy/policy template loading
litvinovg Oct 24, 2023
3dee333
fix jsp forms to support new operations
litvinovg Oct 25, 2023
3ac16d7
fix error log for jsp controllers
litvinovg Oct 25, 2023
07f3536
Migration of custom permission sets for ARM
litvinovg Oct 25, 2023
a76edb9
checkstyle fixes
litvinovg Oct 25, 2023
699cd28
simple permission migration. Query user accounts model via OntModelSe…
litvinovg Oct 26, 2023
0f6c6a7
Revert everytime/permission_config.n3 removal
litvinovg Oct 26, 2023
812214b
improved logging, fixed policy loading
litvinovg Oct 26, 2023
597f665
Overriden toString implementation in AuthorizationRequest for log pur…
litvinovg Oct 26, 2023
348ac43
Simple permission conversion and check fixes.
litvinovg Oct 27, 2023
8eedd64
fix: check faux object property add/edit/drop permissions
litvinovg Oct 27, 2023
fd85924
shorten policy uris for authorization info
litvinovg Oct 27, 2023
33eb96a
Added attribute value container related classes to reduce number of q…
litvinovg Oct 30, 2023
20ff743
Clean ups, renamed ontology properties. Removed ontology n3 file.
litvinovg Oct 30, 2023
573bdef
fix: reload policies after migration. Write converted permissions to …
litvinovg Oct 30, 2023
1306fdd
fixed wrong type of attribute value
litvinovg Nov 1, 2023
3e4b9cc
Added access control ontology
litvinovg Nov 1, 2023
8137aec
added missed class and object property to access control ontology
litvinovg Nov 2, 2023
d8c1d39
fix for prev commit
litvinovg Nov 2, 2023
47907ed
Added comments for ontology
litvinovg Nov 3, 2023
39fddde
removed redundant access modifiers
litvinovg Nov 6, 2023
805c581
renamed variable in FileUploadController
litvinovg Nov 6, 2023
cdd9de8
Extracted method for debug messages
litvinovg Nov 6, 2023
739cc1a
removed useless condition
litvinovg Nov 6, 2023
8624d4d
Use of specific exception in CheckFactory
litvinovg Nov 6, 2023
5cbc154
removed useless condition
litvinovg Nov 6, 2023
8820608
Use optionals in ValueContainerFactory
litvinovg Nov 6, 2023
7258542
Converted Access objects to return optionals
litvinovg Nov 6, 2023
2165b2a
code style fixes
litvinovg Nov 7, 2023
e9cf3ba
renamed AccessRuleImpl to FastFailAccessRule, AccessObjectImpl to Nam…
litvinovg Nov 7, 2023
06be2af
renamed AttributeValueContainerImpl to MutableAttributeValueContainer
litvinovg Nov 7, 2023
f8769c7
Renamed AttributeValuesRegistry to AttributeValueContainerRegistry, r…
litvinovg Nov 7, 2023
b88ebc1
fix: access control ontology property range fixes
litvinovg Nov 14, 2023
31c0dc5
Added missing Configuration class and version data property configura…
litvinovg Nov 14, 2023
7b631da
Vitro value containers to allow rdfs:label property
litvinovg Nov 15, 2023
67bbb3f
increased verbosity of annotation migration
litvinovg Nov 15, 2023
642ea45
Removed attribute value set ontology class
litvinovg Nov 21, 2023
8b3d1ba
Removed Rules ontology class
litvinovg Nov 21, 2023
a3a7241
Removed PolicyDataSets ontology class
litvinovg Nov 21, 2023
741c25e
access control ontology: renamed property relatedValueSet to relatedC…
litvinovg Nov 22, 2023
b34dbe0
renamed ValueContainer to ValueSet
litvinovg Nov 22, 2023
ea3b062
refact: renamed access:defaultValue to access:hasDefaultValue
litvinovg Nov 23, 2023
e54618b
refact: renamed access:singleValue to access:value
litvinovg Nov 23, 2023
1f896c0
refact: renamed access:containerTypeTemplate to access:containsElemen…
litvinovg Nov 23, 2023
8ef6e9f
refact: renamed access:containerType to access:containsElementsOfType
litvinovg Nov 23, 2023
ccf9375
refact: renamed access:check access:requiresCheck and access:rule to …
litvinovg Nov 23, 2023
65856ba
refact: renamed access:attributeValue to access:values
litvinovg Nov 23, 2023
7763bee
refact: renamed access:Attribute to access:AttributeType
litvinovg Nov 23, 2023
f091bc3
renamed access:Value to access:AttributeValuePattern
litvinovg Nov 23, 2023
6c217e5
renamed access:hasDefaultValue to access:value
litvinovg Nov 23, 2023
ffbc30c
created access:SubjectRoleUri class for RoleUri values
litvinovg Nov 23, 2023
3701bbb
checkstyle fixes
litvinovg Nov 23, 2023
419aff7
renamed access:operator to access:useOperator
litvinovg Nov 24, 2023
ba7e91c
renamed access:policyDataSetTemplate to access:hasDataSetTemplate
litvinovg Nov 24, 2023
f173919
renamed access:policyDataSet to access:hasDataSet
litvinovg Nov 24, 2023
1164640
renamed PolicyDataSet to DataSet
litvinovg Nov 24, 2023
c72fa70
renamed :dataSetTemplateKey to hasDataSetTemplateKey
litvinovg Nov 24, 2023
9cdd825
renamed :dataSetKey to hasDataSetKey and :dataSetKeyTemplate to :hasD…
litvinovg Nov 24, 2023
c6cbfae
renamed :templateKey to hasTemplateKeyComponent
litvinovg Nov 24, 2023
dce9e8c
renamed :keyComponent to :hasKeyComponent and :keyComponentTemplate t…
litvinovg Nov 24, 2023
2354c25
renamed :dataSetValues to :hasRelatedValueSet
litvinovg Nov 24, 2023
145ac5a
Created subclasses of :AttributeValuePattern : :AttributeUriValue, :S…
litvinovg Nov 24, 2023
5d457cd
fix: reuse role value pattern if it is already exists on new data set…
litvinovg Nov 24, 2023
6423a09
Added rdfs:label as default value to object property template value sets
litvinovg Nov 24, 2023
6377d21
improved simple permission migrator logging
litvinovg Nov 24, 2023
87d63f8
fixed ARM migrator test
litvinovg Nov 24, 2023
305bea5
improved logging in PolicyDecisionLogger
litvinovg Nov 27, 2023
e6e73e3
Split editable pages policy into policy for self editors and policy f…
litvinovg Nov 29, 2023
0873154
set correct range for value property
litvinovg Nov 29, 2023
a556de2
moved proxymity query
litvinovg Nov 29, 2023
45eaf1e
Renamed property access:attribute to access:hasTypeToCheck
litvinovg Nov 29, 2023
6c65b60
Renamed property access:decision to access:hasDecision
litvinovg Nov 29, 2023
434a557
Allow rdfs:label on ARM migration
litvinovg Nov 29, 2023
978a2d5
fix: renamed Vitro value sets for rdfs:label data property
litvinovg Nov 29, 2023
3906ee4
fix: do not create of new array list on each request
litvinovg Nov 29, 2023
131ffb4
checkstyle fix for prev commit
litvinovg Nov 29, 2023
bb90596
refact: renamed authorization request variable
litvinovg Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,41 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.auth.attributes.AccessObjectType;
import edu.cornell.mannlib.vitro.webapp.auth.attributes.AccessOperation;
import edu.cornell.mannlib.vitro.webapp.auth.policy.EntityPolicyController;
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class BaseEditController extends VitroHttpServlet {

public static final boolean FORCE_NEW = true; // when you know you're starting a new edit process
public static final String ENTITY_URI_ATTRIBUTE_NAME = "_permissionsEntityURI";
public static final String ENTITY_TYPE_ATTRIBUTE_NAME = "_permissionsEntityType";

public static final boolean FORCE_NEW = true; // when you know you're starting a new edit process

public static final String JSP_PREFIX = "/templates/edit/specific/";

Expand All @@ -51,82 +58,87 @@ public class BaseEditController extends VitroHttpServlet {
private final int MAX_EPOS = 5;
private final Calendar cal = Calendar.getInstance();

/* EPO is reused if the controller is passed an epoKey, e.g.
if a previous form submission failed validation, or the edit is a multistage process. */
/*
* EPO is reused if the controller is passed an epoKey, e.g. if a previous form submission failed validation, or the
* edit is a multistage process.
*/

protected EditProcessObject createEpo(HttpServletRequest request) {
return createEpo(request, false);
return createEpo(request, false);
}

protected EditProcessObject createEpo(HttpServletRequest request, boolean forceNew) {
/* this is actually a bit of a misnomer, because we will reuse an epo
if an epoKey parameter is passed */
/*
* this is actually a bit of a misnomer, because we will reuse an epo if an epoKey parameter is passed
*/
EditProcessObject epo = null;
HashMap epoHash = getEpoHash(request);
String existingEpoKey = request.getParameter("_epoKey");
if (!forceNew && existingEpoKey != null && epoHash.get(existingEpoKey) != null) {
if (!forceNew && existingEpoKey != null && epoHash.get(existingEpoKey) != null) {
epo = (EditProcessObject) epoHash.get(existingEpoKey);
epo.setKey(existingEpoKey);
epo.setUseRecycledBean(true);
} else {
LinkedList epoKeylist = getEpoKeylist(request);
if (epoHash.size() == MAX_EPOS) {
try {
epoHash.remove(epoKeylist.getFirst());
epoKeylist.removeFirst();
} catch (Exception e) {
// see JIRA issue VITRO-340, "Odd exception from backend editing"
// possible rare concurrency issue here
log.error("Error removing old EPO", e);
}
try {
epoHash.remove(epoKeylist.getFirst());
epoKeylist.removeFirst();
} catch (Exception e) {
chenejac marked this conversation as resolved.
Show resolved Hide resolved
// see JIRA issue VITRO-340, "Odd exception from backend editing"
// possible rare concurrency issue here
log.error("Error removing old EPO", e);
}
}
Random rand = new Random();
String epoKey = createEpoKey();
while (epoHash.get(epoKey) != null) {
epoKey+=Integer.toHexString(rand.nextInt());
epoKey += Integer.toHexString(rand.nextInt());
}
epo = new EditProcessObject();
epoHash.put (epoKey,epo);
epoHash.put(epoKey, epo);
epoKeylist.add(epoKey);
epo.setKey(epoKey);
epo.setReferer( (forceNew) ? request.getRequestURL().append('?').append(request.getQueryString()).toString() : request.getHeader("Referer") );
epo.setReferer((forceNew) ? request.getRequestURL().append('?').append(request.getQueryString()).toString()
: request.getHeader("Referer"));
epo.setSession(request.getSession());
}
return epo;
}

private LinkedList getEpoKeylist(HttpServletRequest request){
private LinkedList getEpoKeylist(HttpServletRequest request) {
return (LinkedList) request.getSession().getAttribute(EPO_KEYLIST_ATTR);
}

private HashMap getEpoHash(HttpServletRequest request){
private HashMap getEpoHash(HttpServletRequest request) {
HashMap epoHash = (HashMap) request.getSession().getAttribute(EPO_HASH_ATTR);
if (epoHash == null) {
epoHash = new HashMap();
request.getSession().setAttribute(EPO_HASH_ATTR,epoHash);
//since we're making a new EPO hash, we should also make a new keylist.
request.getSession().setAttribute(EPO_HASH_ATTR, epoHash);
// since we're making a new EPO hash, we should also make a new keylist.
LinkedList epoKeylist = new LinkedList();
request.getSession().setAttribute(EPO_KEYLIST_ATTR,epoKeylist);
request.getSession().setAttribute(EPO_KEYLIST_ATTR, epoKeylist);
}
return epoHash;
}

private String createEpoKey(){
private String createEpoKey() {
return Long.toHexString(cal.getTimeInMillis());
}

protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo){
VitroRequest vreq = new VitroRequest(request);
request.setAttribute("epoKey",epo.getKey());
request.setAttribute("epo",epo);
request.setAttribute("globalErrorMsg",epo.getAttribute("globalErrorMsg"));
request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""+vreq.getAppBean().getThemeDir()+"css/edit.css\"/>");
protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo) {
VitroRequest vreq = new VitroRequest(request);
request.setAttribute("epoKey", epo.getKey());
request.setAttribute("epo", epo);
request.setAttribute("globalErrorMsg", epo.getAttribute("globalErrorMsg"));
request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""
+ vreq.getAppBean().getThemeDir() + "css/edit.css\"/>");
}

protected void populateBeanFromParams(Object bean, HttpServletRequest request) {
Map params = request.getParameterMap();
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()){
while (paramNames.hasMoreElements()) {
String key = "";
try {
key = (String) paramNames.nextElement();
Expand Down Expand Up @@ -157,9 +169,9 @@ protected void populateBeanFromParams(Object bean, HttpServletRequest request) {
}
}

public List<Option> getSortedList(HashMap<String,Option> hashMap, List<Option> optionList, VitroRequest vreq){
public List<Option> getSortedList(HashMap<String, Option> hashMap, List<Option> optionList, VitroRequest vreq) {

class ListComparator implements Comparator<String>{
class ListComparator implements Comparator<String> {

Collator collator;

Expand All @@ -174,31 +186,158 @@ public int compare(String str1, String str2) {

}

List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>();
List<String> bodyVal = new ArrayList<String>();
List<Option> options = new ArrayList<Option>();
for (Option option : optionList) {
hashMap.put(option.getBody(), option);
bodyVal.add(option.getBody());
}


bodyVal.sort(new ListComparator(vreq.getCollator()));
bodyVal.sort(new ListComparator(vreq.getCollator()));
for (String aBodyVal : bodyVal) {
options.add(hashMap.get(aBodyVal));
}
return options;
}
return options;
}

protected WebappDaoFactory getWebappDaoFactory() {
return ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY);
return ModelAccess.getInstance().getWebappDaoFactory(ASSERTIONS_ONLY);
}

protected WebappDaoFactory getWebappDaoFactory(String userURI) {
return getWebappDaoFactory().getUserAwareDaoFactory(userURI);
}

public String getDefaultLandingPage(HttpServletRequest request) {
return(request.getContextPath() + DEFAULT_LANDING_PAGE);
return (request.getContextPath() + DEFAULT_LANDING_PAGE);
}

protected static void addAccessAttributes(HttpServletRequest req, String entityURI, AccessObjectType aot) {
// Add the permissionsEntityURI (if we are creating a new property, this will be empty)
req.setAttribute(ENTITY_URI_ATTRIBUTE_NAME, entityURI);

// Get the available permission sets
List<PermissionSet> permissionSets = buildListOfSelectableRoles(ModelAccess.on(req).getWebappDaoFactory());
List<RoleInfo> roles = new ArrayList<>();
List<String> roleUris = new ArrayList<>();

for (PermissionSet permissionSet : permissionSets) {
roles.add(new RoleInfo(permissionSet));
roleUris.add(permissionSet.getUri());
}
List<AccessOperation> accessOperations = AccessOperation.getOperations(aot);
// Operation, list of roles>
Map<String, List<RoleInfo>> operationsToRoles = new LinkedHashMap<>();
for (AccessOperation operation : accessOperations) {
List<RoleInfo> roleInfos = new LinkedList<>();
String operationName = StringUtils.capitalize(operation.toString().toLowerCase());
operationsToRoles.put(operationName, roleInfos);
for (RoleInfo role : roles) {
RoleInfo roleCopy = role.clone();
roleInfos.add(roleCopy);
if (isPublicForbiddenOperation(operation)) {
if (roleCopy.isPublic) {
roleCopy.setEnabled(false);
roleCopy.setGranted(false);
}
}
}
if (!StringUtils.isEmpty(entityURI)) {
for (RoleInfo roleInfo : roleInfos) {
if (roleInfo.isEnabled()) {
roleInfo.setGranted(
EntityPolicyController.isGranted(entityURI, aot, operation, roleInfo.getUri()));
}
}
}
}
req.setAttribute("operationsToRoles", operationsToRoles);
}

static boolean isPublicForbiddenOperation(AccessOperation operation) {
return operation.equals(AccessOperation.PUBLISH);
}

public static class RoleInfo {
String uri;
String label;
private boolean enabled = true;
private boolean granted = true;
private boolean isPublic;

public RoleInfo(PermissionSet ps) {
uri = ps.getUri();
label = ps.getLabel();
isPublic = ps.isForPublic();
}

public RoleInfo(String uri, String label, boolean isPublic) {
this.uri = uri;
this.label = label;
this.isPublic = isPublic;
}

public String getUri() {
return uri;
}

public String getLabel() {
return label;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isGranted() {
return granted;
}

public void setGranted(boolean granted) {
this.granted = granted;
}

public RoleInfo clone() {
return new RoleInfo(uri, label, isPublic);
}

public boolean isPublic() {
return isPublic;
}
}

/**
* Create a list of all known PermissionSets.
*/
protected static List<PermissionSet> buildListOfSelectableRoles(WebappDaoFactory wadf) {
List<PermissionSet> permissionSets = new ArrayList<>();

// Get the non-public PermissionSets.
for (PermissionSet ps : wadf.getUserAccountsDao().getAllPermissionSets()) {
if (!ps.isForPublic()) {
permissionSets.add(ps);
}
}

// Sort the non-public PermissionSets
permissionSets.sort(new Comparator<PermissionSet>() {
@Override
public int compare(PermissionSet ps1, PermissionSet ps2) {
return ps1.getUri().compareTo(ps2.getUri());
}
});

// Add the public PermissionSets.
for (PermissionSet ps : wadf.getUserAccountsDao().getAllPermissionSets()) {
if (ps.isForPublic()) {
permissionSets.add(ps);
}
}

return permissionSets;
}
}
Loading
Loading