コード例 #1
0
ファイル: ReportHandler.java プロジェクト: blagerweij/milton2
 @Override
 public void processExistingResource(
     HttpManager manager, Request request, Response response, Resource resource)
     throws NotAuthorizedException, BadRequestException, ConflictException {
   try {
     org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
     // Prevent possibily of malicious clients using remote the parser to load remote resources
     builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
     org.jdom.Document doc = builder.build(request.getInputStream());
     String reportName = doc.getRootElement().getName();
     Report r = reports.get(reportName);
     if (r == null) {
       log.error("report not known: " + reportName);
       throw new BadRequestException(resource);
     } else {
       log.info("process report: " + reportName + " with : " + r.getClass());
       String xml = r.process(request.getHostHeader(), request.getAbsolutePath(), resource, doc);
       if (log.isTraceEnabled()) {
         log.trace("Report XML:\n" + xml);
       }
       response.setStatus(Response.Status.SC_MULTI_STATUS);
       response.setContentTypeHeader("text/xml");
       response.setEntity(new ByteArrayEntity(xml.getBytes("UTF-8")));
     }
   } catch (JDOMException ex) {
     java.util.logging.Logger.getLogger(ReportHandler.class.getName()).log(Level.SEVERE, null, ex);
   } catch (ReadingException ex) {
     throw new RuntimeException(ex);
   } catch (WritingException ex) {
     throw new RuntimeException(ex);
   } catch (IOException ex) {
     throw new RuntimeException(ex);
   }
 }
コード例 #2
0
 @Override
 public RootFolder peekRootFolder() {
     Request req = HttpManager.request();
     if (req == null) {
         return null;
     }
     return getRootFolder(req.getHostHeader(), req, false);
 }
コード例 #3
0
ファイル: LockHandler.java プロジェクト: yug64/milton2
  @Override
  public void process(HttpManager manager, Request request, Response response)
      throws NotAuthorizedException, BadRequestException {
    if (!handlerHelper.checkExpects(responseHandler, request, response)) {
      return;
    }

    String host = request.getHostHeader();
    String url = HttpManager.decodeUrl(request.getAbsolutePath());

    // Find a resource if it exists
    Resource r = manager.getResourceFactory().getResource(host, url);
    if (r != null) {
      log.debug("locking existing resource: " + r.getName());
      processExistingResource(manager, request, response, r);
    } else {
      log.debug("lock target doesnt exist, attempting lock null..");
      processNonExistingResource(manager, request, response, host, url);
    }
  }
コード例 #4
0
 @Override
 public void appendChallenges(Resource resource, Request request, List<String> challenges) {
   String realm = securityManager.getRealm(request.getHostHeader());
   challenges.add("Basic realm=\"" + realm + "\"");
 }