Package org.springframework.security

Examples of org.springframework.security.GrantedAuthorityImpl


      role = new UserRole(name);
      _userDao.saveOrUpdateUserRole(role);
    }
    _userRoles.put(name, role);

    final GrantedAuthority auth = new GrantedAuthorityImpl(name);
    _standardAuthoritiesMap.put(name, auth);
    return auth;
  }
View Full Code Here


  }

  public GrantedAuthority getNameBasedAuthority(final String name) {
    final GrantedAuthority auth = _standardAuthoritiesMap.get(name);
    if (null == auth) {
      return new GrantedAuthorityImpl(name);
    } else {
      return auth;
    }
  }
View Full Code Here

        int nbrAuth = auths.size();
        if (nbrAuth > 0) {
            result = new GrantedAuthority[nbrAuth];
            int i = 0;
            for (String role : auths) {
                result[i] = new GrantedAuthorityImpl(role);
                i++;
            }
        }
        return result;
    }
View Full Code Here

    }

    @Override
    protected void authenticate(String username, String password) {
        // override as this is not a test going through the servlet filters
        GrantedAuthority ga = new GrantedAuthorityImpl("MOCKROLE");
        UsernamePasswordAuthenticationToken user = new UsernamePasswordAuthenticationToken(
                username, null, new GrantedAuthority[] { ga });
        SecurityContextHolder.getContext().setAuthentication(user);
    }
View Full Code Here

        SecurityContextHolder.getContext().setAuthentication(
            new UsernamePasswordAuthenticationToken(
            "admin",
            "geoserver",
            new GrantedAuthority[]{
                new GrantedAuthorityImpl("ROLE_ADMINISTRATOR")
            }
            )
        );
    }
View Full Code Here

        SecurityContextHolder.getContext().setAuthentication(
            new UsernamePasswordAuthenticationToken(
            "anonymousUser",
            "",
            new GrantedAuthority[]{
                new GrantedAuthorityImpl("ROLE_ANONYMOUS")
            }
            )
        );
    }
View Full Code Here

        }
    }
   
    public void testSetUser() throws Exception {
        dao.setUser(new User("wfs", "pwd", true, true, true, true,
                new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_WFS_ALL"), new GrantedAuthorityImpl("ROLE_WMS_ALL")}));
        UserDetails user = dao.loadUserByUsername("wfs");
        assertEquals("wfs", user.getUsername());
        assertEquals("pwd", user.getPassword());
        assertEquals(2, user.getAuthorities().length);
        // ok... order dependent... making one non order dep takes too much time...
View Full Code Here

    }
   
    public void testSetMissingUser() throws Exception {
        try {
            dao.setUser(new User("notther", "pwd", true, true, true, true,
                    new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_WFS_ALL")}));
            fail("The user is not there, setUser should fail");
        } catch(IllegalArgumentException e) {
            // cool
        }
    }
View Full Code Here

        }
    }
   
    public void testAddUser() throws Exception {
        dao.putUser(new User("newuser", "pwd", true, true, true, true,
                new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_WFS_ALL")}));
        assertNotNull(dao.loadUserByUsername("newuser"));
    }
View Full Code Here

    }
   
    public void addExistingUser() throws Exception {
        try {
            dao.putUser(new User("admin", "pwd", true, true, true, true,
                    new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_WFS_ALL")}));
            fail("The user is already there, addUser should fail");
        } catch(IllegalArgumentException e) {
            // cool
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.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.