use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class UserControllerUnitTest method mockedRole.
private Role mockedRole() {
Role role = new Role();
role.setDescription("descr1");
role.setName("role1");
return role;
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class AuthorizationManager method isAuthOnSinglePermission.
private boolean isAuthOnSinglePermission(UserDetails user, String permissionName) {
if (null == user) {
return false;
}
List<Role> rolesWithPermission = this.getRolesWithPermission(user, permissionName);
for (int i = 0; i < rolesWithPermission.size(); i++) {
Role role = rolesWithPermission.get(i);
boolean check = this.checkAuth(user, role.getAuthority(), true);
if (check) {
return true;
}
}
return false;
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class AuthorizationManager method isAuthOnGroupAndPermission.
@Override
public boolean isAuthOnGroupAndPermission(UserDetails user, String groupName, String permissionName, boolean chechAdmin) {
if (null == user || null == groupName || null == permissionName) {
return false;
}
List<Role> roles = new ArrayList<Role>();
List<Role> rolesWithPermission = this.getRoleManager().getRolesWithPermission(permissionName);
if (null != rolesWithPermission) {
roles.addAll(rolesWithPermission);
}
if (chechAdmin) {
List<Role> rolesWithSupPermission = this.getRoleManager().getRolesWithPermission(Permission.SUPERUSER);
if (null != rolesWithSupPermission) {
roles.addAll(rolesWithSupPermission);
}
}
for (int i = 0; i < roles.size(); i++) {
Role role = roles.get(i);
if (null != role) {
boolean check = this.isAuthOnGroupAndRole(user, groupName, role.getName(), chechAdmin);
if (check) {
return true;
}
}
}
return false;
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class AuthorizationManager method addUserAuthorization.
@Override
public void addUserAuthorization(String username, String groupName, String roleName) throws ApsSystemException {
try {
Group group = (null != groupName) ? this.getGroupManager().getGroup(groupName) : null;
if (null != groupName && null == group) {
_logger.warn("invalid authorization - invalid referenced group name");
return;
}
Role role = (null != roleName) ? this.getRoleManager().getRole(roleName) : null;
if (null != roleName && null == role) {
_logger.warn("invalid authorization - invalid referenced role name");
return;
}
Authorization authorization = new Authorization(group, role);
this.addUserAuthorization(username, authorization);
} catch (Throwable t) {
_logger.error("Error adding user authorization for user '{}'", username, t);
throw new ApsSystemException("Error adding user authorization for user " + username, t);
}
}
use of com.agiletec.aps.system.services.role.Role in project entando-core by entando.
the class AuthorizationManager method getUserAuthorizations.
@Override
public List<Authorization> getUserAuthorizations(String username) throws ApsSystemException {
List<Authorization> authorizations = null;
try {
Map<String, Group> groups = (Map<String, Group>) this.getAuthorityMap(this.getGroupManager().getGroups());
Map<String, Role> roles = (Map<String, Role>) this.getAuthorityMap(this.getRoleManager().getRoles());
authorizations = this.getAuthorizationDAO().getUserAuthorizations(username, groups, roles);
} catch (Throwable t) {
_logger.error("Error extracting user authorizations for user '{}'", username, t);
throw new ApsSystemException("Error extracting user authorizations for user " + username, t);
}
return authorizations;
}
Aggregations