Package ch.entwine.weblounge.common.security

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


    if (site == null) {
      logger.error("Site context not available during user lookup");
      throw new UsernameNotFoundException("No site context available");
    }

    User user = loadUser(name, site);
    if (user == null) {
      throw new UsernameNotFoundException(name);
    } else {

      // By default, add the anonymous role so the user is able to access
      // publicly available resources
      user.addPublicCredentials(SystemRole.GUEST);

      // Collect the set of roles (granted authorities) for this users
      Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
      for (Object o : user.getPublicCredentials(Role.class)) {
        Role masterRole = (Role) o;
        for (Role r : masterRole.getClosure()) {
          authorities.add(new SimpleGrantedAuthority(r.getContext() + ":" + r.getIdentifier()));

          // Every role may or may not be a system role or - in case of non-
          // system roles, may or may not be including one or more of those
          // roles. Let's ask for a translation and then add those roles
          // to the set of granted authorities
          Role[] systemEquivalents = getSystemRoles(r);
          for (Role systemRole : systemEquivalents) {
            authorities.add(new SimpleGrantedAuthority(systemRole.getContext() + ":" + systemRole.getIdentifier()));
            user.addPublicCredentials(systemRole);
          }
        }
      }

      // Make sure there is no ambiguous information with regards to passwords
      Set<Object> passwords = user.getPrivateCredentials(Password.class);
      if (passwords.size() > 1) {
        logger.warn("User '{}@{}' has more than one password'", name, site.getIdentifier());
        throw new DataRetrievalFailureException("User '" + user + "' has more than one password");
      } else if (passwords.size() == 0) {
        logger.warn("User '{}@{}' has no password", name, site.getIdentifier());
View Full Code Here


    // Authentication can be null, e. g. if a user presses "logout" even though
    // his session has already been expired
    if (authentication != null) {
      Object principal = authentication.getPrincipal();
      if (!(principal instanceof SpringSecurityUser)) {
        User user = ((SpringSecurityUser) principal).getUser();
        logger.info("User '{}' logged out", user);
      } else {
        logger.info("User '{}' logged out", authentication.getName());
      }
    }
View Full Code Here

   *
   * @see ch.entwine.weblounge.common.content.Modifiable#getLastModifier()
   */
  @Override
  public User getLastModifier() {
    User user = getModifier();
    if (user != null)
      return user;
    user = getPublisher();
    if (user != null)
      return user;
View Full Code Here

   *
   * @see ch.entwine.weblounge.common.content.Modifiable#getLastModifier()
   */
  @Override
  public User getLastModifier() {
    User user = getModifier();
    if (user != null)
      return user;
    user = getPublisher();
    if (user != null)
      return user;
View Full Code Here

   *
   * @see ch.entwine.weblounge.common.content.Modifiable#getLastModifier()
   */
  @Override
  public User getLastModifier() {
    User user = getModifier();
    if (user != null)
      return user;
    user = getPublisher();
    if (user != null)
      return user;
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.content.Resource#unlock()
   */
  public User unlock() {
    User previousLockOwner = lockOwner;
    lockOwner = null;
    return previousLockOwner;
  }
View Full Code Here

    // Check for existing administrative accounts with the same login
    ServiceReference userDirectoryRef = bundleCtx.getServiceReference(DirectoryService.class.getName());
    if (userDirectoryRef != null) {
      DirectoryService systemDirectory = (DirectoryService) bundleCtx.getService(userDirectoryRef);
      logger.debug("Checking new site '{}' user '{}' for shadowing of site or system account");
      User shadowedUser = systemDirectory.loadUser(user, site);
      if (shadowedUser != null) {
        if (SecurityUtils.userHasRole(shadowedUser, SYSTEMADMIN))
          throw new UserShadowedException("Site '" + site.getIdentifier() + "' account '" + user + "' is shadowing the system account");
        else if (SecurityUtils.userHasRole(shadowedUser, SITEADMIN))
          throw new UserShadowedException("Site '" + site.getIdentifier() + "' account '" + user + "' is shadowing the site account");
View Full Code Here

   *
   * @see ch.entwine.weblounge.common.content.Modifiable#getLastModifier()
   */
  @Override
  public User getLastModifier() {
    User user = getModifier();
    if (user != null)
      return user;
    user = getPublisher();
    if (user != null)
      return user;
View Full Code Here

        b.append(" original=\"true\">");
      else
        b.append(">");

      b.append("<modified>");
      User u = modificationCtx.getModifier(l);
      if (u == null)
        u = uri.getSite().getAdministrator();
      b.append(u.toXml());
      b.append("<date>");
      Date d = modificationCtx.getModificationDate(l);
      if (d == null)
        d = new Date();
      b.append(WebloungeDateFormat.formatStatic(d));
View Full Code Here

   *
   * @see ch.entwine.weblounge.common.content.Modifiable#getLastModifier()
   */
  @Override
  public User getLastModifier() {
    User user = getModifier();
    if (user != null)
      return user;
    user = getPublisher();
    if (user != null)
      return user;
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.