|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread org.schwering.irc.lib.IRCConnection org.schwering.irc.lib.SSLIRCConnection
org.schwering.irc.lib.ssl.SSLDefaultTrustManager
.
The SSL extension of the IRCConnection
class.
Note that this class is deprecated. The SSL supporting classes moved
to org.schwering.irc.lib.ssl
since IRClib 1.10.
The IRC server you want to connect to must accept SSL connections.
Otherwise you cannot connect to it with an instance of
SSLIRCConnection
. IRC servers which accept SSL connections are
really very rare, because SSL means a high load for the server.
The following sample code tries to establish an IRC connection to an
IRC server which must support SSL. Differences to the code which
demonstrates the use of of the IRCConnection
class are printed in bold font:
/* * The following code of a class which imports org.schwering.irc.lib.* * prepares an SSL IRC connection and then tries to establish the * connection. The server is "irc.somenetwork.com", the ports are * the default SSL port (443) and the port used on most SSL IRC servers * (994). No password is used (null). The nickname is "Foo" and * the realname is "Mr. Foobar". The username "foobar". * Because of setDaemon(true), the JVM exits even if this thread is * running. * By setting an instance of SSLDefaultTrustManager as TrustManager * (which is also done implicitely by the SSLIRCConnection class if no * TrustManager is set until the connect method is invoked), the * X509Certificate is accepted automatically. Of course, you can write * your own TrustManager. For example, you could write a class which * extends SSLDefaultTrustManager and overrides its checkServerTrusted * method. In the new checkServerTrusted method, you could ask the user * to accept or reject the certificate. * An instance of the class MyListener which must implement * IRCActionListener is set as event-listener for the connection. * The connection is told to parse out mIRC color codes and to enable * automatic PING? PONG! replies. */ SSLIRCConnection conn = new SSLIRCConnection( "irc.somenetwork.com", new int[] { 443, 994 }, null, "Foo", "Mr. Foobar", "foo@bar.com" ); conn.addIRCEventListener(new MyListener()); conn.addTrustManager(new SSLDefaultTrustManager()); conn.setDaemon(true); conn.setColors(false); conn.setPong(true); try { conn.connect(); // Try to connect!!! Don't forget this!!! } catch (IOException ioexc) { ioexc.printStackTrace(); }
The serverpassword isn't needed in most cases. You can give
null
or ""
instead as done in this example.
TrustManager
s can be added and removed until the
connect
method is invoked. If no TrustManager
s are
set until then, an SSLDefaultTrustManager
is
set automatically. It accepts all X509 certificates.
IRCConnection
,
SSLDefaultTrustManager
,
TrustManager
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
SSLIRCConnection(java.lang.String host,
int[] ports,
java.lang.String pass,
java.lang.String nick,
java.lang.String username,
java.lang.String realname)
Deprecated. Creates a new IRC connection with secure sockets (SSL). |
|
SSLIRCConnection(java.lang.String host,
int portMin,
int portMax,
java.lang.String pass,
java.lang.String nick,
java.lang.String username,
java.lang.String realname)
Deprecated. Creates a new IRC connection with secure sockets (SSL). |
Method Summary | |
void |
addTrustManager(com.sun.net.ssl.TrustManager trustManager)
Deprecated. Adds a new TrustManager . |
void |
connect()
Deprecated. Establish a connection to the server. |
com.sun.net.ssl.TrustManager[] |
getTrustManagers()
Deprecated. Returns the set TrustManager s. |
boolean |
removeTrustManager(com.sun.net.ssl.TrustManager trustManager)
Deprecated. Removes one TrustManager . |
Methods inherited from class org.schwering.irc.lib.IRCConnection |
addIRCEventListener, close, doAway, doAway, doInvite, doIson, doJoin, doJoin, doKick, doKick, doList, doList, doMode, doMode, doNames, doNames, doNick, doNotice, doPart, doPart, doPong, doPrivmsg, doQuit, doQuit, doTopic, doTopic, doUserhost, doWho, doWhois, doWhowas, getColors, getEncoding, getHost, getNick, getPassword, getPong, getPort, getPorts, getRealname, getTimeout, getUsername, isConnected, removeIRCEventListener, run, send, setColors, setEncoding, setPong, setTimeout, toString |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SSLIRCConnection(java.lang.String host, int[] ports, java.lang.String pass, java.lang.String nick, java.lang.String username, java.lang.String realname)
int[]
. Thus, also ports like 994, 6000 and 6697 can be
selected.connect
method. Before
invoking it, you should set the IRCEventListener
, optionally
the TrustManager
, if you don't want to use the
SSLDefaultTrustManager
which accepts the X509 certificate
automatically, and other settings.""
or null
for the password
argument in the constructor.
host
- The hostname of the server we want to connect to.ports
- The portrange to which we want to connect.pass
- The password of the IRC server. If your server isn't
secured by a password (that's normal), use
null
or ""
.nick
- The nickname for the connection. Is used to register the
connection.username
- The username. Is used to register the connection.realname
- The realname. Is used to register the connection.
java.lang.IllegalArgumentException
- If the host
or
ports
is null
or
ports
' length is
0
.connect()
public SSLIRCConnection(java.lang.String host, int portMin, int portMax, java.lang.String pass, java.lang.String nick, java.lang.String username, java.lang.String realname)
int
s. Thus, only a portrange from port x
to
port y
like from port 6000 to 6010 can be selected.connect
method. Before
invoking it, you should set the IRCEventListener
, optionally
the TrustManager
, if you don't want to use the
SSLDefaultTrustManager
which accepts the X509 certificate
automatically, and other settings.""
or null
for the password
argument in the constructor.
host
- The hostname of the server we want to connect to.portMin
- The beginning of the port range we are going to connect
to.portMax
- The ending of the port range we are going to connect to.pass
- The password of the IRC server. If your server isn't
secured by a password (that's normal), use
null
or ""
.nick
- The nickname for the connection. Is used to register the
connection.username
- The username. Is used to register the connection.realname
- The realname. Is used to register the connection.
java.lang.IllegalArgumentException
- If the host
is
null
.connect()
Method Detail |
public void connect() throws java.io.IOException
IOException
. If anything SSL related fails (for example
conflicts with the algorithms or during the handshaking), a
SSLException
is thrown. connect
only one time.
connect
in class IRCConnection
java.io.IOException
- If an I/O error occurs.
javax.net.ssl.SSLException
- If anything with the secure sockets fails.
java.net.SocketException
- If the connect
method was already
invoked.IRCConnection.isConnected()
,
IRCConnection.doQuit()
,
IRCConnection.doQuit(String)
,
IRCConnection.close()
public void addTrustManager(com.sun.net.ssl.TrustManager trustManager)
TrustManager
. com.sun.net.ssl.TrustManager
s of the JSSE API and not the
javax.net.ssl.TrustManager
s of the Java 1.4 API!
trustManager
- The TrustManager
object which is to add.removeTrustManager(TrustManager)
,
getTrustManagers()
public boolean removeTrustManager(com.sun.net.ssl.TrustManager trustManager)
TrustManager
.com.sun.net.ssl.TrustManager
s of the JSSE API and not the
javax.net.ssl.TrustManager
s of the Java 1.4 API!
trustManager
- The TrustManager
object which is to
remove.
true
if a TrustManager
was removed.addTrustManager(TrustManager)
,
getTrustManagers()
public com.sun.net.ssl.TrustManager[] getTrustManagers()
TrustManager
s. The default
TrustManager
is an instance of
SSLDefaultTrustManager
, which is set when you invoke the
connect
method without having set another
TrustManager
.com.sun.net.ssl.TrustManager
s of the JSSE API and not the
javax.net.ssl.TrustManager
s of the Java 1.4 API!
TrustManager
s.addTrustManager(TrustManager)
,
removeTrustManager(TrustManager)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |