Skip to content

Commit

Permalink
search now is possible without the need to specify the message digest…
Browse files Browse the repository at this point in the history
… algorithm
  • Loading branch information
elbosso committed Nov 17, 2019
1 parent e28f142 commit dc5514c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Changelog of this project.


**docker deployment preparations...**


[e28f142452bd91a](https://github.com/<user>/<project>>/commit/e28f142452bd91a) Juergen Key *2019-11-17 18:25:19*

**querying the database now works too**


Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ To verify the timestamp, OpenSSL can help too:
```shell script
openssl ts -verify -config tsa.conf -queryfile <request>.tsq -in <reply>.tsr -CAfile chain.pem
```

The server offers the possibility to search for a hash value - either
with

```shell script
curl -F "algoid=x.y.z" -F "msgDigest=<base64encodedDigest>" http://<host>:<port>/query --output <queried>.tsr
```

or without specifying the message digest algorithm for computing it:

```shell script
curl -F "msgDigest=<base64encodedDigest>" http://<host>:<port>/query --output <queried>.tsr
```

This project offers a server that adheres to standards - this way, it
can be used as standin for any solution that needs access to a timestamping
server. One example for that is the Java build tool [Ant](https://ant.apache.org/):
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/de/elbosso/tools/rfc3161timestampingserver/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public static void main(String[] args) {
}
if((algoid!=null)&&(msgDigest!=null))
{
if (CLASS_LOGGER.isDebugEnabled()) CLASS_LOGGER.debug("searching using message digest algorithm and message digest imprint as parameters");
EntityManager em = PersistenceManager.INSTANCE.getEntityManager();
Query namedQuery = em.createNamedQuery("Rfc3161Timestamp.findYoungestByMsgDigestAndImprint");
namedQuery.setParameter("Alg", algoid);
Expand All @@ -145,6 +146,28 @@ public static void main(String[] args) {
ctx.status(404);
}
}
else if(msgDigest!=null)
{
if (CLASS_LOGGER.isDebugEnabled()) CLASS_LOGGER.debug("searching using only message digest imprint as parameter");
EntityManager em = PersistenceManager.INSTANCE.getEntityManager();
Query namedQuery = em.createNamedQuery("Rfc3161Timestamp.findYoungestByMsgImprint");
namedQuery.setParameter("Imprint", msgDigest);
namedQuery.setMaxResults(1);
java.util.List resultList= namedQuery.getResultList();
if(resultList.isEmpty()==false)
{
if (CLASS_LOGGER.isInfoEnabled()) CLASS_LOGGER.info("Entry found in database");
Rfc3161Timestamp rfc3161Timestamp = (Rfc3161Timestamp) resultList.get(0);
ctx.status(201);
ctx.contentType("application/timestamp-reply");
ctx.result(new java.io.ByteArrayInputStream(rfc3161Timestamp.getTsrData()));
}
else
{
if (CLASS_LOGGER.isInfoEnabled()) CLASS_LOGGER.info("No entry found in database");
ctx.status(404);
}
}
else
{
if (CLASS_LOGGER.isEnabledFor(Priority.ERROR)) CLASS_LOGGER.error("Not all needed information present");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@Entity
@Table(name = "rfc3161timestamp")
@NamedQuery(name = "Rfc3161Timestamp.findById", query = "SELECT u FROM Rfc3161Timestamp u WHERE u.id=:Id")
@NamedQuery(name = "Rfc3161Timestamp.findYoungestByMsgImprint", query = "SELECT u FROM Rfc3161Timestamp u WHERE u.messageImprintDigestBase64=:Imprint ORDER BY u.creationDate DESC")
@NamedQuery(name = "Rfc3161Timestamp.findYoungestByMsgDigestAndImprint", query = "SELECT u FROM Rfc3161Timestamp u WHERE u.messageImprintAlgOID=:Alg AND u.messageImprintDigestBase64=:Imprint ORDER BY u.creationDate DESC")
public class Rfc3161Timestamp extends de.elbosso.util.beans.EventHandlingSupport
{
Expand Down

0 comments on commit dc5514c

Please sign in to comment.