29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

10.1.6.c IMAPProxy<br />

package <strong>Spam</strong>Cash.Client.Proxy;<br />

import javax.mail.*;<br />

import javax.mail.search.*;<br />

import javax.mail.internet.*;<br />

import com.sun.mail.imap.IMAPFolder;<br />

import java.util.*;<br />

import <strong>Spam</strong>Cash.Client.Control;<br />

import <strong>Spam</strong>Cash.Utilities.*;<br />

import <strong>Spam</strong>Cash.Utilities.*;<br />

import <strong>Spam</strong>Cash.Utilities.Debugger;<br />

public class IMAPProxy extends AbstractNonBlockingProxy<br />

{<br />

private static Class className;<br />

private static String username, password;<br />

private static Vector inboxCheckedUids;<br />

private static String currentFolder="",commandForTheClient="";<br />

private static boolean idle;<br />

public IMAPProxy(Control control, int port) throws Exception<br />

{<br />

super(control, port, Config.maxIMAPConnections);<br />

this.className = getClass();<br />

inboxCheckedUids = new Vector();<br />

idle = false;<br />

Debugger.debug(className, 1, "Proxy is ready on port " + port);<br />

}<br />

protected Object testClientCommand(String command)<br />

{<br />

//Debugger.debug(className, 2, "Testing command...: " + command);<br />

if(parseArgument(command, 1).equalsIgnoreCase("LOGIN"))<br />

{<br />

username = parseArgument(command, 2);<br />

password = parseArgument(command, 3);<br />

//remove the "'s<br />

username = username.substring(1, username.length() - 1);<br />

password = password.substring(1, password.length() - 1);<br />

Debugger.debug(className, 2,<br />

"LOGIN detected. Saved username(" + username + ") and<br />

password(" + password + ").");<br />

}<br />

if(parseArgument(command, 1).equalsIgnoreCase("IDLE"))<br />

idle = true;<br />

else<br />

idle = false;<br />

// Debugger.debug(className, 3, "testClientCommand: set IDLE = "+idle);<br />

/*if( -1 != command.indexOf("LOGOUT"))<br />

{<br />

username = "";<br />

password = "";<br />

Debugger.debug(className, 2, "LOGOUT detected. Deleted username and<br />

password.");<br />

}*/<br />

//The client is changing the folder...<br />

276

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!