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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

lists.");<br />

}<br />

}<br />

}<br />

//If we have reached the end <strong>of</strong> a list<br />

//We should blacklist someone<br />

if(listA.length() - 1 == i || listB.length() - 1 == i)<br />

{<br />

//Debugger.debug(getClass(), 1, "No more elements in one <strong>of</strong> the<br />

addToBlacklist(listA.elementAt(i).getCertificate(), i);<br />

return;<br />

}<br />

i = i + 2;<br />

}<br />

catch(Exception e)<br />

{<br />

//Debugger.debug(getClass(),1,"Error while blacklisting, noone is<br />

blacklisted",e);<br />

}<br />

}<br />

private boolean verifyIntegrity(Transactionlist list,long serial)<br />

{<br />

try<br />

{<br />

return list.verify(RSCert, CESCert,serial);<br />

}<br />

catch(Exception ex)<br />

{<br />

//Debugger.debug(getClass(), 1, "SHA1-hash could not be calculated.");<br />

return false;<br />

}<br />

}<br />

private synchronized void addToBlacklist(Certificate cert, int position)<br />

{<br />

blacklist.add(cert);<br />

try<br />

{<br />

FileHandler.writeObject(blacklist, new File(Config.blacklistFilePath));<br />

}<br />

catch(Exception ex)<br />

{<br />

//Debugger.debug(getClass(), 1, "Blacklist could not be written to disk.");<br />

}<br />

//Debugger.debug(getClass(), 1, "Certificate at position " + position + " has<br />

been blacklisted. Contents: "+((X509Certificate) cert).getSubjectDN().getName());<br />

}<br />

public void shutdown() throws Exception<br />

{<br />

System.out.println("Rate:" +count/((System.currentTimeMillis()-time)/1000)+" pr.<br />

sek");<br />

}<br />

}<br />

10.4.4.c BLSCommunicationThread<br />

package <strong>Spam</strong>Cash.Servers.BLS;<br />

import java.net.Socket;<br />

import java.security.Key;<br />

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

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

import <strong>Spam</strong>Cash.Servers.CommunicationThread;<br />

public class BLSCommunicationThread extends CommunicationThread<br />

340

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

Saved successfully!

Ooh no, something went wrong!