Skip to content

Commit

Permalink
adding maven support
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Feb 27, 2017
1 parent 915e9c1 commit 4d0ba30
Show file tree
Hide file tree
Showing 28 changed files with 182 additions and 117 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
target/
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
The OpenTimestamps Client is free software: you can redistribute it and/or
The com.eternitywall.OpenTimestamps Client is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

The OpenTimestamps Client is distributed in the hope that it will be useful,
The com.eternitywall.OpenTimestamps Client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
below for more details.
Expand Down
4 changes: 2 additions & 2 deletions examples/incomplete.txt.ots.info
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
File sha256 hash: 05c4f616a8e5310d19d938cfd769864d7f4ccdc2ca8b479b10af83564b097af9
Timestamp:
com.eternitywall.Timestamp:
append e754bf93806a7ebaa680ef7bd0114bf4
sha256
append b573e8850cfd9e63d1f043fbb6fc250e
sha256
prepend 57cfa5c4
append 6fb1ac8d4e4eb0e7
verify PendingAttestation('https://alice.btc.calendar.opentimestamps.org')
verify com.eternitywall.PendingAttestation('https://alice.btc.calendar.opentimestamps.org')
6 changes: 3 additions & 3 deletions examples/merkle2.txt.ots.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
File sha256 hash: 8bd5a5f07b4451c29756df5eb51d194fb5b20c7e89812d877bbad30d871c582f
Timestamp:
com.eternitywall.Timestamp:
append b63d8f213d047298b8ab4595acd8e5d0
sha256
prepend ae59d2c0d2f5efa97df8f3cca7e85845880c102237f1a6a1b0b4c6a5ab77f494
Expand All @@ -10,9 +10,9 @@ sha256
sha256
prepend 57d982df
append b1f26e2e55590477
verify PendingAttestation('https://alice.btc.calendar.opentimestamps.org')
verify com.eternitywall.PendingAttestation('https://alice.btc.calendar.opentimestamps.org')
-> append 4aaade9c2ffb853ccff9c07681d019fd
sha256
prepend 57d982e0
append 6644ef713071762a
verify PendingAttestation('https://bob.btc.calendar.opentimestamps.org')
verify com.eternitywall.PendingAttestation('https://bob.btc.calendar.opentimestamps.org')
48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.eternitywall</groupId>
<artifactId>java-opentimestamps</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160212</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.56</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
package com.eternitywall; /**
* Created by luca on 25/02/2017.
*/

