use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class ActivityStreamTag method doEndTag.
@Override
public int doEndTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
try {
IActionLogManager loggerManager = (IActionLogManager) ApsWebApplicationUtils.getBean(SystemConstants.ACTION_LOGGER_MANAGER, this.pageContext);
UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
List<Integer> ids = loggerManager.getActivityStream(currentUser);
if (null != this.getVar()) {
ValueStack stack = this.getStack();
stack.getContext().put(this.getVar(), ids);
stack.setValue("#attr['" + this.getVar() + "']", ids, false);
}
} catch (Throwable t) {
_logger.error("Error on doStartTag", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag");
throw new JspException("Error on doStartTag", t);
}
return super.doEndTag();
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class GroupsByPermissionTag method getAllowedGroups.
protected Set<String> getAllowedGroups() {
Set<String> groupCodes = new HashSet<String>();
UserDetails currentUser = (UserDetails) this.pageContext.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
String permissionName = this.getPermission();
if (null != currentUser && null != permissionName) {
IAuthorizationManager authManager = (IAuthorizationManager) ApsWebApplicationUtils.getBean(SystemConstants.AUTHORIZATION_SERVICE, this.pageContext);
List<Group> groupsByPermission = authManager.getGroupsByPermission(currentUser, permissionName);
if (null != groupsByPermission) {
for (Group group : groupsByPermission) {
if (null != group) {
groupCodes.add(group.getName());
}
}
}
}
return groupCodes;
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class ShortcutListTag method doStartTag.
@Override
public int doStartTag() throws JspException {
UserDetails currentUser = (UserDetails) this.pageContext.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
try {
Object retval = null;
IShortcutManager shortcutManager = (IShortcutManager) ApsWebApplicationUtils.getBean(ApsAdminSystemConstants.SHORTCUT_MANAGER, this.pageContext);
List<Shortcut> myShortcuts = shortcutManager.getAllowedShortcuts(currentUser);
if (this.getType().equalsIgnoreCase(TYPE_LIST_OBJECT)) {
retval = (Object) myShortcuts;
} else if (this.getType().equalsIgnoreCase(TYPE_LIST_ITEMS)) {
retval = (Object) this.getAllowedShortcutSelectItems(myShortcuts, currentUser);
} else {
_logger.warn("Invalid param for attribute 'value'. Expected '{}' or '{}' but was {}", TYPE_LIST_ITEMS, TYPE_LIST_OBJECT, this.getType());
}
ValueStack stack = super.getStack();
stack.getContext().put(this.getVar(), retval);
stack.setValue("#attr['" + this.getVar() + "']", retval, false);
} catch (Throwable t) {
_logger.error("Error extracting shortcuts for user '{}'", currentUser.getUsername(), t);
throw new JspException("Error extracting shortcuts", t);
}
return super.doStartTag();
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class UserAction method validate.
@Override
public void validate() {
super.validate();
if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
this.checkAddUserUser();
} else {
try {
if (this.hasActionErrors() || this.hasErrors() || this.hasFieldErrors()) {
String username = this.getUsername();
UserDetails user = this.getUserManager().getUser(username);
this.setUser(user);
}
} catch (Throwable t) {
_logger.error("Error validating user", t);
}
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class ApsAdminBaseTestCase method setUserOnSession.
protected void setUserOnSession(String username) throws Exception {
if (null == username) {
this.removeUserOnSession();
return;
}
// nel database di test, username e password sono uguali
UserDetails currentUser = this.getUser(username, username);
HttpSession session = this._request.getSession();
session.setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, currentUser);
}
Aggregations