/**
   * 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);
    }
  }
  /**
   * validates the passed object as a response to a OWS request. The validity of the response may is
   * assigned to specific user rights. If the passed user is <>null this will be evaluated. <br>
   * the reponse may contain three valid kinds of objects:
   *
   * <ul>
   *   <li>a xml encoded exception
   *   <li>a GML document
   *   <li>a XML document
   *   <li>any other kind of document that is valid against the formats defined for GetRecord in the
   *       capabilities
   * </ul>
   *
   * Each of these types can be identified by the mime-type of the response that is also passed to
   * the method. <br>
   * If something basic went wrong it is possible that not further specified kind of object is
   * passed as response. In this case the method will throw an
   * <tt>InvalidParameterValueException</tt> to avoid sending bad responses to the client.
   *
   * @param service service which produced the response (WMS, WFS ...)
   * @param response
   * @param mime mime-type of the response
   * @param user
   * @return the response array
   * @throws InvalidParameterValueException
   */
  @Override
  public byte[] validateResponse(String service, byte[] response, String mime, User user)
      throws InvalidParameterValueException {

    Request req = policy.getRequest(service, "GetRecord");
    // request is valid because no restrictions are made
    if (req.isAny() || req.getPostConditions().isAny()) {
      return response;
    }

    // Condition condition = req.getPostConditions();

    if (MimeTypeMapper.isKnownOGCType(mime)) {
      // if the mime-type isn't an image type but a known
      // OGC mime-type it must be an XML document.
      // probably it is an exception but it also could be
      // a GML document
      response = validateXML(response, mime, user);
    } else if (mime.equals("text/xml")) {
      // if the mime-type isn't an image type but 'text/xml'
      // it could be an exception
      response = validateXML(response, mime, user);
    } else {
      throw new InvalidParameterValueException(UNKNOWNMIMETYPE + mime);
    }

    return response;
  }
示例#3
0
 /**
  * adds a request/condintions to the <tt>Policy</tt>
  *
  * @see #getRequests()
  * @param request
  */
 public void addRequest(Request request) {
   String key = request.getService() + ':' + request.getName();
   this.requests.put(key, request);
 }