Expand All @@ -24,7 +24,7 @@
* exceptionally rare events anyway, so better to just tell the user the timestamp
* can't be verified rather than add almost-never tested code to handle that case
* more gracefully.
* @extends TimeAttestation
* @extends com.eternitywall.TimeAttestation
*/
class BitcoinBlockHeaderAttestation extends TimeAttestation {

Expand All @@ -51,6 +51,6 @@ public void serializePayload(StreamSerializationContext ctx) {
ctx.writeVaruint(this.height);
}
public String toString() {
return "BitcoinBlockHeaderAttestation(" + this.height + ")";
return "com.eternitywall.BitcoinBlockHeaderAttestation(" + this.height + ")";
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

package com.eternitywall;
/**
* Calendar module.
* @module Calendar
* com.eternitywall.Calendar module.
* @module com.eternitywall.Calendar
* @author EternityWall
* @license LPGL3
*/
Expand All @@ -11,7 +11,7 @@
import java.net.*;
import java.io.*;

/** Class representing Remote Calendar server interface */
/** Class representing Remote com.eternitywall.Calendar server interface */
public class Calendar {

String url;
Expand All @@ -26,7 +26,7 @@ public class Calendar {


/**
* Submitting a digest to remote calendar. Returns a Timestamp committing to that digest.
* Submitting a digest to remote calendar. Returns a com.eternitywall.Timestamp committing to that digest.
* @param {byte[]} digest - The digest hash to send.
*/
public Timestamp submit(byte[] digest) {
Expand Down Expand Up @@ -63,7 +63,7 @@ public Timestamp submit(byte[] digest) {
// Response Hanlder
byte[] body = byteArrayBuffer.getRawData();
if (body.length > 10000) {
System.err.print("Calendar response exceeded size limit");
System.err.print("com.eternitywall.Calendar response exceeded size limit");
return null;
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public Timestamp getTimestamp(byte[] commitment) {
// Response Hanlder
byte[] body = byteArrayBuffer.getRawData();
if (body.length > 10000) {
System.err.print("Calendar response exceeded size limit");
System.err.print("com.eternitywall.Calendar response exceeded size limit");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

package com.eternitywall;
/**
* Detached Timestamp File module.
* @module DetachedTimestampFile
* Detached com.eternitywall.Timestamp File module.
* @module com.eternitywall.DetachedTimestampFile
* @author EternityWall
* @license LPGL3
*/

/**
* Class representing Detached Timestamp File.
* Class representing Detached com.eternitywall.Timestamp File.
* A file containing a timestamp for another file.
* Contains a timestamp, along with a header and the digest of the file.
*/
Expand Down Expand Up @@ -52,9 +52,9 @@ public byte[] fileDigest() {
}

/**
* Serialize a Timestamp File.
* @param {StreamSerializationContext} ctx - The stream serialization context.
* @return {byte[]} The serialized DetachedTimestampFile object.
* Serialize a com.eternitywall.Timestamp File.
* @param {com.eternitywall.StreamSerializationContext} ctx - The stream serialization context.
* @return {byte[]} The serialized com.eternitywall.DetachedTimestampFile object.
*/
public void serialize(StreamSerializationContext ctx) {
ctx.writeBytes(HEADER_MAGIC);
Expand All @@ -65,9 +65,9 @@ public void serialize(StreamSerializationContext ctx) {
}

/**
* Deserialize a Timestamp File.
* @param {StreamDeserializationContext} ctx - The stream deserialization context.
* @return {DetachedTimestampFile} The generated DetachedTimestampFile object.
* Deserialize a com.eternitywall.Timestamp File.
* @param {com.eternitywall.StreamDeserializationContext} ctx - The stream deserialization context.
* @return {com.eternitywall.DetachedTimestampFile} The generated com.eternitywall.DetachedTimestampFile object.
*/
public static DetachedTimestampFile deserialize(StreamDeserializationContext ctx) {
ctx.assertMagic(HEADER_MAGIC);
Expand All @@ -82,21 +82,21 @@ public static DetachedTimestampFile deserialize(StreamDeserializationContext ctx
}

/**
* Read the Detached Timestamp File from bytes.
* @param {Op} fileHashOp - The file hash operation.
* @param {StreamDeserializationContext} ctx - The stream deserialization context.
* @return {DetachedTimestampFile} The generated DetachedTimestampFile object.
* Read the Detached com.eternitywall.Timestamp File from bytes.
* @param {com.eternitywall.Op} fileHashOp - The file hash operation.
* @param {com.eternitywall.StreamDeserializationContext} ctx - The stream deserialization context.
* @return {com.eternitywall.DetachedTimestampFile} The generated com.eternitywall.DetachedTimestampFile object.
*/
public static DetachedTimestampFile fromBytes(OpCrypto fileHashOp, StreamDeserializationContext ctx) {
byte[] fdHash = fileHashOp.hashFd(ctx);
return new DetachedTimestampFile(fileHashOp, new Timestamp(fdHash));
}

/**
* Read the Detached Timestamp File from hash.
* @param {Op} fileHashOp - The file hash operation.
* Read the Detached com.eternitywall.Timestamp File from hash.
* @param {com.eternitywall.Op} fileHashOp - The file hash operation.
* @param {int[]} fdHash - The hash file.
* @return {DetachedTimestampFile} The generated DetachedTimestampFile object.
* @return {com.eternitywall.DetachedTimestampFile} The generated com.eternitywall.DetachedTimestampFile object.
*/
public static DetachedTimestampFile fromHash(Op fileHashOp, byte[] fdHash) {
return new DetachedTimestampFile(fileHashOp, new Timestamp(fdHash));
Expand All @@ -107,7 +107,7 @@ public static DetachedTimestampFile fromHash(Op fileHashOp, byte[] fdHash) {
* @return {string} The output.
*/
public String toString() {
String output = "DetachedTimestampFile\n";
String output = "com.eternitywall.DetachedTimestampFile\n";
output += "fileHashOp: " + this.fileHashOp.toString() + '\n';
output += "timestamp: " + this.timestamp.toString() + '\n';
return output;
Expand Down
12 changes: 5 additions & 7 deletions src/Insight.java → src/main/java/com/eternitywall/Insight.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/**
* Insight module.
* @module Insight
package com.eternitywall; /**
* com.eternitywall.Insight module.
* @module com.eternitywall.Insight
* @author EternityWall
* @license LPGL3
*/

import com.oracle.javafx.jmx.json.JSONFactory;
import com.sun.xml.internal.ws.util.ByteArrayBuffer;
import org.json.JSONObject;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;

/** Class used to query Insight API */
/** Class used to query com.eternitywall.Insight API */
class Insight {

String urlBlockindex;
Expand Down Expand Up @@ -108,7 +106,7 @@ public InsightResponse block(String hash) {
// Response Hanlder
JSONObject json = new JSONObject(jsonString);
String merkleroot = json.getString("merkleroot");
String time = json.getString("time");
String time = String.valueOf(json.getInt("time"));
InsightResponse insightResponse = new InsightResponse();
insightResponse.setMerkleroot( merkleroot );
insightResponse.setTime( time );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.eternitywall;

/**
* Created by luca on 27/02/2017.
*/
Expand Down
23 changes: 11 additions & 12 deletions src/Op.java → src/main/java/com/eternitywall/Op.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import java.util.HashMap;
import java.util.Map;
package com.eternitywall;

/**
* Timestamp proof operations.
* com.eternitywall.Timestamp proof operations.
* Operations are the edges in the timestamp tree, with each operation taking a message and zero or more arguments to produce a result.
*/
class Op {

/**
* Maximum length of an Op result
* Maximum length of an com.eternitywall.Op result
*
* For a verifier, this limit is what limits the maximum amount of memory you
* need at any one time to verify a particular timestamp path; while verifying
Expand All @@ -22,20 +21,20 @@ class Op {
* limits required by both are quite large - 1MB and 16MiB respectively - 4KiB
* is perfectly adequate in both cases for more reasonable usage.
*
* Op subclasses should set this limit even lower if doing so is appropriate
* com.eternitywall.Op subclasses should set this limit even lower if doing so is appropriate
* for them.
*/
public static int _MAX_RESULT_LENGTH = 4096;


/**
* Maximum length of the message an Op can be applied too.
* Maximum length of the message an com.eternitywall.Op can be applied too.
*
* Similar to the result length limit, this limit gives implementations a sane
* constraint to work with; the maximum result-length limit implicitly
* constrains maximum message length anyway.
*
* Op subclasses should set this limit even lower if doing so is appropriate
* com.eternitywall.Op subclasses should set this limit even lower if doing so is appropriate
* for them.
*/
public static int _MAX_MSG_LENGTH = 4096;
Expand All @@ -48,8 +47,8 @@ public String _TAG_NAME() {

/**
* Deserialize operation from a buffer.
* @param {StreamDeserializationContext} ctx - The stream deserialization context.
* @return {Op} The subclass Operation.
* @param {com.eternitywall.StreamDeserializationContext} ctx - The stream deserialization context.
* @return {com.eternitywall.Op} The subclass Operation.
*/
public static Op deserialize(StreamDeserializationContext ctx) {
byte tag = ctx.readBytes(1)[0];
Expand All @@ -58,9 +57,9 @@ public static Op deserialize(StreamDeserializationContext ctx) {

/**
* Deserialize operation from a buffer.
* @param {StreamDeserializationContext} ctx - The stream deserialization context.
* @param {com.eternitywall.StreamDeserializationContext} ctx - The stream deserialization context.
* @param {int} tag - The tag of the operation.
* @return {Op} The subclass Operation.
* @return {com.eternitywall.Op} The subclass Operation.
*/
public static Op deserializeFromTag(StreamDeserializationContext ctx, byte tag) {
if (tag == OpAppend._TAG){
Expand All @@ -81,7 +80,7 @@ public static Op deserializeFromTag(StreamDeserializationContext ctx, byte tag)

/**
* Serialize operation.
* @param {StreamSerializationContext} ctx - The stream serialization context.
* @param {com.eternitywall.StreamSerializationContext} ctx - The stream serialization context.
*/
void serialize(StreamSerializationContext ctx) {
ctx.writeByte(_TAG);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.eternitywall;

/**
* Append a suffix to a message.
* @extends OpBinary
* @extends com.eternitywall.OpBinary
*/
class OpAppend extends OpBinary {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.eternitywall;

/**
* Operations that act on a message and a single argument.
* @extends OpUnary
* @extends com.eternitywall.OpUnary
*/
class OpBinary extends Op {

Expand All @@ -22,7 +23,7 @@ public String _TAG_NAME() {
}

public static Op deserializeFromTag(StreamDeserializationContext ctx, byte tag) {
byte[] arg = ctx.readVarbytes(Op._MAX_RESULT_LENGTH, 1);
byte[] arg = ctx.readVarbytes(_MAX_RESULT_LENGTH, 1);
if (tag == OpAppend._TAG){
return new OpAppend(arg);
}else if (tag == OpPrepend._TAG){
Expand Down
Loading

0 comments on commit 4d0ba30

Please sign in to comment.