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.

throw new Exception("Error");<br />

registered = true;<br />

}<br />

catch(Exception e)<br />

{<br />

Debugger.debug(getClass(), 1, "Certificate could not be loaded or safe<br />

does not exist. Probably first program launch.");<br />

registered = false;<br />

}<br />

//Load the blacklist<br />

try<br />

{<br />

blacklist = (Blacklist) FileHandler.readObject(new<br />

File(Config.blacklistFilePath));<br />

Debugger.debug(getClass(), 1, "Loaded blacklist succesfully.");<br />

}<br />

catch(Exception e)<br />

{<br />

Debugger.debug(getClass(), 1, "Blacklist could not be loaded. Creating<br />

new.");<br />

blacklist = new Blacklist();<br />

}<br />

//Load the whitelist<br />

try<br />

{<br />

whitelist = (Whitelist) FileHandler.readObject(new<br />

File(Config.whitelistFilePath));<br />

Debugger.debug(getClass(), 1, "Loaded whitelist succesfully.");<br />

}<br />

catch(Exception e)<br />

{<br />

Debugger.debug(getClass(), 1, "Whitelist could not be loaded. Creating<br />

new.");<br />

whitelist = new Whitelist();<br />

}<br />

safe = new SafeHandler();<br />

currencyExchangeClient = new CurrencyExchangeClient();<br />

gui.init(this);<br />

if(registered)<br />

{<br />

byte[] testbytes =<br />

{2, 99, 7, 45, 56, 7, 7, 89, 98, 7, 78, 4, 12, 3, 4, 4, 23, 22, 3, 4,<br />

45, 45, 32};<br />

boolean passed = (Cryptotools.verify((RSAPublicKey)<br />

getCertificate().getPublicKey(),<br />

Cryptotools.sign(getPrivateKey(),<br />

testbytes), testbytes));<br />

Debugger.debug(getClass(), 1,<br />

"Test <strong>of</strong> the received certificate with the privatkey..." +<br />

(passed ? "passed" : "failed"));<br />

if( ! passed)<br />

registered = false;<br />

}<br />

if(!registered)<br />

{<br />

Debugger.debug(getClass(), 1, "Starting registration procedure...");<br />

gui.showRegistrationDialog();<br />

}<br />

else<br />

gui.show();<br />

}<br />

catch(Throwable e)<br />

201

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

Saved successfully!

Ooh no, something went wrong!