Package org.geoserver.security.config

Examples of org.geoserver.security.config.SecurityRoleServiceConfig


        return getSecurityManager().loadAuthenticationProvider(name);       
    }
   
    @Override
    public GeoServerRoleService createRoleService(String name) throws Exception {
        SecurityRoleServiceConfig config = getRoleConfig(name);
        getSecurityManager().saveRoleService(config);
        return getSecurityManager().loadRoleService(name);       
    }
View Full Code Here


        } catch (SecurityConfigException ex) {
            assertEquals(ex.getId(), ROLE_SERVICE_ALREADY_EXISTS_$1);
            assertEquals(ex.getArgs()[0],XMLRoleService.DEFAULT_NAME);
        }

        SecurityRoleServiceConfig config = createRoleConfig("default2", GeoServerRoleService.class,
                GeoServerRole.ADMIN_ROLE.getAuthority());
        try {
            validator.validateModifiedRoleService(config,config);
            fail("unknown role service should fail");
        } catch (SecurityConfigException ex) {
View Full Code Here

        replay(ugConfig);*/
        return config;
    }

    protected SecurityRoleServiceConfig createRoleConfig(String name, Class<?> aClass,String adminRole) {
        SecurityRoleServiceConfig config = new MemoryRoleServiceConfigImpl();
        config.setName(name);
        config.setClassName(aClass.getName());
        config.setAdminRoleName(adminRole);
        /*SecurityRoleServiceConfig config = createNiceMock(SecurityRoleServiceConfig.class);
        expect(config.getName()).andReturn(name).anyTimes();
        expect(config.getClassName()).andReturn(aClass.getName()).anyTimes();
        expect(config.getAdminRoleName()).andReturn(adminRole).anyTimes();
        replay(config);*/
 
View Full Code Here

    }

    @Test
    public void testRoleConfig() throws IOException {

        SecurityRoleServiceConfig config = createRoleConfig(XMLRoleService.DEFAULT_NAME,
            MemoryRoleService.class, GeoServerRole.ADMIN_ROLE.getAuthority());

        SecurityConfigValidator validator = new SecurityConfigValidator(getSecurityManager());
        try {
            config.setName(null);
            validator.validateRemoveRoleService(config);
            fail("no name should fail");
            //getSecurityManager().removeRoleService(config) ;
        } catch (SecurityConfigException ex) {
            assertEquals( NAME_REQUIRED,ex.getId());
            assertEquals(0,ex.getArgs().length);           
        }
       
        config.setName("abcd");
        for (GeoServerRole role : GeoServerRole.SystemRoles) {
            config.setAdminRoleName(role.getAuthority());
            try {
                validator.validateAddRoleService(config);
                fail("reserved role name should fail");
                //getSecurityManager().saveRoleService(config);
            } catch (SecurityConfigException ex) {
                assertEquals( RESERVED_ROLE_NAME,ex.getId());
                assertEquals(role.getAuthority(),ex.getArgs()[0]);
            }
        }
       
        for (GeoServerRole role : GeoServerRole.SystemRoles) {
            config.setGroupAdminRoleName(role.getAuthority());
            try {
                validator.validateAddRoleService(config);
                fail("resoerved role name should fail");
                //getSecurityManager().saveRoleService(config);                       
            } catch (SecurityConfigException ex) {
                assertEquals( RESERVED_ROLE_NAME,ex.getId());
                assertEquals(role.getAuthority(),ex.getArgs()[0]);           
            }
        }

        try {
            config.setName(XMLRoleService.DEFAULT_NAME);
            validator.validateRemoveRoleService(config);
            fail("role service active should fail");
            //getSecurityManager().removeRoleService(config) ;                        
        } catch (SecurityConfigException ex) {
            assertEquals( ROLE_SERVICE_ACTIVE_$1,ex.getId());
View Full Code Here

                GeoServerRoleStore store = service.createStore();
                store.clear();
                store.store();
            }

            SecurityRoleServiceConfig old = securityManager.loadRoleServiceConfig(serviceName);
            securityManager.removeRoleService(old);
          
        }
        JDBCRoleServiceConfig config = new JDBCRoleServiceConfig();
       
View Full Code Here

            this.configModel = configModel;
        }

        @Override
        public List<String> getObject() {
            SecurityRoleServiceConfig config = configModel.getObject();
            List<String> roleNames = new ArrayList<String>();
            if (config.getId() != null) {
                try {
                    for (GeoServerRole role : GeoServerApplication.get().getSecurityManager()
                            .loadRoleService(config.getName()).getRoles()) {
                        roleNames.add(role.getAuthority());
                    }
                } catch (IOException e) {
                  // catch exception, otherwise role service
                  // configuration page cannot be opened
View Full Code Here

    protected List<SecurityRoleServiceConfig> load() {
        GeoServerSecurityManager secMgr = GeoServerApplication.get().getSecurityManager();
        List<SecurityRoleServiceConfig> configs = new ArrayList();
        try {
            for (String roleServiceName : secMgr.listRoleServices()) {
                SecurityRoleServiceConfig config = secMgr.loadRoleServiceConfig(roleServiceName);
                configs.add(config);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

    }

    protected void deactivateRORoleService() throws Exception {
        GeoServerSecurityManager secMgr = getSecurityManager();
        if (secMgr.listRoleServices().contains(getRORoleServiceName())) {
            SecurityRoleServiceConfig config =
                secMgr.loadRoleServiceConfig((getRORoleServiceName()));
            secMgr.removeRoleService(config);
        }
    }
View Full Code Here

    @Before
    public void removeRoleService2() throws Exception {
        GeoServerSecurityManager secMgr = getSecurityManager();
        if (secMgr.listRoleServices().contains("default2")) {
            SecurityRoleServiceConfig roleService = secMgr.loadRoleServiceConfig("default2");
            secMgr.removeRoleService(roleService);
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.security.config.SecurityRoleServiceConfig

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.