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.

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

"Pendingmailserial " + ((MailInformation)<br />

pendingMails.elementAt(i)).c.getSerialNumber()<br />

+ " =? " + sn);<br />

if(((MailInformation) pendingMails.elementAt(i)).c.getSerialNumber() == sn)<br />

return true;<br />

}<br />

return false;<br />

}<br />

public void transferCoin(MailInformation m, Certificate cert, RSAPrivateKey key)<br />

throws Exception<br />

{<br />

if(pendingMails.indexOf(m) == -1)<br />

throw new Exception("Could not find " + m);<br />

}<br />

// We can now sign the contents <strong>of</strong> the list (type 2)<br />

m.c.getTransactionlist().signList(cert, key);<br />

m.c.setType(Coin.A_TYPE);<br />

coinHistory.earnedCoin(m.c);<br />

safe.addCoin(m.c);<br />

pendingMails.remove(m);<br />

saveToFile();<br />

public boolean deleteCoinWithSerial(long serial)<br />

{<br />

return safe.deleteCCoin(serial);<br />

}<br />

public Coin getCoinWithSerial(long serial)<br />

{<br />

return coinHistory.getCoinWithSerial(serial);<br />

}<br />

/**<br />

* Retrieves 'numberOfCoins' coins from the safe.<br />

* @param numberOfCoins int<br />

* @return Coin[]<br />

*/<br />

public Coin[] getCoins(int numberOfCoins) throws Exception<br />

{<br />

if(!isOpen())<br />

throw new Exception("The safe is not open. Cannot retrieve " + numberOfCoins<br />

+ " coins.");<br />

if(numberOfCoins > safe.getNumberOfACoins())<br />

throw new Exception("There is only " + safe.getNumberOfACoins()<br />

+ " coins available in the safe. Could not retrieve " +<br />

numberOfCoins + " coins.");<br />

}<br />

Coin[] c = safe.getACoins(numberOfCoins);<br />

saveToFile();<br />

return c;<br />

public Coin[] getCoinsToSend(int numberOfCoins, Address[] receivers) throws Exception<br />

{<br />

if(!isOpen())<br />

throw new Exception("The safe is not open. Cannot retrieve " + numberOfCoins<br />

+ " coins.");<br />

if(numberOfCoins > safe.getNumberOfACoins())<br />

throw new Exception("There is only " + safe.getNumberOfACoins()<br />

+ " coins available in the safe. Could not retrieve " +<br />

numberOfCoins + " coins.");<br />

Coin[] c = safe.getBCoins(numberOfCoins, receivers);<br />

saveToFile();<br />

return c;<br />

304

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

Saved successfully!

Ooh no, something went wrong!