Package org.geoserver.security

Examples of org.geoserver.security.GeoServerUserGroupStore


        properties.put(LayerProperty.STYLE, "raster");
        testData.addRasterLayer(new QName(MockData.SF_URI, "mosaic", MockData.SF_PREFIX),
                "raster-filter-test.zip",null, properties, SystemTestData.class, getCatalog());
       
       
        GeoServerUserGroupStore ugStore= getSecurityManager().
                loadUserGroupService(AbstractUserGroupService.DEFAULT_NAME).createStore();
       
        ugStore.addUser(ugStore.createUserObject("cite", "cite", true));
        ugStore.addUser(ugStore.createUserObject("cite_noinfo", "cite", true));
        ugStore.addUser(ugStore.createUserObject("cite_nostates", "cite", true));
        ugStore.addUser(ugStore.createUserObject("cite_texas", "cite", true));
        ugStore.addUser(ugStore.createUserObject("cite_mosaic1", "cite", true));
        ugStore.addUser(ugStore.createUserObject("cite_mosaic2", "cite", true));
        ugStore.store();
       
        GeoServerRoleStore roleStore= getSecurityManager().getActiveRoleService().createStore();
        GeoServerRole role = roleStore.createRoleObject("ROLE_DUMMY");
        roleStore.addRole(role);
        roleStore.associateRoleToUser(role, "cite");
