@Override public UserDetail getCreator() { if (ownerDetail == null || !ownerDetail.isFullyDefined()) { ownerDetail = UserDetail.getById(String.valueOf(owner_id)); } return ownerDetail; }
/** * Gets a user detail from this entity. * * @return a UserDetail instance. */ public UserDetail toUser() { UserDetail user = new UserDetail(); user.setId(id); if (isDefined(fullName)) { int separatorBetweenFirstAndLastName = fullName.indexOf(' '); user.setFirstName(fullName.substring(0, separatorBetweenFirstAndLastName)); user.setLastName(fullName.substring(separatorBetweenFirstAndLastName + 1)); } return user; }
private AuthorEntity(final UserDetail userDetail) { if (userDetail != null) { this.fullName = userDetail.getDisplayedName(); this.id = userDetail.getId(); this.avatar = userDetail.getAvatar(); UserPreferences prefs = getUserPreferences(); if (prefs != null) { this.language = prefs.getLanguage(); } else { this.language = DisplayI18NHelper.getDefaultLanguage(); } } }
@Override public String doAction(HttpServletRequest request) { HttpSession session = request.getSession(true); MainSessionController controller = (MainSessionController) session.getAttribute(MainSessionController.MAIN_SESSION_CONTROLLER_ATT); if (controller == null) { return "/Login.jsp"; } SettingBundle settings = ResourceLocator.getSettingBundle( "org.silverpeas.authentication.settings.passwordExpiration"); String passwordChangeURL = settings.getString("passwordChangeURL", "/defaultPasswordAboutToExpire.jsp"); UserDetail ud = controller.getCurrentUserDetail(); try { String login = ud.getLogin(); String domainId = ud.getDomainId(); String oldPassword = request.getParameter("oldPassword"); String newPassword = request.getParameter("newPassword"); AuthenticationCredential credential = AuthenticationCredential.newWithAsLogin(login) .withAsPassword(oldPassword) .withAsDomainId(domainId); AuthenticationService authenticator = AuthenticationServiceProvider.getService(); authenticator.changePassword(credential, newPassword); GraphicElementFactory gef = (GraphicElementFactory) session.getAttribute(GraphicElementFactory.GE_FACTORY_SESSION_ATT); String favoriteFrame = gef.getLookFrame(); return "/Main/" + favoriteFrame; } catch (AuthenticationException e) { SilverTrace.error( "peasCore", "effectiveChangePasswordHandler.doAction()", "peasCore.EX_USER_KEY_NOT_FOUND", e); return performUrlChangePasswordError(request, passwordChangeURL, ud); } }
public String getUserAutoRedirectURL(final String userId, final String target) { String encodedTarget = URLUtil.encodeURL(target); try { final UserDetail ud = UserDetail.getById(userId); final Domain dom = ud.getDomain(); String url; if (URLUtil.isPermalink(target)) { url = dom.getSilverpeasServerURL() + getApplicationURL() + target; } else { url = getUserAutoRedirectURL(dom) + encodedTarget; } return url; } catch (final Exception e) { SilverLogger.getLogger(this) .error( "Error while getting user auto redirect url {0} for user {1}", new String[] {target, userId}, e); return "ErrorGettingDomainServer" + encodedTarget; } }
private NodeAttrEntity(final NodeDetail node, URI uri, String lang) { this.componentId = node.getNodePK().getInstanceId(); this.id = node.getNodePK().getId(); this.uri = uri; if (node.getNbObjects() != -1) { this.nbItems = String.valueOf(node.getNbObjects()); } this.status = node.getStatus(); this.role = node.getUserRole(); this.creatorId = node.getCreatorId(); this.description = Encode.forHtml(node.getDescription(lang)); UserDetail user = UserDetail.getById(node.getCreatorId()); if (user != null) { this.creator = UserProfileEntity.fromUser(user); } try { this.creationDate = DateUtil.parse(node.getCreationDate()); } catch (ParseException e) { } }
/** * Gets the users which the value of the extra property name matches the given ones. * * @param domainId the identifier of the aimed domain. * @param propertyName the name of the aimed extra property. * @param propertyValue the value the property must verify. * @return a list of user identifiers. * @throws AdminException */ private List<String> getUserIdsBySpecificProperty( String domainId, String propertyName, String propertyValue) throws AdminException { final int domainIdAsInteger = Integer.parseInt(domainId); UserDetail[] users = new UserDetail[0]; DomainDriverManager domainDriverManager = DomainDriverManagerProvider.getCurrentDomainDriverManager(); DomainDriver domainDriver = null; try { domainDriver = domainDriverManager.getDomainDriver(domainIdAsInteger); } catch (Exception e) { reportInfo( "admin.getUserIdsBySpecificProperty", "Erreur ! Domaine " + domainId + " inaccessible !"); } if (domainDriver != null) { try { users = domainDriver.getUsersBySpecificProperty(propertyName, propertyValue); if (users == null) { reportInfo( "admin.getUserIdsBySpecificProperty", "La propriété '" + propertyName + "' n'est pas définie dans le domaine " + domainId); } } catch (Exception e) { if (e instanceof AdminException) { Throwable cause = e.getCause(); if (cause instanceof LDAPLocalException || cause instanceof org.ietf.ldap.LDAPLocalException) { reportInfo( "admin.getUserIdsBySpecificProperty", "Domain " + domainId + ": " + cause.toString()); } else { throw (AdminException) e; } } else { throw new AdminException(failureOnGetting("users by property", propertyName), e); } } } List<String> specificIds = new ArrayList<>(); if (users != null) { for (UserDetail user : users) { specificIds.add(user.getSpecificId()); } } // We have to find users according to theirs specificIds UserRow[] usersInDomain = domainDriverManager .getOrganization() .user .getUsersBySpecificIds(domainIdAsInteger, specificIds); List<String> userIds = new ArrayList<>(); if (usersInDomain != null) { for (UserRow userInDomain : usersInDomain) { userIds.add(Integer.toString(userInDomain.id)); } } return userIds; }
/** * Indicates if the current user is authorized to perform this upload session. * * @param componentInstanceId */ public boolean isUserAuthorized(final String componentInstanceId) { return StringUtil.isDefined(getComponentInstanceId()) && getComponentInstanceId().equals(componentInstanceId) && getAccessController(ComponentAccessControl.class) .isUserAuthorized(UserDetail.getCurrentRequester().getId(), componentInstanceId); }
@Override public void onDeletion(final UserEvent event) throws Exception { UserDetail user = event.getTransition().getBefore(); kmeliaService.userHaveBeenDeleted(user.getId()); }
/** * Is the specified user can access this comment? * * <p>A user can access a comment if it has enough rights to access the application instance in * which is managed this comment. * * <p>Be caution, the access control on the commented resource is usually more reliable than using * this method. * * @param user a user in Silverpeas. * @return true if the user can access this comment, false otherwise. */ @Override public boolean canBeAccessedBy(final UserDetail user) { AccessController<String> accessController = AccessControllerProvider.getAccessController(ComponentAccessControl.class); return accessController.isUserAuthorized(user.getId(), getComponentInstanceId()); }
public String getUserAutoRedirectSilverpeasServerURL(final String userId) { final UserDetail ud = UserDetail.getById(userId); final Domain dom = ud.getDomain(); String url = dom.getSilverpeasServerURL() + getApplicationURL(); return url; }