return new SecuredSimpleFeatureCollection((SimpleFeatureCollection) object, policy); } else if (FeatureCollection.class.isAssignableFrom(clazz)) { return new SecuredFeatureCollection((FeatureCollection) object, policy);
public void accepts( org.opengis.feature.FeatureVisitor visitor, org.opengis.util.ProgressListener progress) throws IOException { if (canDelegate(visitor)) { delegate.accepts(visitor, progress); } else { super.accepts(visitor, progress); } }
SecuredSimpleFeatureCollection( FeatureCollection<SimpleFeatureType, SimpleFeature> delegate, WrapperPolicy policy) { super(delegate, policy); if (policy.getLimits() instanceof VectorAccessLimits) { List<PropertyName> properties = ((VectorAccessLimits) policy.getLimits()).getReadAttributes(); if (properties == null) { this.readSchema = getSchema(); } else { List<String> names = new ArrayList<String>(); for (PropertyName property : properties) { names.add(property.getPropertyName()); } String[] nameArray = (String[]) names.toArray(new String[names.size()]); try { this.readSchema = DataUtilities.createSubType(getSchema(), nameArray); } catch (SchemaException e) { // should just not happen throw new RuntimeException(e); } } } else { this.readSchema = getSchema(); } }
private void assertOptimalVisit(FeatureVisitor visitor, WrapperPolicy policy) throws IOException { SecuredSimpleFeatureCollection secured = new SecuredSimpleFeatureCollection(collection, policy); secured.accepts(visitor, null); assertSame(lastVisitor, visitor); } }
@Test public void testMaxOnHiddenField() throws SchemaException, IOException { MaxVisitor visitor = new MaxVisitor(CommonFactoryFinder.getFilterFactory2().property("value")); PropertyName geom = CommonFactoryFinder.getFilterFactory2().property("the_geom"); WrapperPolicy policy = WrapperPolicy.hide( new VectorAccessLimits( CatalogMode.HIDE, Arrays.asList(geom), null, null, null)); SecuredSimpleFeatureCollection secured = new SecuredSimpleFeatureCollection(collection, policy); secured.accepts(visitor, null); assertNull(lastVisitor); }