01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * DrFTPD is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with DrFTPD; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.drftpd.plugins;
19:
20: import net.sf.drftpd.FatalException;
21:
22: import org.apache.log4j.Logger;
23:
24: import org.drftpd.BlindTrustManager;
25:
26: import java.io.IOException;
27:
28: import java.security.GeneralSecurityException;
29:
30: import java.util.Properties;
31:
32: import javax.net.ssl.SSLContext;
33: import javax.net.ssl.TrustManager;
34:
35: /**
36: * @author mog
37: * @version $Id: SiteBotSSL.java 753 2004-11-03 16:46:50Z mog $
38: */
39: public class SiteBotSSL extends SiteBot {
40: private static final Logger logger = Logger
41: .getLogger(SiteBot.class);
42: private boolean _useSSL;
43:
44: public SiteBotSSL() throws IOException {
45: super ();
46: }
47:
48: protected void reload(Properties ircCfg) throws IOException {
49: _useSSL = ircCfg.getProperty("irc.ssl", "false").equals("true");
50: logger.debug("useSSL: " + _useSSL);
51: super .reload(ircCfg);
52: }
53:
54: public void connect() throws IOException {
55: if (_useSSL) {
56: try {
57: SSLContext ctx = SSLContext.getInstance("TLS");
58: TrustManager[] tms = { new BlindTrustManager() };
59:
60: ctx.init(null, tms, null);
61: _conn.connect(ctx.getSocketFactory().createSocket(
62: _server, _port), _server);
63:
64: return;
65: } catch (GeneralSecurityException e) {
66: throw new FatalException(e);
67: }
68: }
69:
70: super.connect();
71: }
72: }
|