Debian Codegraph @

ssl-proxies/src/main/java/org/globus/tools/ProxyDestroy.java

raw
1 /*
2 * Copyright 1999-2010 University of Chicago
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 * express or implied.
12 *
13 * See the License for the specific language governing permissions and limitations under the License.
14 */
15 package org.globus.tools;
16
17 import java.io.File;
18
19 import org.globus.common.CoGProperties;
20 import org.globus.util.Util;
21
22 /** Destroys a proxy file.
23 *<pre>
24 * Syntax: java ProxyDestroy [-dryrun][-default] [file1...]
25 * java ProxyDestroy -help\n
26 * Options
27 * -help | -usage
28 * Displays usage
29 * -dryrun
30 * Prints what files would have been destroyed
31 * file1 file2 ...
32 * Destroys files listed
33 *</pre>
34 */
35 public class ProxyDestroy {
36
37 private static final String message =
38 "\n" +
39 "Syntax: java ProxyDestroy [-dryrun] [file1...]\n" +
40 " java ProxyDestroy -help\n\n" +
41 "\tOptions\n" +
42 "\t-help | -usage\n" +
43 "\t\tDisplays usage\n" +
44 "\t-dryrun\n" +
45 "\t\tPrints what files would have been destroyed\n" +
46 "\tfile1 file2 ...\n" +
47 "\t\tDestroys files listed\n\n";
48
49 public static void main(String args[]) {
50
51 boolean dryrun = false;
52 boolean error = false;
53 boolean debug = false;
54 File file = null;
55
56 for (int i = 0; i < args.length; i++) {
57 if (args[i].equalsIgnoreCase("-dryrun")) {
58 dryrun = true;
59 } else if (args[i].equalsIgnoreCase("-help") ||
60 args[i].equalsIgnoreCase("-usage")) {
61 System.err.println(message);
62 System.exit(1);
63 } else {
64 file = new File(args[i]);
65 if (dryrun) {
66 System.out.println("Would remove " + file.getAbsolutePath());
67 continue;
68 }
69 Util.destroy(file);
70 }
71 }
72
73 String fn = CoGProperties.getDefault().getProxyFile();
74 if (fn == null) return ;
75 file = new File(fn);
76 if (dryrun) {
77 System.out.println("Would remove " + file.getAbsolutePath());
78 return;
79 }
80
81 Util.destroy(file);
82 }
83
84 }