diff options
author | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2013-12-12 18:44:48 +0000 |
---|---|---|
committer | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2013-12-12 18:44:48 +0000 |
commit | 0165e2dd986389f7c04b48cd0452f73c3d01c10a (patch) | |
tree | 479a851df048294852782bd19ff52ff38e8f023b /smccSTAL/src/main/java | |
parent | 34d821b73e4cc211e17a036b539859fe2f758ec6 (diff) | |
download | mocca-0165e2dd986389f7c04b48cd0452f73c3d01c10a.tar.gz mocca-0165e2dd986389f7c04b48cd0452f73c3d01c10a.tar.bz2 mocca-0165e2dd986389f7c04b48cd0452f73c3d01c10a.zip |
Display CMS data in Secure Viewer
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1251 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smccSTAL/src/main/java')
-rw-r--r-- | smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java index 10b2e191..8ba18010 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java @@ -24,11 +24,10 @@ package at.gv.egiz.bku.smccstal; -import at.gv.egiz.bku.gui.BKUGUIFacade; -import at.gv.egiz.bku.pin.gui.SignPINGUI; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -38,12 +37,14 @@ import javax.xml.bind.Unmarshaller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.pin.gui.SignPINGUI; import at.gv.egiz.smcc.CancelledException; import at.gv.egiz.smcc.LockedException; import at.gv.egiz.smcc.NotActivatedException; import at.gv.egiz.smcc.SignatureCard; -import at.gv.egiz.smcc.SignatureCardException; import at.gv.egiz.smcc.SignatureCard.KeyboxName; +import at.gv.egiz.smcc.SignatureCardException; import at.gv.egiz.smcc.TimeoutException; import at.gv.egiz.stal.ErrorResponse; import at.gv.egiz.stal.STALRequest; @@ -52,12 +53,18 @@ import at.gv.egiz.stal.SignRequest; import at.gv.egiz.stal.SignResponse; import at.gv.egiz.stal.signedinfo.CanonicalizationMethodType; import at.gv.egiz.stal.signedinfo.ObjectFactory; +import at.gv.egiz.stal.signedinfo.ReferenceType; import at.gv.egiz.stal.signedinfo.SignatureMethodType; import at.gv.egiz.stal.signedinfo.SignedInfoType; public class SignRequestHandler extends AbstractRequestHandler { private final static Logger log = LoggerFactory.getLogger(SignRequestHandler.class); + + private final static String CMS_DEF_SIGNEDINFO_ID = "SignedInfo-1"; + private final static String CMS_DEF_OBJECT_ID = "SignatureData-1"; + private final static String CMS_DEF_REFERENCE_ID = "Reference-1"; + private static JAXBContext jaxbContext; static { @@ -88,12 +95,10 @@ public class SignRequestHandler extends AbstractRequestHandler { public STALResponse handleRequest(STALRequest request) throws InterruptedException { if (request instanceof SignRequest) { SignRequest signReq = (SignRequest) request; + byte[] signedInfoData = signReq.getSignedInfo(); try { - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - InputStream is = new ByteArrayInputStream(signReq.getSignedInfo()); - SignedInfoType signedInfo; - if (signReq.getSignedInfoIsRawData()) { + if (signReq.getSignedInfoIsCMSSignedAttributes()) { signedInfo = new SignedInfoType(); CanonicalizationMethodType canonicalizationMethod = new CanonicalizationMethodType(); @@ -102,8 +107,15 @@ public class SignRequestHandler extends AbstractRequestHandler { signatureMethod.setAlgorithm(signReq.getSignatureMethod()); signedInfo.setCanonicalizationMethod(canonicalizationMethod); signedInfo.setSignatureMethod(signatureMethod); - signedInfo.setId(""); + signedInfo.setId(CMS_DEF_SIGNEDINFO_ID); + List<ReferenceType> references = signedInfo.getReference(); + ReferenceType reference = new ReferenceType(); + reference.setId(CMS_DEF_REFERENCE_ID); + reference.setURI(CMS_DEF_OBJECT_ID); + references.add(reference); } else { + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + InputStream is = new ByteArrayInputStream(signedInfoData); JAXBElement<SignedInfoType> si = (JAXBElement<SignedInfoType>) unmarshaller.unmarshal(is); signedInfo = si.getValue(); @@ -112,7 +124,7 @@ public class SignRequestHandler extends AbstractRequestHandler { log.debug("Found signature method: {}.", signatureMethod); KeyboxName kb = SignatureCard.KeyboxName.getKeyboxName(signReq.getKeyIdentifier()); - byte[] resp = card.createSignature(new ByteArrayInputStream(signReq.getSignedInfo()), kb, + byte[] resp = card.createSignature(new ByteArrayInputStream(signedInfoData), kb, new SignPINGUI(gui, secureViewer, signedInfo), signatureMethod); if (resp == null) { return errorResponse(6001, "Response is null", null); |