use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class CurrentUserProfileAction method edit.
@Override
public String edit() {
try {
IUserProfile userProfile = null;
UserDetails currentUser = this.getCurrentUser();
Object object = currentUser.getProfile();
if (null != object && object instanceof IUserProfile) {
// String username = currentUser.getUsername();
// this.getUserProfileManager().getProfile(username);
userProfile = (IUserProfile) object;
this.checkTypeLabels(userProfile);
} else {
return "currentUserWithoutProfile";
}
IUserProfile currentProfile = this.getUserProfile();
if (null == currentProfile || !currentProfile.getUsername().equals(currentUser.getUsername())) {
userProfile.disableAttributes(SystemConstants.USER_PROFILE_ATTRIBUTE_DISABLING_CODE_ON_EDIT);
this.getRequest().getSession().setAttribute(SESSION_PARAM_NAME_CURRENT_PROFILE, userProfile);
}
} catch (Throwable t) {
_logger.error("error in edit", t);
// ApsSystemUtils.logThrowable(t, this, "edit");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class UserShortcutsConfigTag method doEndTag.
@Override
public int doEndTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
try {
UserConfigBean config = (UserConfigBean) request.getSession().getAttribute(MyShortcutConfigAction.SESSION_PARAM_MY_SHORTCUTS);
UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
if (null == config || !currentUser.getUsername().equals(config.getUsername())) {
request.getSession().removeAttribute(MyShortcutConfigAction.SESSION_PARAM_MY_SHORTCUTS);
IShortcutManager shortcutManager = (IShortcutManager) ApsWebApplicationUtils.getBean(ApsAdminSystemConstants.SHORTCUT_MANAGER, this.pageContext);
config = shortcutManager.getUserConfigBean(currentUser);
}
if (null != this.getVar()) {
ValueStack stack = this.getStack();
stack.getContext().put(this.getVar(), config);
stack.setValue("#attr['" + this.getVar() + "']", config, false);
}
} catch (Throwable t) {
_logger.error("Error on doStartTag", t);
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 DispatchAction method validate.
@Override
public void validate() {
super.validate();
if (this.hasFieldErrors())
return;
_logger.debug("Authentication : user {} - password ******** ", this.getUsername());
UserDetails user = null;
try {
user = this.getAuthenticationProvider().getUser(this.getUsername(), this.getPassword());
} catch (Throwable t) {
_logger.error("error in LoginAction ", t);
throw new RuntimeException("Login error : username " + this.getUsername(), t);
}
if (null == user) {
_logger.debug("Login failed : username {} - password ******** ", this.getUsername());
this.addActionError(this.getText("error.user.login.loginFailed"));
} else {
// UTENTE RICONOSCIUTO ED ATTIVO
if (!user.isAccountNotExpired()) {
this.addActionError(this.getText("error.user.login.accountExpired"));
this.getSession().removeAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
return;
}
this.getSession().setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, user);
if (!user.isCredentialsNotExpired()) {
this.addActionError(this.getText("error.user.login.credentialsExpired"));
return;
}
if (this.getAuthorizationManager().isAuthOnPermission(user, Permission.SUPERUSER) || this.getAuthorizationManager().isAuthOnPermission(user, Permission.BACKOFFICE)) {
_logger.info("User - {} logged", user.getUsername());
} else {
this.addActionError(this.getText("error.user.login.userNotAbilitated"));
}
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class PageFinderAction method getAllowedGroupCodes.
private List<String> getAllowedGroupCodes() {
List<String> allowedGroups = new ArrayList<String>();
UserDetails currentUser = this.getCurrentUser();
List<Group> userGroups = this.getAuthorizationManager().getUserGroups(currentUser);
Iterator<Group> iter = userGroups.iterator();
while (iter.hasNext()) {
Group group = iter.next();
allowedGroups.add(group.getName());
}
return allowedGroups;
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class PagePreviewAction method preview.
public String preview() {
try {
String ERR_RESULT = "apslogin";
if (null == this.getCurrentUser()) {
UserDetails guest = this.getUserManager().getGuestUser();
this.getRequest().getSession().setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, guest);
}
if (StringUtils.isBlank(this.getPageCode())) {
_logger.info("Null page code");
this.addActionError(this.getText("error.page.invalidPageCode"));
return ERR_RESULT;
}
if (!isCurrentUserAdmin()) {
boolean isValidToken = this.checkToken(this.getToken(), this.getPageCode());
if (!isValidToken) {
_logger.info("Invalid token");
this.addActionError(this.getText("error.page.invalidPreviewToken"));
return ERR_RESULT;
}
}
IPage page = this.getPage(this.getPageCode());
if (!this.getAuthorizationManager().isAuth(this.getCurrentUser(), page)) {
_logger.info("Curent user not allowed");
this.addActionError(this.getText("error.page.userNotAllowed"));
return ERR_RESULT;
}
if (null == page) {
_logger.info("Null page code");
this.addActionError(this.getText("error.page.invalidPageCode"));
return ERR_RESULT;
}
if (null == this.getLangManager().getLang(this.getLang())) {
String defaultLangCode = this.getLangManager().getDefaultLang().getCode();
_logger.warn("Invalid lang '{}' detected. Defaulting to '{}'", this.getLang(), defaultLangCode);
this.setLang(defaultLangCode);
}
} catch (Exception e) {
_logger.error("error in preview", e);
return FAILURE;
}
return SUCCESS;
}
Aggregations