use of com.agiletec.aps.system.services.authorization.IAuthorizationManager in project entando-core by entando.
the class AbstractWidgetExecutorService method isUserAllowed.
protected boolean isUserAllowed(RequestContext reqCtx, Widget widget) {
if (null == widget) {
return false;
}
String widgetTypeGroup = widget.getType().getMainGroup();
try {
if (null == widgetTypeGroup || widgetTypeGroup.equals(Group.FREE_GROUP_NAME)) {
return true;
}
IAuthorizationManager authorizationManager = (IAuthorizationManager) ApsWebApplicationUtils.getBean(SystemConstants.AUTHORIZATION_SERVICE, reqCtx.getRequest());
UserDetails currentUser = (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
return authorizationManager.isAuthOnGroup(currentUser, widgetTypeGroup);
} catch (Throwable t) {
_logger.error("Error checking user authorities", t);
}
return false;
}
use of com.agiletec.aps.system.services.authorization.IAuthorizationManager in project entando-core by entando.
the class PreviewRequestAuthorizator method isAllowed.
private boolean isAllowed(UserDetails currentUser, IPage currentPage, HttpServletRequest request) {
boolean isValid = false;
IAuthorizationManager authManager = this.getAuthManager();
if (authManager.isAuthOnPermission(currentUser, Permission.SUPERUSER)) {
isValid = true;
} else {
String token = request.getParameter("token");
if (StringUtils.isNotEmpty(token)) {
String result = this.getPageTokenMager().decrypt(token);
if (result != null && currentPage != null && result.equals(currentPage.getCode())) {
isValid = true;
}
}
}
if (isValid) {
isValid = authManager.isAuth(currentUser, currentPage);
}
return isValid;
}
use of com.agiletec.aps.system.services.authorization.IAuthorizationManager in project entando-core by entando.
the class ContentWrapper method isUserAllowed.
public boolean isUserAllowed(String permissionName) {
try {
IAuthorizationManager authManager = (IAuthorizationManager) this.getBeanFactory().getBean(SystemConstants.AUTHORIZATION_SERVICE);
UserDetails currentUser = (UserDetails) this.getReqCtx().getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
if (null == currentUser)
return false;
if (!authManager.isAuthOnGroup(currentUser, this.getEntity().getMainGroup()))
return false;
if (null != permissionName && permissionName.trim().length() > 0 && !authManager.isAuthOnPermission(currentUser, permissionName))
return false;
} catch (Throwable t) {
_logger.error("Error checking authority - permission {}", permissionName, t);
// ApsSystemUtils.logThrowable(t, this, "isUserAllowed", "Error checking authority - permission " + permissionName);
return false;
}
return true;
}
Aggregations