< prev index next >

test/lib/jdk/test/lib/SecurityTools.java

Print this page




  66 
  67         Path p = Paths.get(RESPONSE_FILE);
  68         if (!Files.exists(p)) {
  69             Files.createFile(p);
  70         }
  71         pb.redirectInput(ProcessBuilder.Redirect.from(new File(RESPONSE_FILE)));
  72 
  73         try {
  74             return execute(pb);
  75         } finally {
  76             Files.delete(p);
  77         }
  78     }
  79 
  80     // Only call this if there is no white space in every argument
  81     public static OutputAnalyzer keytool(String args) throws Exception {
  82         return keytool(args.split("\\s+"));
  83     }
  84 
  85     public static OutputAnalyzer keytool(String... args) throws Exception {
  86         return keytool(List.of(args));
  87     }
  88 
  89     public static void setResponse(String... responses) throws IOException {
  90         String text;
  91         if (responses.length > 0) {
  92             text = Stream.of(responses).collect(
  93                     Collectors.joining("\n", "", "\n"));
  94         } else {
  95             text = "";
  96         }
  97         Files.write(Paths.get(RESPONSE_FILE), text.getBytes());
  98     }
  99 
 100     // jarsigner
 101 
 102     public static OutputAnalyzer jarsigner(List<String> args)
 103             throws Exception {
 104         return execute(getProcessBuilder("jarsigner", args));
 105     }
 106 


 108         try {
 109             OutputAnalyzer oa = ProcessTools.executeCommand(pb);
 110             System.out.println("Exit value: " + oa.getExitValue());
 111             return oa;
 112         } catch (Throwable t) {
 113             if (t instanceof Exception) {
 114                 throw (Exception) t;
 115             } else {
 116                 throw new Exception(t);
 117             }
 118         }
 119     }
 120 
 121     // Only call this if there is no white space in every argument
 122     public static OutputAnalyzer jarsigner(String args) throws Exception {
 123 
 124         return jarsigner(args.split("\\s+"));
 125     }
 126 
 127     public static OutputAnalyzer jarsigner(String... args) throws Exception {
 128         return jarsigner(List.of(args));
 129     }
 130 }
 131 


  66 
  67         Path p = Paths.get(RESPONSE_FILE);
  68         if (!Files.exists(p)) {
  69             Files.createFile(p);
  70         }
  71         pb.redirectInput(ProcessBuilder.Redirect.from(new File(RESPONSE_FILE)));
  72 
  73         try {
  74             return execute(pb);
  75         } finally {
  76             Files.delete(p);
  77         }
  78     }
  79 
  80     // Only call this if there is no white space in every argument
  81     public static OutputAnalyzer keytool(String args) throws Exception {
  82         return keytool(args.split("\\s+"));
  83     }
  84 
  85     public static OutputAnalyzer keytool(String... args) throws Exception {
  86         return keytool(Arrays.asList(args));
  87     }
  88 
  89     public static void setResponse(String... responses) throws IOException {
  90         String text;
  91         if (responses.length > 0) {
  92             text = Stream.of(responses).collect(
  93                     Collectors.joining("\n", "", "\n"));
  94         } else {
  95             text = "";
  96         }
  97         Files.write(Paths.get(RESPONSE_FILE), text.getBytes());
  98     }
  99 
 100     // jarsigner
 101 
 102     public static OutputAnalyzer jarsigner(List<String> args)
 103             throws Exception {
 104         return execute(getProcessBuilder("jarsigner", args));
 105     }
 106 


 108         try {
 109             OutputAnalyzer oa = ProcessTools.executeCommand(pb);
 110             System.out.println("Exit value: " + oa.getExitValue());
 111             return oa;
 112         } catch (Throwable t) {
 113             if (t instanceof Exception) {
 114                 throw (Exception) t;
 115             } else {
 116                 throw new Exception(t);
 117             }
 118         }
 119     }
 120 
 121     // Only call this if there is no white space in every argument
 122     public static OutputAnalyzer jarsigner(String args) throws Exception {
 123 
 124         return jarsigner(args.split("\\s+"));
 125     }
 126 
 127     public static OutputAnalyzer jarsigner(String... args) throws Exception {
 128         return jarsigner(Arrays.asList(args));
 129     }
 130 }
 131 
< prev index next >