/** * validates the passed WMS GetMap request against a User- and Rights-Management DB. * * @param wmsreq * @throws InvalidParameterValueException */ private void validateAgainstRightsDB(GetLegendGraphic wmsreq, User user) throws InvalidParameterValueException, UnauthorizedException { if (user == null) { throw new UnauthorizedException("no access to anonymous user"); } // create feature that describes the map request FeatureProperty[] fps = new FeatureProperty[7]; fps[0] = FeatureFactory.createFeatureProperty(new QualifiedName("version"), wmsreq.getVersion()); fps[1] = FeatureFactory.createFeatureProperty( new QualifiedName("width"), new Integer(wmsreq.getWidth())); fps[2] = FeatureFactory.createFeatureProperty( new QualifiedName("height"), new Integer(wmsreq.getHeight())); fps[3] = FeatureFactory.createFeatureProperty(new QualifiedName("format"), wmsreq.getFormat()); fps[4] = FeatureFactory.createFeatureProperty( new QualifiedName("exceptions"), wmsreq.getExceptions()); fps[5] = FeatureFactory.createFeatureProperty(new QualifiedName("sld"), wmsreq.getSLD()); fps[6] = FeatureFactory.createFeatureProperty(new QualifiedName("style"), wmsreq.getStyle()); Feature feature = FeatureFactory.createFeature("id", glgFT, fps); if (securityConfig.getProxiedUrl() == null) { handleUserCoupledRules(user, feature, wmsreq.getLayer(), "Layer", GETLEGENDGRAPHIC); } else { handleUserCoupledRules( user, feature, "[" + securityConfig.getProxiedUrl() + "]:" + wmsreq.getLayer(), "Layer", GETLEGENDGRAPHIC); } }
/** * validates the incomming GetLegendGraphic request against the policy assigend to a validator * * @param request request to validate * @param user name of the user who likes to perform the request (can be null) */ @Override public void validateRequest(OGCWebServiceRequest request, User user) throws InvalidParameterValueException, UnauthorizedException { userCoupled = false; Request req = policy.getRequest("WMS", "GetLegendGraphic"); // request is valid because no restrictions are made if (req.isAny() || req.getPreConditions().isAny()) { return; } Condition condition = req.getPreConditions(); GetLegendGraphic wmsreq = (GetLegendGraphic) request; validateVersion(condition, wmsreq.getVersion()); validateLayer(condition, wmsreq.getLayer(), wmsreq.getStyle()); validateExceptions(condition, wmsreq.getExceptions()); validateFormat(condition, wmsreq.getFormat()); validateMaxWidth(condition, wmsreq.getWidth()); validateMaxHeight(condition, wmsreq.getHeight()); validateSLD(condition, wmsreq.getSLD()); if (userCoupled) { validateAgainstRightsDB(wmsreq, user); } }