Package org.geoserver.security

Examples of org.geoserver.security.TestResourceAccessManager


        super.setUpInternal();

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        FeatureTypeInfo buildings = catalog.getFeatureTypeByName(getLayerId(MockData.BUILDINGS));

        // limits for mr readfilter
        Filter fid113 = ff.equal(ff.property("FID"), ff.literal("113"), false);
        tam.putLimits("cite_readfilter", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                fid113, null, null));

        // limits for mr readatts (both limited read attributes and features)
        List<PropertyName> readAtts = Arrays.asList(ff.property("the_geom"), ff.property("FID"));
        tam.putLimits("cite_readatts", buildings, new VectorAccessLimits(CatalogMode.HIDE,
                readAtts, fid113, null, null));

        // disallow writing on Restricted Street
        Filter restrictedStreet = ff.not(ff.like(ff.property("ADDRESS"), "*Restricted Street*", "*", "?",
                "\\"));
        tam.putLimits("cite_insertfilter", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                null, null, restrictedStreet));
       
        // allows writing only on 113
        tam.putLimits("cite_writefilter", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                null, null, fid113));
       
        // disallow writing on the ADDRESS attribute
        List<PropertyName> writeAtts = Arrays.asList(ff.property("the_geom"), ff.property("FID"));
        tam.putLimits("cite_writeatts", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                null, writeAtts, null));
    }
View Full Code Here


    @Override
    protected void setUpInternal() throws Exception {
        super.setUpInternal();

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        CoverageInfo world = catalog.getCoverageByName(getLayerId(MockData.WORLD));

        // limits for mr cite_noworld: can't access the world layer
        tam.putLimits("cite_noworld", world, new CoverageAccessLimits(CatalogMode.HIDE,
                Filter.EXCLUDE, null, null));

        // limits for mr cite_noworld: can't access the world layer
        tam.putLimits("cite_noworld_challenge", world, new CoverageAccessLimits(
                CatalogMode.CHALLENGE, Filter.EXCLUDE, null, null));

        // limits the area to north america
        MultiPolygon rasterFilter = (MultiPolygon) new WKTReader().read("MULTIPOLYGON(((-120 30, -120 60, -60 60, -60 30, -120 30)))");
        tam.putLimits("cite_usa", world, new CoverageAccessLimits(CatalogMode.HIDE, null,
                rasterFilter, null));
    }
View Full Code Here

    protected void setUpInternal() throws Exception {
        super.setUpInternal();
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        FeatureTypeInfo gu = catalog.getFeatureTypeByName("gsml:GeologicUnit");

        // limits for mr readfilter
        Filter f = ff.equal(ff.property("purpose"), ff.literal("instance"), false);
        tam.putLimits("cite_readfilter", gu, new VectorAccessLimits(CatalogMode.HIDE, null, f,
                null, null));

        List<PropertyName> readAtts = Arrays.asList(ff.property("composition"), ff
                .property("outcropCharacter"));
        tam.putLimits("cite_readatts", gu, new VectorAccessLimits(CatalogMode.HIDE, readAtts, f,
                null, null));

    }
View Full Code Here

        super.onSetUp(testData);
       
        addUser("cite", "cite", null, Collections.singletonList("ROLE_DUMMY"));

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        FeatureTypeInfo buildings = catalog
                .getFeatureTypeByName(getLayerId(SystemTestData.BUILDINGS));

        // limits make the layer be visible when logged in as the cite user, but not when
        // running as the anonymous one (the TestResourceAccessManager does not allow
        // to run tests against un-recognized users)
        tam.putLimits("cite", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                Filter.INCLUDE, null, null));
        tam.putLimits("anonymous", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                Filter.EXCLUDE, null, null));
    }
View Full Code Here

        //------
       
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        FeatureTypeInfo buildings = catalog.getFeatureTypeByName(getLayerId(SystemTestData.BUILDINGS));

        // limits for mr readfilter
        Filter fid113 = ff.equal(ff.property("FID"), ff.literal("113"), false);
        tam.putLimits("cite_readfilter", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                fid113, null, null));

        // limits for mr readatts (both limited read attributes and features)
        List<PropertyName> readAtts = Arrays.asList(ff.property("the_geom"), ff.property("FID"));
        tam.putLimits("cite_readatts", buildings, new VectorAccessLimits(CatalogMode.HIDE,
                readAtts, fid113, null, null));
       
        // limits the attributes, but specifies no filtering
        tam.putLimits("cite_readattsnf", buildings, new VectorAccessLimits(CatalogMode.HIDE,
                readAtts, Filter.INCLUDE, null, Filter.INCLUDE));

        // disallow writing on Restricted Street
        Filter restrictedStreet = ff.not(ff.like(ff.property("ADDRESS"), "*Restricted Street*", "*", "?",
                "\\"));
        tam.putLimits("cite_insertfilter", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                null, null, restrictedStreet));
       
        // allows writing only on 113
        tam.putLimits("cite_writefilter", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                null, null, fid113));
       
        // disallow writing on the ADDRESS attribute
        List<PropertyName> writeAtts = Arrays.asList(ff.property("the_geom"), ff.property("FID"));
        tam.putLimits("cite_writeatts", buildings, new VectorAccessLimits(CatalogMode.HIDE, null,
                null, writeAtts, null));
    }
View Full Code Here

        Hints hints = new Hints();
        hints.put(FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, ns);                       
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(hints);

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        FeatureTypeInfo gu = catalog.getFeatureTypeByName("gsml:GeologicUnit");

        // limits for mr readfilter
        Filter f = ff.equal(new AttributeExpressionImpl("gsml:purpose", ns), ff.literal("instance"), false);
        tam.putLimits("cite_readfilter", gu, new VectorAccessLimits(CatalogMode.HIDE, null, f,
                null, null));

        List<PropertyName> readAtts = Arrays.asList(ff.property("gsml:composition"),
                ff.property("gsml:outcropCharacter"));

        tam.putLimits("cite_readatts", gu, new VectorAccessLimits(CatalogMode.HIDE, readAtts, f,
                null, null));

    }
