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.

this.transferExpirationTime = a.transferExpirationTime;<br />

if (a.transactionList instance<strong>of</strong> UnencryptedTransactionlist)<br />

this.transactionList = new<br />

UnencryptedTransactionlist((UnencryptedTransactionlist)a.transactionList);<br />

else<br />

this.transactionList = new<br />

EncryptedTransactionlist(((EncryptedTransactionlist)a.transactionList));<br />

}<br />

public Coin(byte[] data) throws Exception<br />

{<br />

ByteArrayInputStream bis = new ByteArrayInputStream(data);<br />

ObjectInputStream ois = new ObjectInputStream(bis);<br />

}<br />

this.type = ((Integer)ois.readObject()).intValue();<br />

this.value = ((Double)ois.readObject()).doubleValue();<br />

this.serialNumber = ((Long)ois.readObject()).longValue();<br />

this.expirationTime = ((Long)ois.readObject()).longValue();<br />

this.transferExpirationTime = ((Long)ois.readObject()).longValue();<br />

this.maxNumberOfUsages = ((Integer)ois.readObject()).intValue();<br />

Object input = ois.readObject();<br />

if (input instance<strong>of</strong> EncryptedTransactionlist)<br />

this.transactionList = (EncryptedTransactionlist) input;<br />

else<br />

this.transactionList = (UnencryptedTransactionlist) input;<br />

this.signature = (byte[])ois.readObject();<br />

this.signHash = ((String)ois.readObject());<br />

public byte[] getCompressed() throws IOException<br />

{<br />

ByteArrayOutputStream outStream = new ByteArrayOutputStream();<br />

ObjectOutputStream out = new ObjectOutputStream(outStream);<br />

out.writeObject(new Integer(type));<br />

out.writeObject(new Double(value));<br />

out.writeObject(new Long(serialNumber));<br />

out.writeObject(new Long(expirationTime));<br />

out.writeObject(new Long(transferExpirationTime));<br />

out.writeObject(new Integer(this.maxNumberOfUsages));<br />

out.writeObject(this.transactionList);<br />

out.writeObject(this.signature);<br />

out.writeObject(this.signHash);<br />

}<br />

byte[] result = outStream.toByteArray();<br />

outStream.close();<br />

out.close();<br />

return result;<br />

private void setCExpirationTime()<br />

{<br />

//Expirationtime is calculated<br />

transferExpirationTime = System.currentTimeMillis();<br />

transferExpirationTime += Config.CCoinExpirationTimeInMilliseconds +<br />

Config.CCoinDelayTimeInMilliseconds;<br />

//Debugger.debug(getClass(),1,"C_expirationtime set to:<br />

"+C_expirationTime.getTime());<br />

}<br />

private void setBExpirationTime()<br />

{<br />

transferExpirationTime = System.currentTimeMillis();<br />

transferExpirationTime += Config.CCoinExpirationTimeInMilliseconds;<br />

}<br />

public boolean transferTimeexpired()<br />

{<br />

return System.currentTimeMillis() > transferExpirationTime;<br />

}<br />

public void insertValues(double value, int maxUsages)<br />

312

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

Saved successfully!

Ooh no, something went wrong!