View Full Code Here


        return (GeoServerUserGroupService) super.getService();
    }

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

        GeoServerSecurityManager securityManager) throws Exception {       

        if (securityManager.listUserGroupServices().contains(serviceName)) {
            GeoServerUserGroupService service = securityManager.loadUserGroupService(serviceName);
            if (service.canCreateStore()) {
                GeoServerUserGroupStore store = service.createStore();
                store.clear();
                store.store();
            }
            SecurityUserGroupServiceConfig old =
                    securityManager.loadUserGroupServiceConfig(serviceName);
            securityManager.removeUserGroupService(old);
View Full Code Here

    public void testCopyFrom() {
        try {
   
            GeoServerUserGroupService service1 = createUserGroupService("copyFrom");
            GeoServerUserGroupService service2 = createUserGroupService("copyTo");
            GeoServerUserGroupStore store1 = createStore(service1);
            GeoServerUserGroupStore store2 = createStore(service2);                       

           
            store1.clear();
            checkEmpty(store1);       
            insertValues(store1);
View Full Code Here

        FileUtils.copyURLToFile(getClass().getResource("usersTemplate.xml"),xmlFile);
        GeoServerUserGroupService service1 = 
            createUserGroupService("locking1",xmlFile.getCanonicalPath());
        GeoServerUserGroupService service2 = 
            createUserGroupService("locking2",xmlFile.getCanonicalPath());
        GeoServerUserGroupStore store1= createStore(service1);
        GeoServerUserGroupStore store2= createStore(service2);
       
       
        GeoServerUser user = store1.createUserObject("user", "ps", true);
        GeoServerUserGroup group = store2.createGroupObject("group", true);
       
       // obtain a lock
        store1.addUser(user);
        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.addUser(user);
       
        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.addUser(user);
       
        fail=true;
        try {
            store2.associateUserToGroup(user, group);
        } catch (IOException ex) {
            try {
                store2.disAssociateUserFromGroup(user, group);
            } catch (IOException e) {
                fail=false;
            }
        }
        if (fail)
            Assert.fail(failMessage);
       
       
        fail=true;
        try {
            store2.updateUser(user);
        } catch (IOException ex) {
            try {
                store2.removeUser(user);
            } catch (IOException ex1) {
                try {
                    store2.addUser(user);
                } catch (IOException ex2) {
                    fail=false;
                }
            }
        }
        if (fail)
            Assert.fail(failMessage);
       
        fail=true;
        try {
            store2.updateGroup(group);
        } catch (IOException ex) {
            try {
                store2.removeGroup(group);
            } catch (IOException ex1) {
                try {
                    store2.addGroup(group);
                } 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)
View Full Code Here

        GeoServerUserGroupService service1 = 
            createUserGroupService("reload1",xmlFile.getCanonicalPath());
        GeoServerUserGroupService service2 = 
            createUserGroupService("reload2",xmlFile.getCanonicalPath());
       
        GeoServerUserGroupStore store1= createStore(service1);
       
       
        GeoServerUserGroup group = store1.createGroupObject("group",true);
       
        checkEmpty(service1);
        checkEmpty(service2);
       
        // prepare for syncing
       
        UserGroupLoadedListener listener = new UserGroupLoadedListener() {
           
            @Override
            public void usersAndGroupsChanged(UserGroupLoadedEvent event) {
                synchronized (this) {
                    this.notifyAll();
                }
            }
        };
           
        service2.registerUserGroupLoadedListener(listener);
       
        // modifiy store1
        store1.addGroup(group);
        store1.store();
        assertTrue(service1.getUserGroups().size()==1);
        assertTrue(service1.getGroupCount()==1);
       
     // increment lastmodified adding a second manually, the test is too fast
        xmlFile.setLastModified(xmlFile.lastModified()+2000)
View Full Code Here

        }).setFilterable(false));
    }

    @Override
    protected void onFormSubmit(GeoServerUserGroup group) throws IOException {
        GeoServerUserGroupStore store = null;
        try {
            if (hasUserGroupStore(userGroupServiceName)) {
                store = new UserGroupStoreValidationWrapper(getUserGroupStore(userGroupServiceName));
                store.updateGroup(group);
                store.store();
            };
        } catch (IOException ex) {
            try {
                //try to reload the store
                store.load();
            } catch (IOException ex2) {};
            throw ex;
        }

        GeoServerRoleStore gaStore = null;
View Full Code Here

        }
    }

    @Override
    protected void onFormSubmit(GeoServerUserGroup group) throws IOException {
        GeoServerUserGroupStore store=null;
        try {
            store = new UserGroupStoreValidationWrapper(getUserGroupStore(userGroupServiceName));
            group = store.createGroupObject(group.getGroupname(),group.isEnabled());
            store.addGroup(group);
            store.store();
        } catch (IOException ex) {
            try {
                store.load();
            } catch (IOException ex2) {};
            throw ex;
        }

        GeoServerRoleStore gaStore=null;
View Full Code Here

                };
            }

            protected boolean onSubmit(AjaxRequestTarget target, Component contents) {

                GeoServerUserGroupStore ugStore=null;
                try {
                    GeoServerUserGroupService ugService =
                            GeoServerApplication.get().getSecurityManager()
                            .loadUserGroupService(userGroupsServiceName);
                    ugStore = new UserGroupStoreValidationWrapper(ugService.createStore());
                    for (GeoServerUserGroup group : removePanel.getRoots()) {                    
                         ugStore.removeGroup(group);
                    }
                    ugStore.store();
                } catch (IOException ex) {
                    try {ugStore.load(); } catch (IOException ex2) {};
                    throw new RuntimeException(ex);
                }
               
                GeoServerRoleStore gaStore = null;
                if (disassociateRoles) {
View Full Code Here

    @Override
    protected void onFormSubmit(GeoServerUser user)
        throws IOException,PasswordPolicyException {
       
        GeoServerUserGroupService ugService = getUserGroupService(ugServiceName);
        GeoServerUserGroupStore ugStore = null;
        try {
            if (ugService.canCreateStore()) {
                ugStore = new UserGroupStoreValidationWrapper(ugService.createStore());
   
                Set<GeoServerUserGroup> orig = ugStore.getGroupsForUser(user);
                Set<GeoServerUserGroup> add = new HashSet<GeoServerUserGroup>();
                Set<GeoServerUserGroup> remove = new HashSet<GeoServerUserGroup>();
                userGroupPalette.diff(orig, add, remove);

                ugStore.updateUser(user);

                for (GeoServerUserGroup g : add) ugStore.associateUserToGroup(user, g);
                for (GeoServerUserGroup g : remove) ugStore.disAssociateUserFromGroup(user,g);

                ugStore.store();
            }
        } catch (IOException ex) {
            LOGGER.log(Level.WARNING, ex.getLocalizedMessage(), ex);
            try { ugStore.load(); } catch (IOException ex2) {};
            throw ex;
        } catch (PasswordPolicyException ex) {
            try { ugStore.load(); } catch (IOException ex2) {};
            throw ex;
        }

        GeoServerRoleStore roleStore=null;
        try {
View Full Code Here

TOP

Related Classes of org.geoserver.security.GeoServerUserGroupStore

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.