Java tutorial
/* * eID Digital Signature Service Project. * Copyright (C) 2009 FedICT. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version * 3.0 as published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, see * http://www.gnu.org/licenses/. */ package be.fedict.eid.dss.model.bean; import java.security.InvalidAlgorithmParameterException; import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import java.util.List; import javax.servlet.http.HttpSession; import javax.xml.crypto.dsig.Reference; import javax.xml.crypto.dsig.XMLObject; import javax.xml.crypto.dsig.XMLSignatureFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import be.fedict.eid.applet.service.signer.HttpSessionTemporaryDataStorage; import be.fedict.eid.applet.service.signer.SignatureFacet; import be.fedict.eid.dss.model.DocumentRepository; /** * Signature Facet to push the signer certificate in the HTTP session. * * @author Frank Cornelis * */ public class SignerCertificateSignatureFacet implements SignatureFacet { private static final Log LOG = LogFactory.getLog(SignerCertificateSignatureFacet.class); public void postSign(Element signatureElement, List<X509Certificate> signingCertificateChain) { HttpSession httpSession = HttpSessionTemporaryDataStorage.getHttpSession(); DocumentRepository documentRepository = new DocumentRepository(httpSession); X509Certificate signerCertificate = signingCertificateChain.get(0); LOG.debug("signer certificate: " + signerCertificate.getSubjectX500Principal()); documentRepository.setSignerCertificate(signerCertificate); } public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId, List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { // empty } }