import java.io.*; import javax.net.*; import java.net.*; import javax.net.ssl.SSLSocketFactory; import java.util.StringTokenizer; import javax.net.ssl.SSLSocket; class Pop3sPlugin /*extends AbstractPlugin*/ { public String getProtocolName() { return "POP3s"; } /* public boolean isProtocolSupported(InetAddress address) { */ public static void main(String args[]) throws java.io.IOException { // try { int port = 995; 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("Pop3Plugin: connected to host: " + hostname + " on port: " + port); // Allocate a line reader // BufferedReader lineRdr = new BufferedReader(new InputStreamReader(socket.getInputStream())); // Tokenize the Banner Line, and check the first // line for a valid return. // // Server response should start with: "+OK" // StringTokenizer t = new StringTokenizer(lineRdr.readLine()); if (t.nextToken().equals("+OK")) { //user String cmd = "user " + user + "\r\n"; socket.getOutputStream().write(cmd.getBytes()); t = new StringTokenizer(lineRdr.readLine()); if (t.nextToken().equals("+OK")){ cmd = "pass " + password + "\r\n"; socket.getOutputStream().write(cmd.getBytes()); t = new StringTokenizer(lineRdr.readLine()); if (t.nextToken().equals("+OK")){ // POP3 server should recoginize the QUIT command // cmd = "QUIT\r\n"; socket.getOutputStream().write(cmd.getBytes()); // // Token the response to the QUIT command // // Server response should start with: "+OK" // t = new StringTokenizer(lineRdr.readLine()); if (t.nextToken().equals("+OK")){ 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); } */ }