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.

}<br />

public synchronized StatusPacket activationRequest(String username,<br />

RegistrationInfoPacket pack) throws<br />

Exception<br />

{<br />

Debugger.debug(getClass(), 1, "Activationrequest... User: " + username);<br />

used");<br />

BankAccount acc = accounts.getAccount(username);<br />

Debugger.debug(getClass(), 1, "Found account.");<br />

Debugger.debug(getClass(), 1, "Testing if activationNumber has already been<br />

if(acc.activationNumbers.contains(new Long(pack.activationNumber)))<br />

return new StatusPacket(true, "activationNumber accepted.");<br />

acc.activationNumbers.addElement(new Long(pack.activationNumber));<br />

Debugger.debug(getClass(), 1, "activationNumber has NOT been used before.");<br />

session RSsession = createRSSession();<br />

RSsession.send(new ActivationPacket(pack.activationNumber,<br />

Cryptotools.sign(super.privateKey, new<br />

Long(pack.activationNumber))));<br />

// CurrencyServer now tries to retrieve the users certificate from the<br />

registration server<br />

while(true)<br />

{<br />

RSsession.send(new RegistrationInfoPacket(pack.activationNumber));<br />

NetPacket packet = RSsession.receive();<br />

if(packet instance<strong>of</strong> ActivationCompletedPacket)<br />

{<br />

acc.cert = ((ActivationCompletedPacket) packet).certificate;<br />

Debugger.debug(getClass(), 1, "Certificate succesfully retrieved from<br />

RS.");<br />

break;<br />

}<br />

else if(packet instance<strong>of</strong> StatusPacket)<br />

{<br />

Debugger.debug(getClass(), 1, "Error retrieving certificate from RS.");<br />

return new StatusPacket(false, "Error generating certificate.");<br />

}<br />

else<br />

throw new Exception("Error in getting certificate from RS. Server<br />

responded unexpectedly.");<br />

}<br />

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

"Withdrawing the registrationFee " + Config.registrationFee + " +<br />

" + Config.registrationCoinValue<br />

+ ".");<br />

acc.withdrawNoteUpFront(Config.registrationFee + Config.registrationCoinValue);<br />

Debugger.debug(getClass(), 1, "ActivationRequest completed for user: " +<br />

username);<br />

}<br />

return new StatusPacket(true, Config.registrationCoinValue);<br />

private session createRSSession() throws Exception<br />

{<br />

Debugger.debug(getClass(), 3, "Creating new session with the RS: " +<br />

Config.RSAddress + ":" + Config.RSPort);<br />

Socket socket = new Socket(InetAddress.getByName(Config.RSAddress),<br />

Config.RSPort);<br />

return new session(socket, false, RSPublicKey, true);<br />

}<br />

public synchronized CoinSignaturePacket blindingFactor(String username,<br />

CurrencyBlindingFactorPacket cp) throws<br />

350

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

Saved successfully!

Ooh no, something went wrong!