Package org.springframework.security.core.authority

Examples of org.springframework.security.core.authority.GrantedAuthorityImpl


    assertEquals("emailAddress", user.getEmailAddress());
    assertEquals("website", user.getWebsite());

    Collection<GrantedAuthority> authorities = user.getAuthorities();
    assertEquals(2, authorities.size());
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_OWNER_ROLE)));
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE)));
  }
View Full Code Here


    assertEquals("emailAddress", user.getEmailAddress());
    assertEquals("website", user.getWebsite());

    Collection<GrantedAuthority> authorities = user.getAuthorities();
    assertEquals(1, authorities.size());
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE)));
  }
View Full Code Here

  private BloggerAPIHandler handler = new BloggerAPIHandler();

  protected void setUp() throws Exception {
    super.setUp();

    handler.setAuthenticationManager(new net.sourceforge.pebble.mock.MockAuthenticationManager(true, new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_CONTRIBUTOR_ROLE)}));
    blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "username");
  }
View Full Code Here

  private BloggerAPIHandler handler = new BloggerAPIHandler();

  protected void setUp() throws Exception {
    super.setUp();

    handler.setAuthenticationManager(new net.sourceforge.pebble.mock.MockAuthenticationManager(true, new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_CONTRIBUTOR_ROLE)}));
    blog1.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "username");
    blog2.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "username2");
  }
View Full Code Here

  private AuthenticationManager authenticationManager;

  protected void setUp() throws Exception {
    super.setUp();

    authenticationManager = new MockAuthenticationManager(true, new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_CONTRIBUTOR_ROLE)});
    handler.setAuthenticationManager(authenticationManager);
    blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "username");
  }
View Full Code Here

  public static boolean isBlogContributor(Authentication auth) {
    return isUserInRole(auth, Constants.BLOG_CONTRIBUTOR_ROLE);
  }

  public static void runAsBlogOwner() {
    Authentication auth = new TestingAuthenticationToken("username", "password", new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_OWNER_ROLE)});
    SecurityContextHolder.getContext().setAuthentication(auth);
  }
View Full Code Here

    Authentication auth = new TestingAuthenticationToken("username", "password", new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_OWNER_ROLE)});
    SecurityContextHolder.getContext().setAuthentication(auth);
  }

  public static void runAsBlogPublisher() {
    Authentication auth = new TestingAuthenticationToken("username", "password", new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_PUBLISHER_ROLE)});
    SecurityContextHolder.getContext().setAuthentication(auth);
  }
View Full Code Here

    Authentication auth = new TestingAuthenticationToken("username", "password", new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_PUBLISHER_ROLE)});
    SecurityContextHolder.getContext().setAuthentication(auth);
  }

  public static void runAsBlogContributor() {
    Authentication auth = new TestingAuthenticationToken("username", "password", new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_CONTRIBUTOR_ROLE)});
    SecurityContextHolder.getContext().setAuthentication(auth);
  }
View Full Code Here

  private MetaWeblogAPIHandler handler = new MetaWeblogAPIHandler();

  protected void setUp() throws Exception {
    super.setUp();

    handler.setAuthenticationManager(new net.sourceforge.pebble.mock.MockAuthenticationManager(true, new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_CONTRIBUTOR_ROLE)}));
    blog1.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "username");
  }
View Full Code Here

    }

    private List<GrantedAuthority> getGrantedAuthorities(Set<UserRole> roles) {
        List<GrantedAuthority> result = new ArrayList<GrantedAuthority>();
        for (UserRole r : roles) {
            result.add(new GrantedAuthorityImpl(r.name()));
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.authority.GrantedAuthorityImpl

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.