View Full Code Here

        roleStore.associateRoleToUser(role, "cite_filtermosaic");            
        roleStore.store();
       
        // populate the access manager
        Catalog catalog = getCatalog();
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
       

        CoverageInfo coverage = catalog.getCoverageByName("sf:mosaic");
       
        //layer disable
        tam.putLimits("cite_nomosaic", coverage, new CoverageAccessLimits(CatalogMode.HIDE, Filter.EXCLUDE, null, null));
       
        // image cropping setup
        WKTReader wkt = new WKTReader();
        MultiPolygon cropper = (MultiPolygon) wkt.read("MULTIPOLYGON(((140 -50, 150 -50, 150 -30, 140 -30, 140 -50)))");
        tam.putLimits("cite_cropmosaic", coverage, new CoverageAccessLimits(CatalogMode.HIDE, Filter.INCLUDE, cropper, null));
       
        // filter setup
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Filter filter = ff.contains(ff.property("geometry"), ff.literal(cropper));
        tam.putLimits("cite_filtermosaic", coverage, new CoverageAccessLimits(CatalogMode.HIDE, filter, null, null));
       
    }
View Full Code Here

    public void prepare() throws Exception {
       
       
        // populate the access manager
        Catalog catalog = getCatalog();
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
       
        // tile filtering setup
        CoverageInfo coverage = catalog.getCoverageByName("sf:mosaic");
        Filter green = CQL.toFilter("location like 'green%'");
        tam.putLimits("cite_mosaic1", coverage, new CoverageAccessLimits(CatalogMode.HIDE, green, null, null));
       
        // image cropping setup
        WKTReader wkt = new WKTReader();
        MultiPolygon cropper = (MultiPolygon) wkt.read("MULTIPOLYGON(((0 0, 0.5 0, 0.5 0.5, 0 0.5, 0 0)))");
        tam.putLimits("cite_mosaic2", coverage, new CoverageAccessLimits(CatalogMode.HIDE, green, cropper, null));

        // add a wms store too, if possible
        if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
            return;
        }

        // setup the wms store, resource and layer
        CatalogBuilder cb = new CatalogBuilder(catalog);
        WMSStoreInfo wms = cb.buildWMSStore("demo");
        wms.setCapabilitiesURL(RemoteOWSTestSupport.WMS_SERVER_URL
                + "service=WMS&request=GetCapabilities");
        catalog.save(wms);
        cb.setStore(wms);
        WMSLayerInfo states = cb.buildWMSLayer("topp:states");
        states.setName("rstates");
        catalog.add(states);
        LayerInfo layer = cb.buildLayer(states);
        catalog.add(layer);

        // hide the layer to cite_nostates
        tam.putLimits("cite_nostates", states, new WMSAccessLimits(CatalogMode.HIDE,
                Filter.EXCLUDE, null, false));
        // disallow getfeatureinfo on the states layer
        tam.putLimits("cite_noinfo", states, new WMSAccessLimits(CatalogMode.HIDE, Filter.INCLUDE,
                null, false));
        // cascade CQL filter, allow feature info
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Filter texas = ff.equal(ff.property("STATE_NAME"), ff.literal("Texas"), false);
        tam.putLimits("cite_texas", states,
                new WMSAccessLimits(CatalogMode.HIDE, texas, null, true));
    }
View Full Code Here

    @Override
    protected void onSetUp(SystemTestData testData) throws Exception {
        super.onSetUp(testData);

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");
        Catalog catalog = getCatalog();
        CoverageInfo world = catalog.getCoverageByName(getLayerId(MockData.WORLD));

        // limits for mr cite_noworld: can't access the world layer
        tam.putLimits("cite_noworld", world, new CoverageAccessLimits(CatalogMode.HIDE,
                Filter.EXCLUDE, null, null));

        // limits for mr cite_noworld: can't access the world layer
        tam.putLimits("cite_noworld_challenge", world, new CoverageAccessLimits(
                CatalogMode.CHALLENGE, Filter.EXCLUDE, null, null));

        // limits the area to north america
        MultiPolygon rasterFilter = (MultiPolygon) new WKTReader()
                .read("MULTIPOLYGON(((-120 30, -120 60, -60 60, -60 30, -120 30)))");
        tam.putLimits("cite_usa", world, new CoverageAccessLimits(CatalogMode.HIDE, null,
                rasterFilter, null));
    }
View Full Code Here

        catalog.add(states);
        LayerInfo layer = cb.buildLayer(states);
        catalog.add(layer);

        // populate the access manager
        TestResourceAccessManager tam = (TestResourceAccessManager) applicationContext
                .getBean("testResourceAccessManager");

        // hide the layer to cite_nostates
        tam.putLimits("cite_nostates", states, new WMSAccessLimits(CatalogMode.HIDE,
                Filter.EXCLUDE, null, false));
        // disallow getfeatureinfo on the states layer
        tam.putLimits("cite_noinfo", states, new WMSAccessLimits(CatalogMode.HIDE, Filter.INCLUDE,
                null, false));
        // cascade CQL filter, allow feature info
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Filter texas = ff.equal(ff.property("STATE_NAME"), ff.literal("Texas"), false);
        tam.putLimits("cite_texas", states,
                new WMSAccessLimits(CatalogMode.HIDE, texas, null, true));
    }
View Full Code Here

TOP

Related Classes of org.geoserver.security.TestResourceAccessManager

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.