コード例 #1
0
  @AfterClass
  public static void setbackDeploymentProperties() throws IOException {
    String properties = FileUtils.loadFileAsString(deployFile);
    if (attributesCheck != null) {
      properties =
          properties.replace("deployment.manifest.attributes.check=TRUSTED\n", attributesCheck);
    } else {
      properties = properties.replace("deployment.manifest.attributes.check=TRUSTED\n", "");
    }

    FileUtils.saveFile(properties, deployFile);
  }
コード例 #2
0
  @BeforeClass
  public static void setupDeploymentProperties() throws IOException {
    deployFile = PathsAndFiles.USER_DEPLOYMENT_FILE.getFile();
    String properties = FileUtils.loadFileAsString(deployFile);

    for (String line : properties.split("\n")) {
      if (line.contains("deployment.manifest.attribute.check")) {
        attributesCheck = line;
        properties = properties.replace(line, "deployment.manifest.attributes.check=TRUSTED\n");
      }
    }
    if (attributesCheck == null) {
      properties += "deployment.manifest.attributes.check=TRUSTED\n";
    }

    FileUtils.saveFile(properties, deployFile);
  }
コード例 #3
0
 /**
  * This method is package private for testing purposes only.
  *
  * <p>This method verify that directory exists, is directory, file and directory can be created,
  * file can be written into, and subdirectory can be written into.
  *
  * <p>Some steps may looks like redundant, but some permission settings really alow to create file
  * but not directory and vice versa. Also some settings can allow to create file or directory
  * which can not be written into. (eg ACL or network disks)
  */
 static DirectoryCheckResult testDir(File f, boolean verbose, boolean testSubdir) {
   DirectoryCheckResult result = new DirectoryCheckResult(f);
   if (!f.exists()) {
     if (verbose) {
       OutputController.getLogger()
           .log(OutputController.Level.ERROR_ALL, DirectoryCheckResult.notExistsMessage(f));
     }
     result.exists = false;
   }
   if (!f.isDirectory()) {
     if (verbose) {
       OutputController.getLogger()
           .log(OutputController.Level.ERROR_ALL, DirectoryCheckResult.notDirMessage(f));
     }
     result.isDir = false;
   }
   File testFile = null;
   boolean correctPermissions = true;
   try {
     testFile = File.createTempFile("maindir", "check", f);
     if (!testFile.exists()) {
       correctPermissions = false;
     }
     try {
       FileUtils.saveFile("ww", testFile);
       String s = FileUtils.loadFileAsString(testFile);
       if (!s.trim().equals("ww")) {
         correctPermissions = false;
       }
     } catch (Exception ex) {
       if (JNLPRuntime.isDebug()) {
         ex.printStackTrace();
       }
       correctPermissions = false;
     }
     File[] canList = f.listFiles();
     if (canList == null || canList.length == 0) {
       correctPermissions = false;
     }
     testFile.delete();
     if (testFile.exists()) {
       correctPermissions = false;
     } else {
       boolean created = testFile.mkdir();
       if (!created) {
         correctPermissions = false;
       }
       if (testFile.exists()) {
         if (testSubdir) {
           DirectoryCheckResult subdirResult = testDir(testFile, verbose, false);
           if (subdirResult.getFailures() != 0) {
             result.subDir = subdirResult;
             correctPermissions = false;
           }
           testFile.delete();
           if (testFile.exists()) {
             correctPermissions = false;
           }
         }
       } else {
         correctPermissions = false;
       }
     }
   } catch (Exception ex) {
     if (JNLPRuntime.isDebug()) {
       ex.printStackTrace();
     }
     correctPermissions = false;
   } finally {
     if (testFile != null && testFile.exists()) {
       testFile.delete();
     }
   }
   if (!correctPermissions) {
     if (verbose) {
       OutputController.getLogger()
           .log(OutputController.Level.ERROR_ALL, DirectoryCheckResult.wrongPermissionsMessage(f));
     }
     result.correctPermissions = false;
   }
   return result;
 }
 public static void prepareCopyFile(String s) throws IOException {
   String orig = FileUtils.loadFileAsString(new File(server.getDir() + "/" + s + ".jnlp"));
   String processed =
       orig.replace("codebase=\".\"", "codebase=\"" + server.getUrl().toExternalForm() + "\"");
   FileUtils.saveFile(processed, new File(server.getDir() + "/" + s + "_copy.jnlp"));
 }