Package org.geoserver.security

Examples of org.geoserver.security.GeoServerRoleStore


        setMockCreator(new MockCreator() {
            @Override
            public GeoServerSecurityManager createSecurityManager(MockTestData testData) throws Exception {
                GeoServerSecurityManager secMgr = createNiceMock(GeoServerSecurityManager.class);

                GeoServerRoleStore roleStore =
                    createRoleStore("test", secMgr, "admin", "groupAdmin", "role1");
                addRolesToCreate(roleStore, "admin", "groupAdmin");
                expect(roleStore.getAdminRole()).andReturn(new GeoServerRole("admin")).anyTimes();
                expect(roleStore.getGroupAdminRole()).andReturn(new GeoServerRole("groupAdmin")).anyTimes();

                replay(roleStore, secMgr);
                return secMgr;
            }
        });
View Full Code Here


        return (GeoServerRoleService) super.getService();
    }

    @Override
    public GeoServerRoleStore createStore() throws IOException {
        GeoServerRoleStore store = getService().createStore();
        return store != null ? new LockingRoleStore(store) : null;
    }
View Full Code Here

                securityManager.setActiveRoleService(roleService);
            }

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

            SecurityRoleServiceConfig old = securityManager.loadRoleServiceConfig(serviceName);
            securityManager.removeRoleService(old);
          
View Full Code Here

        GeoServerSecurityManager manager = GeoServerExtensions.bean(GeoServerSecurityManager.class);
        service.setSecurityManager(manager);
        manager.setActiveRoleService(service);
        manager.saveRoleService(config);
       
        GeoServerRoleStore store = service.createStore();
        GeoServerRole adminRole = store.createRoleObject("adminRole");
        GeoServerRole groupAdminRole = store.createRoleObject("groupAdminRole");      
        GeoServerRole role1 = store.createRoleObject("role1");
        store.addRole(adminRole);
        store.addRole(groupAdminRole);
        store.addRole(role1);
       
        store.associateRoleToUser(adminRole, "user1");
        store.associateRoleToUser(groupAdminRole, "user1");
        store.associateRoleToUser(adminRole, "user2");
        store.associateRoleToUser(role1, "user3");
        store.store();
    
        MemoryUserGroupServiceConfigImpl ugconfig = new MemoryUserGroupServiceConfigImpl();        
        ugconfig.setName("testAdminRole");       
        ugconfig.setClassName(MemoryUserGroupService.class.getName());
        ugconfig.setPasswordEncoderName(getPBEPasswordEncoder().getName());
View Full Code Here

                store.load();
            } catch (IOException ex2) {};
            throw ex;
        }

        GeoServerRoleStore gaStore = null;
        try {
            if (hasRoleStore(getSecurityManager().getActiveRoleService().getName())) {
                gaStore = getRoleStore(getSecurityManager().getActiveRoleService().getName());
                gaStore = new RoleStoreValidationWrapper(gaStore);

                Set<GeoServerRole> orig = gaStore.getRolesForGroup(group.getGroupname());
                Set<GeoServerRole> add = new HashSet<GeoServerRole>();
                Set<GeoServerRole> remove = new HashSet<GeoServerRole>();
                rolePalette.diff(orig, add, remove);

                for (GeoServerRole role : add)
                    gaStore.associateRoleToGroup(role, group.getGroupname());
                for (GeoServerRole role : remove)
                    gaStore.disAssociateRoleFromGroup(role, group.getGroupname());       
                gaStore.store();
            }       
        } catch (IOException ex) {
            try {gaStore.load(); } catch (IOException ex2) {};
            throw ex;
        }

    }
