use of com.agiletec.aps.system.services.role.Permission in project entando-core by entando.
the class TestAuthorizationManager method testCheckAdminUser.
public void testCheckAdminUser() throws Throwable {
// nel database di test, username e password sono uguali
UserDetails adminUser = this._authenticationProvider.getUser("admin", "admin");
assertNotNull(adminUser);
assertEquals("admin", adminUser.getUsername());
assertEquals(1, adminUser.getAuthorizations().size());
List<Group> groups = this._groupManager.getGroups();
for (int i = 0; i < groups.size(); i++) {
Group group = groups.get(i);
boolean check = this._authorizationManager.isAuth(adminUser, group);
assertTrue(check);
check = this._authorizationManager.isAuthOnGroup(adminUser, group.getName());
assertTrue(check);
}
List<Permission> permissions = new ArrayList<Permission>(this._roleManager.getPermissions());
for (int i = 0; i < permissions.size(); i++) {
Permission perm = permissions.get(i);
boolean check = this._authorizationManager.isAuth(adminUser, perm);
assertTrue(check);
check = this._authorizationManager.isAuthOnPermission(adminUser, perm.getName());
assertTrue(check);
}
}
use of com.agiletec.aps.system.services.role.Permission in project entando-core by entando.
the class PermissionCacheWrapper method initCache.
@Override
public void initCache(IPermissionDAO permissionDAO) throws ApsSystemException {
try {
Cache cache = this.getCache();
this.releaseCachedObjects(cache);
Map<String, Permission> permissions = permissionDAO.loadPermissions();
this.insertObjectsOnCache(cache, permissions);
} catch (Throwable t) {
_logger.error("Error loading permissions", t);
throw new ApsSystemException("Error loading permissions", t);
}
}
use of com.agiletec.aps.system.services.role.Permission in project entando-core by entando.
the class RoleService method getPermissions.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public PagedMetadata<PermissionDto> getPermissions(RestListRequest requestList) {
List<Permission> permissions = this.getRoleManager().getPermissions();
permissions = sortPermissionList(requestList, permissions);
if (null != requestList.getFilter()) {
for (Filter f : requestList.getFilter()) {
if (f.getAttributeName().equals(KEY_FILTER_PERMISSION_CODE)) {
permissions = permissions.stream().filter(i -> i.getName().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
if (f.getAttributeName().equals(KEY_FILTER_PERMISSION_DESCR)) {
permissions = permissions.stream().filter(i -> i.getDescription().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
}
}
List<Permission> subList = requestList.getSublist(permissions);
List<PermissionDto> dtoSlice = this.getPermissionDtoBuilder().convert(subList);
SearcherDaoPaginatedResult<PermissionDto> paginatedResult = new SearcherDaoPaginatedResult(permissions.size(), dtoSlice);
PagedMetadata<PermissionDto> pagedMetadata = new PagedMetadata<>(requestList, paginatedResult);
pagedMetadata.setBody(dtoSlice);
return pagedMetadata;
}
use of com.agiletec.aps.system.services.role.Permission in project entando-core by entando.
the class AbstractApiAction method getPermissionAutorityOptions.
public List<SelectItem> getPermissionAutorityOptions() {
List<SelectItem> items = new ArrayList<SelectItem>();
try {
List<Permission> permissions = new ArrayList<Permission>();
permissions.addAll(this.getRoleManager().getPermissions());
BeanComparator comparator = new BeanComparator("description");
Collections.sort(permissions, comparator);
for (int i = 0; i < permissions.size(); i++) {
Permission permission = permissions.get(i);
items.add(new SelectItem(permission.getName(), this.getPermissionAutorityOptionPrefix() + permission.getDescription()));
}
} catch (Throwable t) {
_logger.error("Error extracting autority options", t);
}
return items;
}
use of com.agiletec.aps.system.services.role.Permission in project entando-core by entando.
the class RoleAction method getRolePermissions.
public Set<Permission> getRolePermissions() {
Set<String> permissionNames = this.getPermissionNames();
Set<Permission> rolePermissions = new HashSet<Permission>(permissionNames.size());
Iterator<String> permsIter = permissionNames.iterator();
while (permsIter.hasNext()) {
String permissionName = permsIter.next();
Permission permission = this.getRoleManager().getPermission(permissionName);
rolePermissions.add(permission);
}
return rolePermissions;
}
Aggregations