Package ch.entwine.weblounge.common.impl.security

Examples of ch.entwine.weblounge.common.impl.security.UserImpl


    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    User user = null;
    Set<Role> roles = new HashSet<Role>();

    if (!securityService.isEnabled()) {
      user = new UserImpl(Security.ADMIN_USER, Security.SYSTEM_CONTEXT, Security.ADMIN_NAME);
      roles.add(SystemRole.SYSTEMADMIN);
      roles.add(getLocalRole(site, SystemRole.SYSTEMADMIN));
    } else if (auth == null) {
      logger.debug("No spring security context available, setting current user to anonymous");
      String realm = site != null ? site.getIdentifier() : Security.SYSTEM_CONTEXT;
      user = new UserImpl(Security.ANONYMOUS_USER, realm, Security.ANONYMOUS_NAME);
      roles.add(SystemRole.GUEST);
      roles.add(getLocalRole(site, SystemRole.GUEST));
    } else {
      Object principal = auth.getPrincipal();
      if (principal == null) {
        logger.warn("No principal found in spring security context, setting current user to anonymous");
        user = new Guest(site.getIdentifier());
        roles.add(getLocalRole(site, SystemRole.GUEST));
      } else if (principal instanceof SpringSecurityUser) {
        user = ((SpringSecurityUser) principal).getUser();
        logger.debug("Principal was identified as '{}'", user.getLogin());
      } else if (principal instanceof UserDetails) {
        UserDetails userDetails = (UserDetails) principal;
        user = new UserImpl(userDetails.getUsername());
        logger.debug("Principal was identified as '{}'", user.getLogin());

        Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
        if (authorities != null && authorities.size() > 0) {
          for (GrantedAuthority ga : authorities) {
View Full Code Here


   */
  public void setUser(User user) {
    if (user == null)
      userHolder.set(null);
    else
      userHolder.set(new UserImpl(user));
    extendedUserHolder.set(user);
  }
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.content.Creatable#getCreator()
   */
  public User getCreator() {
    return new UserImpl(uri.getSite().getAdministrator());
  }
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.content.Modifiable#getModifier()
   */
  public User getModifier() {
    return new UserImpl(uri.getSite().getAdministrator());
  }
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.content.Publishable#getPublisher()
   */
  public User getPublisher() {
    return new UserImpl(uri.getSite().getAdministrator());
  }
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.security.Securable#getOwner()
   */
  public User getOwner() {
    return new UserImpl(uri.getSite().getAdministrator());
  }
View Full Code Here

   * {@link ch.entwine.weblounge.common.impl.content.SearchQueryImpl#withAuthor(ch.entwine.weblounge.common.security.User)}
   * .
   */
  @Test
  public void testWithAuthor() {
    User author = new UserImpl("john");
    query.withAuthor(author);
    assertEquals(author, query.getAuthor());
  }
View Full Code Here

   * {@link ch.entwine.weblounge.common.impl.content.SearchQueryImpl#withCreator(ch.entwine.weblounge.common.security.User)}
   * .
   */
  @Test
  public void testWithCreator() {
    User author = new UserImpl("john");
    query.withAuthor(author);
    assertEquals(author, query.getAuthor());
  }
View Full Code Here

   * {@link ch.entwine.weblounge.common.impl.content.SearchQueryImpl#withModifier(ch.entwine.weblounge.common.security.User)}
   * .
   */
  @Test
  public void testWithModifier() {
    User modifier = new UserImpl("john");
    query.withModifier(modifier);
    assertEquals(modifier, query.getModifier());
  }
View Full Code Here

   * {@link ch.entwine.weblounge.common.impl.content.SearchQueryImpl#withPublisher(ch.entwine.weblounge.common.security.User)}
   * .
   */
  @Test
  public void testWithPublisher() {
    User publisher = new UserImpl("john");
    query.withPublisher(publisher);
    assertEquals(publisher, query.getPublisher());
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.impl.security.UserImpl

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.