use of se.funktionstjanster.grp.v1.CollectRequestType in project webcert by sklintyg.
the class GrpCollectPollerImpl method run.
@Override
public void run() {
try {
applySecurityContextToThreadLocal();
WebCertUser webCertUser = (WebCertUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
long startTimeMs = System.currentTimeMillis();
while ((startTimeMs + TIMEOUT) > System.currentTimeMillis()) {
CollectRequestType req = buildCollectRequest();
try {
CollectResponseType resp = grpService.collect(req);
LOG.info("GRP collect returned ProgressStatusType: {}", resp.getProgressStatus());
switch(resp.getProgressStatus()) {
case COMPLETE:
String subjectSerialNumber = getCollectResponseAttribute(resp.getAttributes());
if (!subjectSerialNumber.replaceAll("\\-", "").equals(webCertUser.getPersonId().replaceAll("\\-", ""))) {
throw new IllegalStateException("Could not process GRP Collect COMPLETE response, subject serialNumber did not match " + "issuing WebCertUser.");
}
String signature = resp.getSignature();
signaturService.clientGrpSignature(resp.getTransactionId(), signature, webCertUser);
LOG.info("Signature was successfully persisted and ticket updated.");
return;
case USER_SIGN:
signaturTicketTracker.updateStatus(transactionId, SignaturTicket.Status.VANTA_SIGN);
break;
case OUTSTANDING_TRANSACTION:
case STARTED:
case USER_REQ:
break;
case NO_CLIENT:
signaturTicketTracker.updateStatus(transactionId, SignaturTicket.Status.NO_CLIENT);
LOG.info("GRP collect returned ProgressStatusType: {}, " + "has the user started their BankID or Mobilt BankID application?", resp.getProgressStatus());
break;
}
} catch (GrpFault grpFault) {
handleGrpFault(grpFault);
// Always terminate loop after a GrpFault has been encountered
return;
}
sleepMs(ms);
}
} finally {
// Since this poller thread will be returned to its thread pool, we make sure we clean up the security
// context we bound to this runnable's threadlocal.
SecurityContextHolder.clearContext();
}
}
use of se.funktionstjanster.grp.v1.CollectRequestType in project webcert by sklintyg.
the class GrpCollectPollerImpl method buildCollectRequest.
private CollectRequestType buildCollectRequest() {
CollectRequestType req = new CollectRequestType();
req.setOrderRef(orderRef);
req.setTransactionId(transactionId);
req.setPolicy(serviceId);
req.setDisplayName(displayName);
req.setProvider(GrpSignaturServiceImpl.BANK_ID_PROVIDER);
return req;
}
Aggregations