Examples of GeoServerRoleService


Examples of org.geoserver.security.GeoServerRoleService

        gaConfig.setCheckInterval(1000);
        gaConfig.setFileName(XMLConstants.FILE_RR);
        gaConfig.setValidating(true);
        getSecurityManager().saveRoleService(gaConfig/*,isNewRoleService(serviceName)*/);

        GeoServerRoleService service =
            getSecurityManager().loadRoleService(serviceName);
        service.initializeFromConfig(gaConfig);
        return service;
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

//        GeoserverRoleService roleService = createRoleService(
//                XMLRoleService.DEFAULT_NAME);
//        getSecurityManager().setActiveRoleService(roleService);
//        getSecurityManager().setActiveUserGroupService(userService);
        GeoServerUserGroupService userService = getSecurityManager().loadUserGroupService(XMLUserGroupService.DEFAULT_NAME);
        GeoServerRoleService roleService =getSecurityManager().loadRoleService(XMLRoleService.DEFAULT_NAME);
       
        assertEquals(3,userService.getUsers().size());
        assertEquals(3,userService.getUserCount());
        assertEquals(0,userService.getUserGroups().size());
        assertEquals(0,userService.getGroupCount());
       
        assertEquals(9,roleService.getRoles().size());
       
        GeoServerUser admin = (GeoServerUser) userService.loadUserByUsername("admin");
        assertNotNull(admin);
        GeoServerMultiplexingPasswordEncoder enc= getEncoder(userService);
        assertTrue(enc.isPasswordValid(admin.getPassword(), "gs", null));
       
        assertTrue(admin.isEnabled());
       
        GeoServerUser wfs = (GeoServerUser) userService.loadUserByUsername("wfs");
        assertNotNull(wfs);
        assertTrue(enc.isPasswordValid(wfs.getPassword(), "webFeatureService", null));
        assertTrue(wfs.isEnabled());

        GeoServerUser disabledUser = (GeoServerUser) userService.loadUserByUsername("disabledUser");
        assertNotNull(disabledUser);
        assertTrue(enc.isPasswordValid(disabledUser.getPassword(), "nah", null));
        assertFalse(disabledUser.isEnabled());
       
        GeoServerRole role_admin = roleService.getRoleByName(XMLRoleService.DEFAULT_LOCAL_ADMIN_ROLE);
        assertNotNull(role_admin);
        GeoServerRole role_wfs_read = roleService.getRoleByName("ROLE_WFS_READ");
        assertNotNull(role_wfs_read);
        GeoServerRole role_wfs_write = roleService.getRoleByName("ROLE_WFS_WRITE");
        assertNotNull(role_wfs_write);
        GeoServerRole role_test = roleService.getRoleByName("ROLE_TEST");
        assertNotNull(role_test);
        assertNotNull(roleService.getRoleByName("NO_ONE"));
        assertNotNull(roleService.getRoleByName("TRUSTED_ROLE"));
        assertNotNull(roleService.getRoleByName("ROLE_SERVICE_1"));
        assertNotNull(roleService.getRoleByName("ROLE_SERVICE_2"));

       

        assertEquals(2,admin.getAuthorities().size());
        assertTrue(admin.getAuthorities().contains(role_admin));
        assertTrue(admin.getAuthorities().contains(GeoServerRole.ADMIN_ROLE));
       
        assertEquals(2,wfs.getAuthorities().size());
        assertTrue(wfs.getAuthorities().contains(role_wfs_read));
        assertTrue(wfs.getAuthorities().contains(role_wfs_write));

        assertEquals(1,disabledUser.getAuthorities().size());
        assertTrue(disabledUser.getAuthorities().contains(role_test));
       
        GeoServerSecurityManager securityManager = getSecurityManager();
        File userfile = new File(securityManager.getSecurityRoot(),"users.properties");
        assertFalse(userfile.exists());
        File userfileOld = new File(securityManager.getSecurityRoot(),"users.properties.old");
        assertTrue(userfileOld.exists());

        File roleXSD = new File(new File(securityManager.getRoleRoot(), roleService.getName()),
            XMLConstants.FILE_RR_SCHEMA);
        assertTrue(roleXSD.exists());

        File userXSD = new File (new File(securityManager.getUserGroupRoot(), userService.getName()),
            XMLConstants.FILE_UR_SCHEMA);
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

//                    rec.add(behavior);*/
//                return rec;
//            }
//        };

        GeoServerRoleService roleService = getSecurityManager().getActiveRoleService();
        final String roleServiceName = roleService.getName();
       
        if (choicesModel instanceof RuleRolesModel)
            add(new Label("roles", new StringResourceModel("roles",this,null)));
        else
            add(new Label("roles", new StringResourceModel("rolesFromActiveService",
                    this,null,new Object[] {roleServiceName})));
       
        add(new SubmitLink("addRole") {
            @Override
            public void onSubmit() {
                setResponsePage(new NewRolePage(roleServiceName).setReturnPage(this.getPage()));
            }
        }.setVisible(roleService.canCreateStore()));
    }
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

            List<GeoServerRole> tmp = new ArrayList<GeoServerRole>();
            List<GeoServerRole> result = new ArrayList<GeoServerRole>();
            try {
                GeoServerUserGroupService ugService = getSecurityManager()
                        .loadUserGroupService(ugServiceName);
                GeoServerRoleService gaService = getSecurityManager()
                        .getActiveRoleService();

                RoleCalculator calc = new RoleCalculator(ugService, gaService);
                tmp.addAll(rolePalette.getSelectedRoles());
                calc.addInheritedRoles(tmp);
View Full Code Here

Examples of org.geoserver.security.GeoServerRoleService

     (non-Javadoc)
     * @see org.geoserver.security.file.FileWatcher#doOnChange()
     */
    @Override
    protected void doOnChange() {       
        GeoServerRoleService theService = getService();
        try {
            if (theService!=null)
                theService.load();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
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.