import java.io.*; import javax.net.*; import java.net.*; import javax.net.ssl.SSLSocketFactory; import java.util.StringTokenizer; import javax.net.ssl.SSLSocket; class ImapsPlugin /*extends AbstractPlugin*/ { public String getProtocolName() { return "IMAPs"; } /* public boolean isProtocolSupported(InetAddress address) { */ public static void main(String args[]) throws java.io.IOException { // try { int port = 993; String hostname = "kmlinux.fjfi.cvut.cz"; String user = "vokac"; String password = "heslo"; SocketFactory socketFactory = SSLSocketFactory.getDefault(); SSLSocket socket = (SSLSocket)socketFactory.createSocket(hostname, port); /*boolean isAServer = false; */ socket.startHandshake(); System.out.println("ImapsPlugin: connected to host: " + hostname + " on port: " + port); // Allocate a line reader // BufferedReader lineRdr = new BufferedReader(new InputStreamReader(socket.getInputStream())); StringTokenizer t = new StringTokenizer(lineRdr.readLine()); t.nextToken();//zahod * if (t.nextToken().equals("OK")) { //user String cmd = "0001 login " + user + " " + password + "\r\n"; socket.getOutputStream().write(cmd.getBytes()); t = new StringTokenizer(lineRdr.readLine()); t.nextToken(); //zahod cislo //System.out.println(t.nextToken()); if (t.nextToken().equals("OK")){ cmd = "0002 logout\r\n"; socket.getOutputStream().write(cmd.getBytes()); t = new StringTokenizer(lineRdr.readLine()); t.nextToken(); //zahod * if (t.nextToken().equals("BYE")){ System.out.println("Podarilo se to!"); /* isAServer = true;*/ } } } // } catch(IOException e) { } /* return isAServer;*/ } //konec metody /* public boolean isProtocolSupported(InetAddress address, Map qualifiers) { return isProtocolSupported(adress); } */ }