Search in sources :

Example 1 with Office2010SignatureFacet

use of org.apache.poi.poifs.crypt.dsig.facets.Office2010SignatureFacet in project poi by apache.

the class SignatureConfig method init.

/**
     * Inits and checks the config object.
     * If not set previously, complex configuration properties also get 
     * created/initialized via this initialization call.
     *
     * @param onlyValidation if true, only a subset of the properties
     * is initialized, which are necessary for validation. If false,
     * also the other properties needed for signing are been taken care of
     */
protected void init(boolean onlyValidation) {
    if (opcPackage == null) {
        throw new EncryptedDocumentException("opcPackage is null");
    }
    if (uriDereferencer == null) {
        uriDereferencer = new OOXMLURIDereferencer();
    }
    if (uriDereferencer instanceof SignatureConfigurable) {
        ((SignatureConfigurable) uriDereferencer).setSignatureConfig(this);
    }
    if (namespacePrefixes.isEmpty()) {
        /*
             * OOo doesn't like ds namespaces so per default prefixing is off.
             */
        // namespacePrefixes.put(XML_DIGSIG_NS, "");
        namespacePrefixes.put(OO_DIGSIG_NS, "mdssi");
        namespacePrefixes.put(XADES_132_NS, "xd");
    }
    if (onlyValidation)
        return;
    if (signatureMarshalListener == null) {
        signatureMarshalListener = new SignatureMarshalListener();
    }
    if (signatureMarshalListener instanceof SignatureConfigurable) {
        ((SignatureConfigurable) signatureMarshalListener).setSignatureConfig(this);
    }
    if (tspService != null) {
        tspService.setSignatureConfig(this);
    }
    if (signatureFacets.isEmpty()) {
        addSignatureFacet(new OOXMLSignatureFacet());
        addSignatureFacet(new KeyInfoSignatureFacet());
        addSignatureFacet(new XAdESSignatureFacet());
        addSignatureFacet(new Office2010SignatureFacet());
    }
    for (SignatureFacet sf : signatureFacets) {
        sf.setSignatureConfig(this);
    }
}
Also used : EncryptedDocumentException(org.apache.poi.EncryptedDocumentException) Office2010SignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.Office2010SignatureFacet) KeyInfoSignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.KeyInfoSignatureFacet) XAdESSignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.XAdESSignatureFacet) OOXMLSignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.OOXMLSignatureFacet) SignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.SignatureFacet) KeyInfoSignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.KeyInfoSignatureFacet) OOXMLSignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.OOXMLSignatureFacet) Office2010SignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.Office2010SignatureFacet) XAdESSignatureFacet(org.apache.poi.poifs.crypt.dsig.facets.XAdESSignatureFacet)

Aggregations

EncryptedDocumentException (org.apache.poi.EncryptedDocumentException)1 KeyInfoSignatureFacet (org.apache.poi.poifs.crypt.dsig.facets.KeyInfoSignatureFacet)1 OOXMLSignatureFacet (org.apache.poi.poifs.crypt.dsig.facets.OOXMLSignatureFacet)1 Office2010SignatureFacet (org.apache.poi.poifs.crypt.dsig.facets.Office2010SignatureFacet)1 SignatureFacet (org.apache.poi.poifs.crypt.dsig.facets.SignatureFacet)1 XAdESSignatureFacet (org.apache.poi.poifs.crypt.dsig.facets.XAdESSignatureFacet)1