makdimka077 / xades4j

Automatically exported from code.google.com/p/xades4j
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Difficulties to add tag SignaturePolicyIdentifier #63

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Firstly, all my best wishes to all of you :)

 I have difficulties to add this tags :
<xad:SignaturePolicyIdentifier>
    <xad:SignaturePolicyId>
        <xad:SigPolicyId><xad:Identifier>urn:oid:1.2.250.1.131.1.5.18.21.1.4</xad:Identifier>
<xad:Description>Politique de signature Helios de la DGFiP</xad:Description>
        </xad:SigPolicyId>
        <xad:SigPolicyHash>
            <xad:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
            <xad:DigestValue>Jkdb+aba0Hz6+ZPKmKNhPByzQ+Q=</xad:DigestValue>
        </xad:SigPolicyHash>
        <xad:SigPolicyQualifiers>
            <xad:SigPolicyQualifier>
                <xad:SPURI>https://portail.dgfip.finances.gouv.fr/documents/PS_Helios_DGFiP.pdf</xad:SPURI>
            </xad:SigPolicyQualifier>
        </xad:SigPolicyQualifiers>
    </xad:SignaturePolicyId>
</xad:SignaturePolicyIdentifier>

I can get this :
<xades:SignaturePolicyIdentifier>
    <xades:SignaturePolicyId>
        <xades:SigPolicyId>
            <xades:Identifier>urn:oid:1.2.563</xades:Identifier>
        </xades:SigPolicyId>
        <xades:SigPolicyHash>
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
            <ds:DigestValue>Jkdb+aba0Hz6+ZPKmKNhPByzQ+Q=</ds:DigestValue>
        </xades:SigPolicyHash>
    </xades:SignaturePolicyId>
</xades:SignaturePolicyIdentifier>

I'm using this code:
XadesSigningProfile p = new XadesTSigningProfile(kp)
                 .withPolicyProvider(new SignaturePolicyInfoProvider() {
                    @Override
                    public SignaturePolicyBase getSignaturePolicy() {
                         try {
                             return new SignaturePolicyIdentifierProperty(new ObjectIdentifier("urn:oid:1.2.563"),
                                     new URL("https://portail.dgfip.finances.gouv.fr/documents/PS_Helios_DGFiP.pdf").openStream());
                         } catch (MalformedURLException ex) {
                             Logger.getLogger(StelaSign.class.getName()).log(Level.SEVERE, null, ex);
                             return new SignaturePolicyImpliedProperty();
                         } catch (IOException ex) {
                             Logger.getLogger(StelaSign.class.getName()).log(Level.SEVERE, null, ex);
                             return new SignaturePolicyImpliedProperty();
                         }
                    }
                 })               
                  .withAlgorithmsProviderEx(new AlgorithmsProviderEx() {
                    @Override
                    public Algorithm getSignatureAlgorithm(String string) throws UnsupportedAlgorithmException {
                       return new GenericAlgorithm(XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
                    }
                    @Override
                    public Algorithm getCanonicalizationAlgorithmForSignature() {
                        //return new GenericAlgorithm(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
                        return new GenericAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
                    }
                    @Override
                    public Algorithm getCanonicalizationAlgorithmForTimeStampProperties() {
                        //return new GenericAlgorithm(Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS);
                        return new GenericAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
                    }
                    @Override
                    public String getDigestAlgorithmForDataObjsReferences() {
                        //return DigestMethod.SHA1;                       
                        return Constants.ALGO_ID_DIGEST_SHA1;
                    }
                    @Override
                    public String getDigestAlgorithmForReferenceProperties() {
                         return Constants.ALGO_ID_DIGEST_SHA1;
                    }
                    @Override
                    public String getDigestAlgorithmForTimeStampProperties() {
                        return Constants.ALGO_ID_DIGEST_SHA1;
                    }
                })              
                ;

I can't integrate tags SigPolicyQualifiers and description for the tag 
SigPolicyId.

Does anyone knows the solution?

By advance, thank you !
Regards.

Original issue reported on code.google.com by sict...@gmail.com on 2 Jan 2013 at 9:15

GoogleCodeExporter commented 9 years ago
Hello!

Currently there isn't support for adding information other than the OID and the 
policy hash. This si something that has to be improved on the 
SignaturePolicyIdentifierProperty and its marshalling.

Original comment by luis.fgoncalv on 5 Jan 2013 at 2:20