summaryrefslogtreecommitdiff
path: root/BKUOnline/src/main/java
diff options
context:
space:
mode:
authorAndreas Abraham <aabraham@iaik.tugraz.at>2018-04-23 09:48:33 +0200
committerAndreas Abraham <aabraham@iaik.tugraz.at>2018-04-23 09:48:33 +0200
commit9e24a02d80e13273ec5d1d4fa9b3a95d8ae486c2 (patch)
tree32decc21d7035250e02798733454868231036d8a /BKUOnline/src/main/java
parent6386fb8e6ba691bce0cf129e7da4324935a9b333 (diff)
parentb9ccb62d35a755efb505d426ce924d5a8fbe937a (diff)
downloadmocca-9e24a02d80e13273ec5d1d4fa9b3a95d8ae486c2.tar.gz
mocca-9e24a02d80e13273ec5d1d4fa9b3a95d8ae486c2.tar.bz2
mocca-9e24a02d80e13273ec5d1d4fa9b3a95d8ae486c2.zip
Merge branch 'fb-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");