Package org.geoserver.security

Examples of org.geoserver.security.CatalogFilterAccessManager


    @SuppressWarnings("serial")
    @Test
    public void testCatalogFilteredGetLayers() throws Exception {

        CatalogFilterAccessManager filter = new CatalogFilterAccessManager();

        // make a catalog that uses our layers
        Catalog withLayers = new AbstractCatalogDecorator(catalog) {

            @SuppressWarnings("unchecked")
            @Override
            public <T extends CatalogInfo> CloseableIterator<T> list(Class<T> of, Filter filter, Integer offset, Integer count, SortBy sortBy) {
                return new CloseableIteratorAdapter<T>((Iterator<T>) layers.iterator());
            }
        };

        // and the secure catalog with the filter
        SecureCatalogImpl sc = this.buildTestObject("publicRead.properties", withLayers, filter);

        // base behavior sanity
        assertTrue(layers.size() > 1);
        assertTrue(sc.getLayers().size() > 1);

        // setup a catalog filter that will hide the layer
        // an example of this happening is when the LocalWorkspaceCatalogFilter
        // detects 'LocalLayer.get' contains the local layer
        // the result is it gets filtered out
        filter.setCatalogFilters(Collections.singletonList(new AbstractCatalogFilter() {

            @Override
            public boolean hideLayer(LayerInfo layer) {
                return layer != statesLayer;
            }
View Full Code Here


    }

    CatalogFilterAccessManager setupAccessManager() throws Exception {
        DataAccessManager def = buildLegacyAccessManager("wideOpen.properties");
        ResourceAccessManager defAsResourceManager = new DataAccessManagerAdapter(def);
        CatalogFilterAccessManager mgr = new CatalogFilterAccessManager();
        mgr.setCatalogFilters(Collections.singletonList(new LocalWorkspaceCatalogFilter(catalog)));
        mgr.setDelegate(defAsResourceManager);
        return mgr;
    }
View Full Code Here

        mgr.setDelegate(defAsResourceManager);
        return mgr;
    }
    @Test
    public void testAccessToLayer() throws Exception {
        CatalogFilterAccessManager mgr = setupAccessManager();
       
        SecureCatalogImpl sc = new SecureCatalogImpl(catalog, mgr) {};
        assertNotNull(sc.getLayerByName("topp:states"));
       
        WorkspaceInfo ws = sc.getWorkspaceByName("nurc");
View Full Code Here

        assertNull(sc.getLayerByName("topp:states"));
    }

    @Test
    public void testAccessToStyle() throws Exception {
        CatalogFilterAccessManager mgr = setupAccessManager();

        SecureCatalogImpl sc = new SecureCatalogImpl(catalog, mgr) {};
        assertEquals(2, sc.getStyles().size());

        WorkspaceInfo ws = sc.getWorkspaceByName("topp");
View Full Code Here

        assertEquals(1, sc.getStyles().size());
    }

    @Test
    public void testAccessToLayerGroup() throws Exception {
        CatalogFilterAccessManager mgr = setupAccessManager();

        SecureCatalogImpl sc = new SecureCatalogImpl(catalog, mgr) {};
        assertEquals(3, sc.getLayerGroups().size());

        WorkspaceInfo ws = sc.getWorkspaceByName("topp");
View Full Code Here

TOP

Related Classes of org.geoserver.security.CatalogFilterAccessManager

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.