View Full Code Here

            protected boolean onSubmit(AjaxRequestTarget target, Component contents) {
                // cascade delete the whole selection

               
                GeoServerRoleStore gaStore = null;
                try {
                    GeoServerRoleService gaService =
                            GeoServerApplication.get().getSecurityManager().loadRoleService(roleServiceName);
                    gaStore = new RoleStoreValidationWrapper(gaService.createStore());
                    for (GeoServerRole role : removePanel.getRoots()) {                    
                         gaStore.removeRole(role);
                    }
                    gaStore.store();
                } catch (IOException ex) {
                    try {gaStore.load(); } catch (IOException ex2) {};
                    throw new RuntimeException(ex);
                }
                // the deletion will have changed what we see in the page
                // so better clear out the selection
                roles.clearSelection();
View Full Code Here

    public void testCopyFrom() {
        try {
           
            GeoServerRoleService service1 = createRoleService("copyFrom");
            GeoServerRoleService service2 = createRoleService("copyTo");
            GeoServerRoleStore store1 = createStore(service1);
            GeoServerRoleStore store2 = createStore(service2);                       
           
            store1.clear();
            checkEmpty(store1);       
            insertValues(store1);
            Util.copyFrom(store1, store2);
View Full Code Here

        FileUtils.copyURLToFile(getClass().getResource("rolesTemplate.xml"),xmlFile);
        GeoServerRoleService service1 = 
            createRoleService("locking1",xmlFile.getCanonicalPath());
        GeoServerRoleService service2 = 
            createRoleService("locking2",xmlFile.getCanonicalPath());
        GeoServerRoleStore store1= createStore(service1);
        GeoServerRoleStore store2= createStore(service2);
       
       
        GeoServerRole role_test1 = store1.createRoleObject("ROLE_TEST");
        GeoServerRole role_test2= store2.createRoleObject("ROLE_TEST");
       
       // obtain a lock
        store1.addRole(role_test1);
        boolean fail;
        String failMessage="Concurrent lock not allowed";
        fail=true;
        try {
            store2.clear();
        } catch (IOException ex) {
            fail=false;
        }
        if (fail)
            Assert.fail(failMessage);
       
        // release lock
        store1.load();
        // get lock
        store2.addRole(role_test1);
       
        fail=true;
        try {
            store1.clear();
        } catch (IOException ex) {
            fail=false;
        }
        if (fail)
            Assert.fail(failMessage);
       
        // release lock
        store2.store();
        store1.clear();
        store1.store();
       
        //// end of part one, now check all modifying methods

        // obtain a lock
        store1.addRole(role_test1);
       
        fail=true;
        try {
            store2.associateRoleToGroup(role_test2, "agroup");
        } catch (IOException ex) {
            try {
                store2.disAssociateRoleFromGroup(role_test2, "agroup");
            } catch (IOException e) {
                fail=false;
            }
        }
        if (fail)
            Assert.fail(failMessage);
       
        fail=true;
        try {
            store2.associateRoleToUser(role_test2, "auser");
        } catch (IOException ex) {
            try {
                store2.disAssociateRoleFromUser(role_test2, "auser");
            } catch (IOException e) {
                fail=false;
            }
        }
        if (fail)
            Assert.fail(failMessage);
       
        fail=true;
        try {
            store2.updateRole(role_test2);
        } catch (IOException ex) {
            try {
                store2.removeRole(role_test2);
            } catch (IOException ex1) {
                try {
                    store2.addRole(role_test2);
                } catch (IOException ex2) {
                    fail=false;
                }
            }
        }
        if (fail)
            Assert.fail(failMessage);

        fail=true;
        try {
            store2.clear();
        } catch (IOException ex) {
            try {
                store2.store();
            } catch (IOException e) {
                fail=false;
            }
        }
        if (fail)
            Assert.fail(failMessage);

        fail=true;
        try {
            store2.setParentRole(role_test1, null);
        } catch (IOException ex) {
            fail=false;
        }
        if (fail)
            Assert.fail(failMessage);
View Full Code Here

            GeoServerRoleService service1 = 
                createRoleService("reload1",xmlFile.getCanonicalPath());
            GeoServerRoleService service2 = 
                createRoleService("reload2",xmlFile.getCanonicalPath());
           
            GeoServerRoleStore store1= createStore(service1);
           
           
            GeoServerRole role_test1 = store1.createRoleObject("ROLE_TEST1");
           
            checkEmpty(service1);
            checkEmpty(service2);
           
            // prepare for syncing           
            class CheckRoleLoaded implements RoleLoadedListener {   
                public int notified = 0;
                @Override
                public void rolesChanged(RoleLoadedEvent event) {
                    synchronized (this) {
                        this.notifyAll();
                        notified++;
                    }                   
                }
            };            
            CheckRoleLoaded listener = new CheckRoleLoaded();
            service2.registerRoleLoadedListener(listener);
           
            // modifiy store1
            store1.addRole(role_test1);
            store1.store();
            assertTrue(service1.getRoles().size()==1);
           
            // increment lastmodified adding a second manually, the test is too fast
            xmlFile.setLastModified(xmlFile.lastModified()+1000);
           
View Full Code Here

                store.load();
            } catch (IOException ex2) {};
            throw ex;
        }

        GeoServerRoleStore gaStore=null;
        try {
            if (hasRoleStore(getSecurityManager().getActiveRoleService().getName())) {
                gaStore = getRoleStore(getSecurityManager().getActiveRoleService().getName());
                gaStore = new RoleStoreValidationWrapper(gaStore);

                for (GeoServerRole role : rolePalette.getSelectedRoles()) {
                    gaStore.associateRoleToGroup(role, group.getGroupname());
                }
                gaStore.store();
            }
        } catch (IOException ex) {
            try {gaStore.load(); } catch (IOException ex2) {};
            throw ex;
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.security.GeoServerRoleStore

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.