summaryrefslogtreecommitdiff
path: root/BKUOnline/src/main/java
diff options
context:
space:
mode:
authorBonato, Martin <martin.bonato@prime-sign.com>2018-02-08 22:19:55 +0100
committerBonato, Martin <martin.bonato@prime-sign.com>2018-02-08 22:19:55 +0100
commitb9ccb62d35a755efb505d426ce924d5a8fbe937a (patch)
tree00d17aa7dc660eb0e90ae753e36a623d672fc0e0 /BKUOnline/src/main/java
parent84794c877062fe0424f357be0e83bdd045d75d52 (diff)
downloadmocca-b9ccb62d35a755efb505d426ce924d5a8fbe937a.tar.gz
mocca-b9ccb62d35a755efb505d426ce924d5a8fbe937a.tar.bz2
mocca-b9ccb62d35a755efb505d426ce924d5a8fbe937a.zip
BulkSignature implementationfb-bulksignature
Diffstat (limited to 'BKUOnline/src/main/java')
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java20
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java42
2 files changed, 52 insertions, 10 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
index eab5c62d..3746b8d1 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -25,6 +25,7 @@
package at.gv.egiz.stal.service.impl;
+import at.gv.egiz.stal.BulkSignRequest;
import at.gv.egiz.stal.ErrorResponse;
import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.QuitRequest;
@@ -115,8 +116,25 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
// and getHashDataInput() accesses request obj
// (requests are cleared only when we receive the response)
// DataObjectHashDataInput with reference caching enabled DataObject
+
+ log.info("Adding HashdataInput with id {} and digsest {}", ((SignRequest) stalRequest).getHashDataInput()
+ .get(0).getReferenceId(), ((SignRequest) stalRequest).getHashDataInput().get(0).getDigest());
hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput());
- } else if (stalRequest instanceof QuitRequest) {
+ }
+
+ if (stalRequest instanceof BulkSignRequest) {
+
+ BulkSignRequest bulkSignRequest = (BulkSignRequest) stalRequest;
+
+ for (SignRequest signRequest : bulkSignRequest.getSignRequests()) {
+ log.info("Adding HashdataInput with id {} and digsest {}", signRequest.getHashDataInput().get(0)
+ .getReferenceId(), signRequest.getHashDataInput().get(0).getDigest());
+ hashDataInputs.addAll(signRequest.getHashDataInput());
+ }
+
+ }
+
+ else if (stalRequest instanceof QuitRequest) {
log.trace("Received QuitRequest, do not wait for responses.");
log.trace("notifying request consumers");
requests.notify();
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
index 836d6538..1819074a 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
@@ -120,7 +120,7 @@ public class STALServiceImpl implements STALPortType {
if (stal != null) {
List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).connect();
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
+ response.getInfoboxReadRequestOrSignRequestOrBulkSignRequest().addAll(requestsOut);
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Returning initial GetNextRequestResponse containing ");
@@ -136,7 +136,7 @@ public class STALServiceImpl implements STALPortType {
log.error("Failed to get STAL, returning QuitRequest.");
QuitRequestType quitT = stalObjFactory.createQuitRequestType();
JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
+ response.getInfoboxReadRequestOrSignRequestOrBulkSignRequest().add(quit);
}
return response;
@@ -157,7 +157,7 @@ public class STALServiceImpl implements STALPortType {
try {
- List<JAXBElement<? extends ResponseType>> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();
+ List<JAXBElement<? extends ResponseType>> responsesIn = request.getInfoboxReadResponseOrSignResponseOrBulkSignResponse();
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Received GetNextRequest containing ");
@@ -186,7 +186,7 @@ public class STALServiceImpl implements STALPortType {
if (stal != null) {
List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn);
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
+ response.getInfoboxReadRequestOrSignRequestOrBulkSignRequest().addAll(requestsOut);
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Returning GetNextRequestResponse containing ");
@@ -202,7 +202,7 @@ public class STALServiceImpl implements STALPortType {
log.error("Failed to get STAL, returning QuitRequest.");
QuitRequestType quitT = stalObjFactory.createQuitRequestType();
JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
+ response.getInfoboxReadRequestOrSignRequestOrBulkSignRequest().add(quit);
}
return response;
@@ -242,27 +242,51 @@ public class STALServiceImpl implements STALPortType {
if (hashDataInputs != null) {
Map<String, HashDataInput> hashDataIdMap = new HashMap<String, HashDataInput>();
+ Map<String, HashDataInput> hashDataDigestMap = new HashMap<String, HashDataInput>();
for (HashDataInput hdi : hashDataInputs) {
if (log.isTraceEnabled()) {
log.trace("Provided HashDataInput for reference {}.", hdi.getReferenceId());
}
+
+
+ if(hdi.getDigest() != null) {
+ log.trace("Provided HashDataInput for digest {}.", hdi.getDigest());
+ hashDataDigestMap.put(new String(hdi.getDigest()), hdi);
+ }
+
+ log.trace("Provided HashDataInput for reference {}.", hdi.getReferenceId());
hashDataIdMap.put(hdi.getReferenceId(), hdi);
}
List<GetHashDataInputType.Reference> reqRefs = request.getReference();
for (GetHashDataInputType.Reference reqRef : reqRefs) {
String reqRefId = reqRef.getID();
- HashDataInput reqHdi = hashDataIdMap.get(reqRefId);
+ String digest = new String(reqRef.getDigest());
+
+ log.info("looking for digest {}", digest);
+ HashDataInput reqHdi = hashDataDigestMap.get(digest);
+ if (reqHdi == null) {
+ log.info("looking for referenceId {}", reqRefId);
+ reqHdi = hashDataIdMap.get(reqRefId);
+ }
if (reqHdi == null) {
String msg = "Failed to resolve HashDataInput for reference " + reqRefId;
- log.error(msg);
+ log.info(msg);
GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
faultInfo.setErrorCode(1);
faultInfo.setErrorMessage(msg);
throw new GetHashDataInputFault(msg, faultInfo);
}
- InputStream hashDataIS = reqHdi.getHashDataInput();
+ InputStream hashDataIS;
+ try {
+ hashDataIS = reqHdi.getHashDataInput();
+ } catch (IOException e) {
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(e.getMessage());
+ throw new GetHashDataInputFault(e.getMessage(), faultInfo);
+ }
if (hashDataIS == null) {
//HashDataInput not cached?
String msg = "Failed to obtain HashDataInput for reference " + reqRefId + ", reference not cached";
@@ -345,7 +369,7 @@ public class STALServiceImpl implements STALPortType {
GetNextRequestResponseType response = new GetNextRequestResponseType();
response.setSessionId(TEST_SESSION_ID.toString());
- List<JAXBElement<? extends RequestType>> reqs = response.getInfoboxReadRequestOrSignRequestOrQuitRequest();
+ List<JAXBElement<? extends RequestType>> reqs = response.getInfoboxReadRequestOrSignRequestOrBulkSignRequest();
if (responsesIn == null) {
log.info("[TestSession] CONNECT");