Package ch.entwine.weblounge.common.security

Examples of ch.entwine.weblounge.common.security.User


   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {
    if (obj instanceof User) {
      User u = (User) obj;
      if (realm != null && !realm.equals(u.getRealm()))
        return false;
      if (u.getRealm() != null && realm == null)
        return false;
      return login.equals(u.getLogin());
    }
    return super.equals(obj);
  }
View Full Code Here


   *
   * @param owner
   *          the context owner
   */
  public void setOwner(User owner) {
    User oldOwner = securityCtx.getOwner();
    securityCtx.setOwner(owner);
    fireOwnerChanged(owner, oldOwner);
  }
View Full Code Here

   * @see #switchTo(Language)
   * @see #switchTo(Language, boolean)
   */
  public User getModifier() {
    Language currentLanguage = getLanguage();
    User modifier = null;
    if (currentLanguage != null) {
      Modification c = modifications.get(currentLanguage);
      if (c != null)
        modifier = c.getUser();
    }
View Full Code Here

    if (lastModifier != null)
      return lastModifier;

    // First time calculation
    Date date = null;
    User user = null;
    for (Modification m : modifications.values()) {
      if (date == null || m.getDate().after(date)) {
        date = m.getDate();
        user = m.getUser();
      }
View Full Code Here

      // Modifying user
      Node modifierNode = XPathHelper.select(locale, "modified/user", xpath);
      if (modifierNode == null)
        throw new IllegalStateException("Modifier cannot be null");
      User modifier = UserImpl.fromXml(modifierNode, xpath);

      // Modification date
      String date = XPathHelper.valueOf(locale, "modified/date", xpath);
      if (date == null)
        throw new IllegalStateException("Date cannot be null");
View Full Code Here

                // Make sure the system admin account is not shadowed
                if (site.getAdministrator() != null) {
                  ServiceReference userDirectoryRef = bundleContext.getServiceReference(SystemDirectory.class.getName());
                  if (userDirectoryRef != null) {
                    SystemDirectory systemDirectory = (SystemDirectory) bundleContext.getService(userDirectoryRef);
                    User siteAdmin = site.getAdministrator();
                    if (siteAdmin != null) {
                      logger.debug("Checking site '{}' admin user '{}' for shadowing of system account");
                      User shadowedUser = systemDirectory.loadUser(siteAdmin.getLogin(), site);
                      if (shadowedUser != null && SecurityUtils.userHasRole(shadowedUser, SystemRole.SYSTEMADMIN)) {
                        throw new IllegalStateException("Site '" + site.getIdentifier() + "' administrative account '" + siteAdmin.getLogin() + "' is shadowing the system account");
                      }
                    }
                  } else {
View Full Code Here

    // creator, modifier
    if ("user".equals(raw)) {
      String login = (String) clipboard.remove("user");
      String realm = (String) clipboard.remove("realm");
      String name = getCharacters();
      User user = new UserImpl(login, realm, name);
      clipboard.put("user", user);
    }

    // date
    else if ("date".equals(raw)) {
      try {
        Date d = dateFormat.parse(getCharacters());
        clipboard.put("date", d);
      } catch (ParseException e) {
        throw new IllegalStateException("Reading date failed: '" + getCharacters() + "'");
      }
    }

    // publishing start date
    else if (contentReaderContext == Context.Publish && "from".equals(raw)) {
      try {
        Date d = dateFormat.parse(getCharacters());
        clipboard.put("publish.start", d);
      } catch (ParseException e) {
        throw new IllegalStateException("Reading publishing start date failed: '" + getCharacters() + "'");
      }
    }

    // publishing end date
    else if (contentReaderContext == Context.Publish && "to".equals(raw)) {
      try {
        Date d = dateFormat.parse(getCharacters());
        if (d.getTime() < Times.MAX_DATE)
          clipboard.put("publish.end", d);
      } catch (ParseException e) {
        throw new IllegalStateException("Reading publishing end date failed: '" + getCharacters() + "'");
      }
    }

    // created
    else if (contentReaderContext == Context.Creation && "created".equals(raw)) {
      User owner = (User) clipboard.remove("user");
      Date date = (Date) clipboard.remove("date");
      if (date == null)
        throw new IllegalStateException("Creation date not found");
      setCreated(owner, date);
      contentReaderContext = Context.Unknown;
    }

    // modified
    else if (contentReaderContext == Context.Modification && "modified".equals(raw)) {
      User modifier = (User) clipboard.remove("user");
      Date date = (Date) clipboard.remove("date");
      if (date == null)
        throw new IllegalStateException("Modification date not found");
      setModified(modifier, date);
      contentReaderContext = Context.Unknown;
    }

    // published
    else if (contentReaderContext == Context.Publish && "published".equals(raw)) {
      User publisher = (User) clipboard.remove("user");
      Date startDate = (Date) clipboard.remove("publish.start");
      if (startDate == null)
        throw new IllegalStateException("Publication start date not found");
      Date endDate = (Date) clipboard.remove("publish.end");
      setPublished(publisher, startDate, endDate);
      contentReaderContext = Context.Unknown;
    }

    // owner
    else if (contentReaderContext == Context.Security && "owner".equals(raw)) {
      User owner = (User) clipboard.remove("user");
      if (owner == null)
        throw new IllegalStateException("Owner not found");
      setOwner(owner);
    }
View Full Code Here

   */
  public int doStartTag() throws JspException {
    super.doStartTag();

    WebloungeRequest request = getRequest();
    User user = request.getUser();
    Site site = request.getSite();
    if (hasOneOf(user, site) && hasAllOf(user, site))
      return EVAL_BODY_INCLUDE;
    else
      return SKIP_BODY;
View Full Code Here

   * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag()
   */
  @Override
  public int doStartTag() throws JspException {
    super.doStartTag();
    User user = getRequest().getUser();

    // If the user object is Guest, no more questions will be asked
    if (user instanceof Guest)
      return SKIP_BODY;

    // If the user has more than one role, or that one role is not
    // SystemRole.Guest, we are on the safe side
    Set<Object> roles = user.getPublicCredentials(Role.class);
    if (roles.size() > 1 || !SecurityUtils.userHasRole(user, SystemRole.GUEST))
      return SKIP_BODY;

    return EVAL_BODY_INCLUDE;
  }
View Full Code Here

   */
  public int doStartTag() throws JspException {
    super.doStartTag();

    WebloungeRequest request = getRequest();
    User user = request.getUser();
    Site site = request.getSite();
    if (!hasOneOf(user, site) || !hasAllOf(user, site))
      return EVAL_BODY_INCLUDE;
    else
      return SKIP_BODY;
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.security.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.