KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > externaltools > GPGPlugin


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.externaltools;
17
18 import java.io.File JavaDoc;
19 import java.net.MalformedURLException JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import org.columba.core.base.OSInfo;
23
24
25 /**
26  * Plugin for the aspell spell-checking package.
27  *
28  * @author fdietz
29  */

30 public class GPGPlugin extends AbstractExternalToolsPlugin {
31     protected static File JavaDoc defaultLinux = new File JavaDoc("/usr/bin/gpg");
32     protected static File JavaDoc defaultLocalLinux = new File JavaDoc("/usr/local/bin/gpg");
33
34     /* GPG for windows is an executable-only download, fortunately there is
35  * a windows registry file included in the download and has this as the
36  * default installation path in it. While users will probably install GPG
37  * into many other places, this is atleast a best-guess start.
38  */

39     protected static File JavaDoc defaultWin = new File JavaDoc("C:\\GnuPG\\gpg.exe");
40     protected static URL JavaDoc websiteURL;
41
42     static {
43         try {
44             websiteURL = new URL JavaDoc("http://www.gnupg.org/");
45         } catch (MalformedURLException JavaDoc mue) {
46         }
47
48         //does not happen
49
}
50
51     /**
52  * Construct the default GPG plugin.
53  */

54     public GPGPlugin() {
55         super();
56     }
57
58     public String JavaDoc getDescription() {
59         return "<html><body><p>GnuPG is a complete and free replacement for PGP.</p><p>Because it does not use the patented IDEA algorithm, it can be used without any restrictions. GnuPG is a RFC2440 (OpenPGP) compliant application.</p><p>GnuPG itself is a commandline tool without any graphical stuff. It is the real crypto engine which can be used directly from a command prompt, from shell scripts or by other programs. Therefore it can be considered as a backend for other applications.</p></body></html>";
60     }
61
62     public URL JavaDoc getWebsite() {
63         return websiteURL;
64     }
65
66     public File JavaDoc locate() {
67         /* If this is a unix-based system, check the 2 best-known areas for the
68  * gpg binary.
69  */

70         if (OSInfo.isLinux() || OSInfo.isSolaris()) {
71             if (defaultLinux.exists()) {
72                 return defaultLinux;
73             } else if (defaultLocalLinux.exists()) {
74                 return defaultLocalLinux;
75             }
76         }
77
78         /* RIYAD: The Prefs API cannot be used to read the Window's registry,
79  * it is coded to use the registry (if available) as a backing store
80  * on in the SOFTWARE/JavaSoft/Prefs registry keys for HKEY_CURRENT_USER
81  * and HKEY_LOCAL_MACHINE paths. I have seen a few java apps that use
82  * the Windows registry and they all required a native lib to do it.
83  */

84         /* If this is windows, check the default installation location for the
85  * gpg.exe binary.
86  */

87         if (OSInfo.isWin32Platform() && defaultWin.exists()) {
88             return defaultWin;
89         }
90
91         /* Couldn't find anything, so return null and let the wizard ask the
92  * user.
93  */

94         return null;
95     }
96 }
97
Popular Tags