use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class TestShortcutManager method testGetAllowedShortcuts.
public void testGetAllowedShortcuts() throws Throwable {
assertNotNull(this._shortcutManager);
String expectedShortcut = "core.tools.setting";
UserDetails adminUser = super.getUser("admin");
List<Shortcut> shortcuts = this._shortcutManager.getAllowedShortcuts(adminUser);
assertTrue(this.containsShortcut(shortcuts, expectedShortcut));
UserDetails editorCoach = super.getUser("editorCoach");
shortcuts = this._shortcutManager.getAllowedShortcuts(editorCoach);
assertFalse(this.containsShortcut(shortcuts, expectedShortcut));
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class NavigatorParser method parseSpec.
/**
* Crea e restituisce una lista di oggetti NavigatorTarget, che wrappano
* pagine del portale e possono essere utilizzati dai sub-tag.
*
* @param spec L'espressione usata la specificazione delle pagine da
* selezionare; possono essere assolute o relative o miste.
* @param reqCtx Il contesto della richiesta corrente.
* @return La lista di oggetti NavigatorTarget.
*/
@Override
public List<NavigatorTarget> parseSpec(String spec, RequestContext reqCtx) {
IPage currentPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
UserDetails currentUser = (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
return this.parseSpec(spec, currentPage, currentUser);
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class CheckPermissionTag method doStartTag.
@Override
public int doStartTag() throws JspException {
HttpSession session = this.pageContext.getSession();
try {
boolean isAuthorized = false;
UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
IAuthorizationManager authManager = (IAuthorizationManager) ApsWebApplicationUtils.getBean(SystemConstants.AUTHORIZATION_SERVICE, this.pageContext);
boolean isGroupSetted = StringUtils.isNotEmpty(this.getGroupName());
boolean isPermissionSetted = StringUtils.isNotEmpty(this.getPermission());
boolean isAuthGr = isGroupSetted && (authManager.isAuthOnGroup(currentUser, this.getGroupName()) || authManager.isAuthOnGroup(currentUser, Group.ADMINS_GROUP_NAME));
boolean isAuthPerm = isPermissionSetted && (authManager.isAuthOnPermission(currentUser, this.getPermission()) || authManager.isAuthOnPermission(currentUser, Permission.SUPERUSER));
if (isGroupSetted && !isPermissionSetted) {
isAuthorized = isAuthGr;
} else if (!isGroupSetted && isPermissionSetted) {
isAuthorized = isAuthPerm;
} else if (isGroupSetted && isPermissionSetted && isAuthGr && isAuthPerm) {
isAuthorized = authManager.isAuthOnGroupAndPermission(currentUser, this.getGroupName(), this.getPermission(), true);
}
if (null != this.getVar()) {
this.pageContext.setAttribute(this.getVar(), isAuthorized);
}
if (isAuthorized) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
}
} catch (Throwable t) {
_logger.error("Error during tag initialization", t);
throw new JspException("Error during tag initialization ", t);
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class ContentInfoTag method doStartTag.
@Override
public int doStartTag() throws JspException {
int result = super.doStartTag();
try {
if (null != this.getMasterObject()) {
HttpSession session = this.pageContext.getSession();
UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
IContentAuthorizationHelper contentAuthHelper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
boolean isAuthOnEdit = false;
if (this.isRecord()) {
// PENSARE ALL'OPPORTUNITA'... meno prestante nel caso di oggetto contenuto!
String keyValue = (String) super.findValue(this.getKey(), String.class);
isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, keyValue, false);
} else {
isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, (Content) this.getMasterObject());
}
if (isAuthOnEdit) {
if (null != this.getAuthToEditVar()) {
ValueStack stack = this.getStack();
stack.getContext().put(this.getAuthToEditVar(), isAuthOnEdit);
stack.setValue("#attr['" + this.getAuthToEditVar() + "']", isAuthOnEdit, false);
}
result = EVAL_BODY_INCLUDE;
}
}
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag", "Error on doStartTag");
throw new JspException("Error on doStartTag", t);
}
return result;
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class ContentTypeInfoTag method getPropertyValue.
@Override
protected Object getPropertyValue(Object masterObject, String propertyValue) {
if (null == propertyValue || !propertyValue.equals("isAuthToEdit")) {
return super.getPropertyValue(masterObject, propertyValue);
}
try {
HttpSession session = this.pageContext.getSession();
UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
Content prototype = (Content) masterObject;
IContentAuthorizationHelper helper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
return helper.isAuthToEdit(currentUser, prototype);
} catch (Throwable t) {
_logger.error("Error extracting property value : Master Object '{}' - property '{}'", masterObject.getClass().getName(), propertyValue, t);
}
return null;
}
Aggregations