Examples of GeoServerRoleService


Examples of org.geoserver.security.GeoServerRoleService

     */
    protected Collection<GeoServerRole> getRolesFromRoleService(HttpServletRequest request, String principal) throws IOException{
        boolean useActiveService = getRoleServiceName()==null ||
                getRoleServiceName().trim().length()==0;
     
        GeoServerRoleService service = useActiveService ?
              getSecurityManager().getActiveRoleService() :
              getSecurityManager().loadRoleService(getRoleServiceName());
             
        RoleCalculator calc = new RoleCalculator(service);
        return calc.calculateRoles(principal);
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

        assertTrue(fail);
    }
   
    @Test
    public void testAuthentificationWithUserGroupService() throws Exception {
        GeoServerRoleService roleService = createRoleService("jdbc2");
        GeoServerUserGroupService ugService = createUserGroupService("jdbc2");
        JDBCConnectAuthProviderConfig config = createAuthConfg("jdbc2", ugService.getName());
        getSecurityManager().saveAuthenticationProvider(config);
        GeoServerAuthenticationProvider provider = getSecurityManager().loadAuthenticationProvider("jdbc2");
       
        GeoServerUserGroupStore ugStore =  ugService.createStore();
        GeoServerUser sa = ugStore.createUserObject("sa", "", true);
        ugStore.addUser(sa);
        ugStore.store();
       
        GeoServerRoleStore roleStore =  roleService.createStore();
        roleStore.addRole(GeoServerRole.ADMIN_ROLE);
        roleStore.associateRoleToUser(GeoServerRole.ADMIN_ROLE, sa.getUsername());
        roleStore.store();
        getSecurityManager().setActiveRoleService(roleService);
       
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

        assertTrue(fail);
               
    }
    @Test
    public void testAuthentificationWithRoleAssociation() throws Exception {
        GeoServerRoleService roleService = createRoleService("jdbc3");
        JDBCConnectAuthProviderConfig config = createAuthConfg("jdbc3", null);
        getSecurityManager().saveAuthenticationProvider(config);
        GeoServerAuthenticationProvider provider = getSecurityManager().loadAuthenticationProvider("jdbc3");
       
       
        GeoServerRoleStore roleStore =  roleService.createStore();
        roleStore.addRole(GeoServerRole.ADMIN_ROLE);
        roleStore.associateRoleToUser(GeoServerRole.ADMIN_ROLE, "sa");
        roleStore.store();
        getSecurityManager().setActiveRoleService(roleService);
       
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

       
        Collection<GeoServerRole> roles = new ArrayList<GeoServerRole>();
        boolean useActiveService = getRoleServiceName()==null ||
                getRoleServiceName().trim().length()==0;
     
        GeoServerRoleService service = useActiveService ?
              getSecurityManager().getActiveRoleService() :
              getSecurityManager().loadRoleService(getRoleServiceName());
                               
        for (GeoServerRole role: service.getRoles())
          if (request.isUserInRole(role.getAuthority()))
              roles.add(role);
     
        RoleCalculator calc = new RoleCalculator(service);
        calc.addInheritedRoles(roles);
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

    }

   
    protected void createServices() throws Exception{
       
        GeoServerRoleService rservice = createRoleService("rs1");
        GeoServerRoleStore rstore = rservice.createStore();
        GeoServerRole root, derived;
        rstore.addRole(root=rstore.createRoleObject(rootRole));
        rstore.addRole(derived=rstore.createRoleObject(derivedRole));
        rstore.setParentRole(derived, root);
        rstore.associateRoleToUser(derived, testUserName);
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

    static final String plainTextUserGroup = "plainuserGroup";

    @Override
    public GeoServerRoleService createRoleService(String name) throws Exception {
        MemoryRoleServiceConfigImpl config = getRoleConfig(name);
        GeoServerRoleService service = new MemoryRoleService();
        service.setSecurityManager(GeoServerExtensions.bean(GeoServerSecurityManager.class));
        service.initializeFromConfig(config);
        getSecurityManager().saveRoleService(config/*,isNewRoleService(name)*/);
        return service;

       
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

            }
        }
        ugStore.store();

        if (roles != null && !roles.isEmpty()) {
            GeoServerRoleService roleService = secMgr.getActiveRoleService();
            GeoServerRoleStore roleStore = roleService.createStore();
            for (String roleName : roles) {
                GeoServerRole role = roleStore.getRoleByName(roleName);
                if (role == null) {
                    role = roleStore.createRoleObject(roleName);
                    roleStore.addRole(role);
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService


    @Test
    public void testNoRoles() throws Exception{
        copyWebXML("web1.xml");
        GeoServerRoleService service =  getSecurityManager().loadRoleService("test1");
        checkEmpty(service);       
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

    }
   
    @Test
    public void testRoles() throws Exception{
        copyWebXML("web2.xml");
        GeoServerRoleService service =  getSecurityManager().loadRoleService("test2");
        assertEquals(4,service.getRoleCount());
        assertTrue(service.getRoles().contains(new GeoServerRole("role1")));
        assertTrue(service.getRoles().contains(new GeoServerRole("role2")));
        assertTrue(service.getRoles().contains(new GeoServerRole("employee")));
        assertTrue(service.getRoles().contains(new GeoServerRole("MGR")));
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

    protected static GeoServerRoleService createH2RoleService(
        String serviceName, GeoServerSecurityManager securityManager) throws Exception {

        if (securityManager.listRoleServices().contains(serviceName)) {
            if (securityManager.getActiveRoleService().getName().equals(serviceName)) {
                GeoServerRoleService roleService = securityManager.loadRoleService("default");
                securityManager.setActiveRoleService(roleService);
            }

            GeoServerRoleService service = securityManager.loadRoleService(serviceName);
            if (service.canCreateStore()) {
                GeoServerRoleStore store = service.createStore();
                store.clear();
                store.store();
            }

            SecurityRoleServiceConfig old = securityManager.loadRoleServiceConfig(serviceName);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.