Pulling my hairs for a valid pdf signature

Using Acrobat Pro 9 with a new server certificate from a different CA I've been trying to put a valid signature in a pdf file. For some reason acrobat is giving me the "Signature is invalid" message with a red cross. When I open the Certificate-details dialog I see a "!" at the bottom with the message "The selected certificate path has errors: Invalid policy constraint". I'm not really sure what this means? which constraints are invalid? Then I read acrobat can make a log file during the validation process so I wondered if this could help, I got something like this (I edited some parts to protect my client):
20110913195706Z:
20110913195706Z: Validating cert graph with 1 chains
20110913195706Z: Validating chain: CertChain_[edit] Length = 5
   20110913195706Z: ----ChainBuilder----
      20110913195706Z: Processing Certificate: DN: cn=[edit] CA - G2, o=[edit], c=NL Serial: [edit]
      20110913195706Z: verification time = 20110913131236+0200
      20110913195706Z: Processing Certificate: DN: cn=[edit] - G2, o=[edit], c=NL Serial: [edit]
      20110913195706Z: verification time = 20110913131236+0200
      20110913195706Z: Processing Certificate: DN: cn=[edit] - G2, o=[edit], c=NL Serial: [edit]
      20110913195706Z: verification time = 20110913131236+0200
      20110913195706Z: Processing Certificate: DN: cn=[edit] - G2, o=[edit], c=NL Serial: [edit]
      20110913195706Z: verification time = 20110913131236+0200
      20110913195706Z: Processing Certificate: DN: cn=[edit], ou=[edit], o=[edit], l=[edit], st=[edit], c=NL Serial: [edit]
      20110913195706Z: verification time = 20110913131236+0200
      20110913195706Z: Chain builder added trouble flags 0x200
   20110913195706Z: Finished Chain Validation.  TroubleFlags: 200
20110913195706Z:
I'm particularly interested if anyone knows what this line "Chain builder added trouble flags 0x200" means???
Any help is greatly appriciated!

Hi lullolullo,
You've come the right place. Signature validation starts with trust. If you don't trust the signer, or one of the certificates in the signing chain then nothing happens. A signature chain looks something like this:
Big Time CA Root Cert
    Intermediate Certificate Authority
        End-Entity (the signer, or in this case, you)
You have to assign trust to at least one of the certificates in the signature chain. You can either add trust via the Manage Trusted Identities dialog, or, via a preference where you can inherit trust from the Windows Certificate Store (Windows only, no Mac). To see the chain in the signature you are looking at do the following:
Right Mouse Click on the signature
Select Show Signature Properties from the pop-up menu
Click the Show Certificate button on the Signature Properties dialog
The chain is displayed in the tree view on the on the left side of the dialog
If you select the Trust tab and then select the different certificates in the chain view you will be able to see which one is the trust anchor.
Enough about trust, on to Policy Restrictions. When a Certificate Authority (CA) issues certificates they will often add the Certificate Policy extension. You can find this by selecting the Details tab and scrolling the list box for  Certificate Policies. The policy is a long dotted number that acts as a marker for a specific set of rules. The rules themselves tend to be published online in a "Certificate Practice Statement" document, but that's getting a little beyond the scope of your problem. The rule might mean something like all certificates issues under this policy constraint are issued to employees of Company XYZ and have to be on a hardware token. That's an example of something you might see, but I'm not saying it the exact scenario you are facing.
The Root CA usually doesn't have a Certificate Policy extension, but all of the certs under it do meaning that this particular chain obeys a specific set of rules.
On to enforcing the rules. Let's say you have Big Time CA that issues certificates for IBM, Microsoft, Apple, and Adobe. Each one of those chains would contain a different Certificate Policy. Now let's say that I've trusted Big Time CA, which means every signature that created that chains up to Big Time CA would be trusted and valid. Now lets say I only want to trust the signatures that come from my fellow Adobe employees. What I would do is add a Policy Restriction to the trust setting, thus making trust more granular.
Next up, where to find the Policy Restriction. Select the Policies tab on the Certificate Viewer. When you are viewing the same certificate that is designated as the trust anchor do you see something in the Policy Restrictions group box? By something I mean data in the Certificate Policies edit field that will appear to be grayed out. If so then the signers certificate, and all of the other certificates in the chain have to have the Certificate Policy Extension with that number in it.
If the restriction is there, you can remove it by going to the Manage Trusted Identities dialog, which you get to from the Advanced menu. From there you need to select Certificates from the Display drop-down list. Find the certificate that corresponds to the trust anchor, selected from the list box, and then click the Edit Trust button. Finally, select the Policy Restrictions tab on the Edit Certificate Trust dialog. However, I'm not advising you to break any company policy if they want the restriction in place.
Steve

Similar Messages

  • Using Access/VBA to tell if a PDF has a valid e-signature in it?

    I'm using VBA in Access 2010.  Is there a way to find out if a PDF document has a valid e-signature in it?
    I'd also like to be able to do the same thing in Outlook 2010, but Access is the main thing...
    ajw

    Hi
    >> Is there a way to find out if a PDF document has a valid e-signature in it?
    I'd also like to be able to do the same thing in Outlook 2010, but Access is the main thing...
    As far as I know, Access and Outlook did not provide such method. But I think you are able to achieve this goal through some 3<sup>rd</sup> party PDF component.
    Hope this will help you
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Can't open PDF.  Program does not have valid digital signature. No valid Acrobat S/N found.

    I recently bought new HP computer with Windows 7.  I loaded my Adobe Creative Suite 2 Premium.  Illustrator tries to open then just disappears.  I can not open PDF's.  Get the following message:  This program doesn't have valid digital signature that verifies it's signature.  No valid Acrobat S/N found. Acrobat will now quit.  Then: There is a problem with Adobe Acrobat/Reader. Please exit and try again.  When I exit - computer locks up.

    These can be frustrating.
    Try restarting your PC.
    Using a different browser.
    There have been reports that this can be due to router problems.
    A simple way round it is to get a friend to download the installer for your and put it on a USB stick.

  • I can't affix my valid digital signature to adobe reader pdf document?

    I can't affix my valid digital signature to adobe reader pdf document. When the signature field is clicked, it is not showing my digital ID so that I can sign with it. Why it is not displaying my valid digital ID?

    What is your operating system?  What is your Reader version?  What means "can not"?
    Can you post a screenshot of such a message "to buy Adobe XI"?

  • What plugins, software do I need for Wacom STU-300 signature pad to sign pdf?

    What plugins, software do I need for Wacom STU-300 signature pad to sign a pdf?

    This isn't the correct forum for this topic, but I may be
    able to get you started...
    The licensing restrictions on gathering form data from PDFs
    is outlined in the EULA for Reader, I believe there is a limit of
    500 copies, but I could be wrong ... you should look at the EULA to
    be sure.
    Beyond that, try posting to the
    Acrobat
    Forums or contacting a sales rep at Adobe, they may be able to
    advise you further.

  • PDF signature timestamp problem

    Hi, sorry if this post is slightly offtopic.
    We are trying to sign and timestamp pdf documents in java (using Apache PDFBox) and we are stuck with a problem for more than a week. The signature itself is good, Adobe Reader can validate it succesfully (after adding our self signed test root certificate to trusted certificates). The problem is with the timestamp. Adobe Reader says that the signature is timestamped, but the timestamp could not be verified. If I look at the Date/Time tab on the Signature Properties window the Timestamp Authority field says Not available. Older versions of Adobe Reader 9 displayed the Show Certificate button for the Timestamp Authority as enabled, and if I clicked it, the Reader crashed. In newer Reader 9 versions and in Reader X the button is disabled. It seems Reader recognises the timestamp but can't extract the TSA certificate.
    However if I sign the pdf with Acrobat X Pro or with iText (using the same private key and the same TSA) everything is perfect, the timestamp is validated, Timestamp Authority field shows the correct value, TSA certifiicate is OK.
    I analyzed the signatures and the timestamp tokens, but I could not find any significant difference between the good and wrong ones.
    I wanted to attach a working and a non-working sample but I didn't find how to do that.
    Could someone please give us some advice about what could cause something like this?
    Can Reader log the signature parsing/validating process to view what's wrong?
    Thanks in advance
    Csaba

    Hi,
    I had the same problem with the pdf signature timestamp…..
    The thing I was doing wrong was the SHA-1 hash sent to the timestamp server, more precisely I was sending the whole signature SHA-1 hash when I suppose to send the SHA-1 hash of the RSA encrypted hash of the digital signature (I think that in your case is the 256 hash starting from 1783).
    Hope this helps you,
    Corina

  • "this is not a valid PDF file" message when creating a new document?

    Every time i try and open a new document I get a message that says this is not a valid PDF file?
    Has anyone else recieved this message?

    Sorry, I am out of ideas. Unless anyone else can help I suggest you need to contact support directly. It’s usually possible to start a live chat, if an Adobe agent is free, and often to get problems fixed right away.
    To get help now click here for product support

  • This document cannot be opened as it is not a valid PDF document

    I am trying to get my Amex statement from Amex on my tablet. I have Adobe reader for Andriod and Pdf  to Go. Each time I download and tray to read the document I get this error. Other Pdf files I have downloaded open OK.

    I GOT PROBLEMS TOO...got this error when trying open the pdf files in android devices "The document cannot be opened because it is not a valid PDF document"  ..im using samsung s4..i tried open the same files at windows pc and its can be open fine,the files not contain any passwod btw..seem some files cannot be open at android is this normal or what? got solution of tht?or i just search another pdf viewer?
    example of files : http://www.mediafire.com/download/raz3x0bk1mvnni4/Lawak+Kampus+01%40ih azaliza.blogspot.com.pdf
    this the screenshot

  • This new version of FireFox is making me nutz! It is SUCKING 100% CPU time almost constantly. I could just pull my hair out. I wpdated once a month or so ag

    I tried to add this in the topic already open but it kept sending me through the unending rabbit holes!
    My question is: How do I figure out what release I was on, get rid of this one and got back to a functional firefox that moves in realtime. I already did all the reset and etc.... I just want to go back to the speed I had. This halting , hanging up misery of a browzer is Sad. I have had firefox for years and always recommended it ..... BUT NOT ANY MORE. I agree with the other poster ... there should be a rollback feature. Peoples time has value and right now FireFox is sucking the value down a rabbit hole.
    See Below Comment Feedback submitted before I finally got here:
    This new version of FireFox is making me nutz! It is SUCKING 100% CPU time almost constantly. I could just pull my hair out. I wpdated once a month or so ago and it slowed down..... but the latest update before I did the reset really slowed me down. I came here to fix it a couple of dayz ago and did the reset firefox and now it IS RUNNING SO POORLY AND SLOW I AM ABOUT TO KILL IT OFF MY MACHINE!!! Yes that is me yelling - and it happened in SSSSSSSSSSSSS LLLLLLLLL OOOOOOOO WWWWWWWWWW Motion. I have run all the security scans and cleanups ---this needs a fix ASAP!!! PS: The hang ups and slowness is EVERYWHERE I go. I only get speed doing programs not connected to ON LINE.

    Hello,
    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!
    Thank you.

  • "Can't open file - not a valid pdf"

    Hi,
    This seems to have been asked before but I can't find an answer!!
    I have a small app that i use for work which essentially just links to pdfs stored on a wordpress site
    All has been working well until recently when android phones can no longer open the files - they get a "can't open file - not a valid pdf file" message
    It seems to happen with many but not all the files. Some examples of problematic ones are:
    http://uhbsosguidelines.files.wordpress.com/2014/02/transfusionmajorhaemorrhagecompressed. pdf
    http://uhbsosguidelines.files.wordpress.com/2014/02/aagbi_la_toxicitycompress.pdf
    http://uhbsosguidelines.files.wordpress.com/2015/01/anaphylaxis-under-anaesthesiaupdated02 14compresresave.pdf
    Oddly, it seems only to be a problem when trying to open directly from the link in the app into adobe reader. If you download the file onto the phone THEN open it in Reader it works fine!
    As I say, this seems to be a recent problem - has been working perfectly up until now.
    I'd really appreciate it if you have any thoughts / suggestions - I don't want to have to ask all the users to install a different PDF reader app!

    Thanks for reporting the issue. We have been able to reproduce it at our end and shall let you know when this gets fixed in one of the future releases.
    Thanks,
    Adobe Reader Team

  • Validating detached signature with jsr105

    Hi all.
    I need to sign a SOAP message and I need to use JSR105. I've created a message with the following code and is signed without problems. However, I can't validate the signature. As you can see the elements that contains the nodes are OMElement (specific for Axis2 SOAP server) that are an instance of Node and Element classes.
    The error I get is:
    Exception in thread "main" javax.xml.crypto.dsig.XMLSignatureException: javax.xml.crypto.URIReferenceException: com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID 1
         at org.jcp.xml.dsig.internal.dom.DOMReference.dereference(DOMReference.java:366)
         at org.jcp.xml.dsig.internal.dom.DOMReference.validate(DOMReference.java:318)
         at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.validate(DOMXMLSignature.java:230)
         at SignedSoap.main(SignedSoap.java:272)
    Caused by: javax.xml.crypto.URIReferenceException: com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID 1
         at org.jcp.xml.dsig.internal.dom.DOMURIDereferencer.dereference(DOMURIDereferencer.java:84)
         at org.jcp.xml.dsig.internal.dom.DOMReference.dereference(DOMReference.java:358)
         ... 3 more
    Caused by: com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID 1
         at com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverFragment.engineResolve(Unknown Source)
         at com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver.resolve(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMURIDereferencer.dereference(DOMURIDereferencer.java:77)
         ... 4 more
    javax.xml.crypto.URIReferenceException: com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID 1
         at org.jcp.xml.dsig.internal.dom.DOMURIDereferencer.dereference(DOMURIDereferencer.java:84)
         at org.jcp.xml.dsig.internal.dom.DOMReference.dereference(DOMReference.java:358)
         at org.jcp.xml.dsig.internal.dom.DOMReference.validate(DOMReference.java:318)
         at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.validate(DOMXMLSignature.java:230)
         at SignedSoap.main(SignedSoap.java:272)
    Caused by: com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID 1
         at com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverFragment.engineResolve(Unknown Source)
         at com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver.resolve(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMURIDereferencer.dereference(DOMURIDereferencer.java:77)
         ... 4 more
    My code is as follows
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.Provider;
    import java.security.SecureRandom;
    import java.util.Calendar;
    import java.util.Collections;
    import javax.xml.crypto.dsig.*;
    import javax.xml.crypto.dom.*;
    import javax.xml.crypto.dsig.dom.*;
    import javax.xml.crypto.dsig.keyinfo.*;
    import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
    import javax.xml.soap.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.sax.SAXSource;
    import javax.xml.transform.stream.*;
    import org.apache.axiom.om.OMAttribute;
    import org.apache.axiom.om.OMElement;
    import org.apache.axiom.om.OMNamespace;
    import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
    import org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader;
    import org.w3c.dom.*;
    import org.w3c.dom.Node;
    import org.xml.sax.InputSource;
    //import org.xmlsoap.schemas.soap.encoding.DateTime;
    * Construct a SOAP message, sign it and then validate the signature.
    * This implementation follows the
    * <a ref="http://www.w3.org/TR/SOAP-dsig/">
    * W3C Note on digital signatures in SOAP messages
    * </a>.
    * The validating key is included in the signature.
    * DOM Level 2 is used throughout.
    * <p>
    * The following SOAP message is signed:
    * <pre><code>
    * <?xml version="1.0" encoding="UTF-8"?>
    * <soap-env:Envelope
    * xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    * <soap-env:Header>
    * <SOAP-SEC:Signature
    * mustUnderstand="1"
    * xmlns:SOAP-SEC="http://schemas.xmlsoap.org/soap/security/2000-12"/>
    * </soap-env:Header>
    * <soap-env:Body id="Body">
    * <m:GetLastTradePrice xmlns:m="http://wombats.ztrade.com">
    * <symbol>SUNW</symbol>
    * </m:GetLastTradePrice>
    * </soap-env:Body>
    * </soap-env:Envelope>
    * </code></pre>
    public class SignedSoap {
    private static boolean debug = false;
    public static void main(String[] args) throws Exception {
         int argc = args.length;
         if (argc == 1) {
         if (args[0].equalsIgnoreCase("-help")) {
              System.out.println("Usage: SignedSoap [-debug]");
              System.out.println(" -debug\tactivates debug messages");
              return;
         debug = args[0].equalsIgnoreCase("-debug");
         // Create the SOAP message
         OMDOMFactory omfact=new OMDOMFactory();
         //Node nodo1=fd.newDomNode(options);
         OMNamespace namespace=omfact.createOMNamespace("http://schemas.xmlsoap.org/soap/security/2000-12", "soapenv");
         OMNamespace namespace2=omfact.createOMNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "wsu");
         OMAttribute attr=omfact.createOMAttribute("mustUnderstand",namespace,"1");
         OMAttribute id=omfact.createOMAttribute("id",namespace,"1");
         OMAttribute id2=omfact.createOMAttribute("id",namespace,"2");
         OMElement sec=omfact.createOMElement("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse");
         OMElement timestamp=omfact.createOMElement("Timestamp",namespace2);
         OMElement created=omfact.createOMElement("Created",namespace2);
         OMElement expires=omfact.createOMElement("Expires",namespace2);
         created.setText("12122007");
         expires.setText("12122008");
         timestamp.addAttribute(id);
         timestamp.addChild(created);
         timestamp.addChild(expires);
         sec.addChild(timestamp);
         System.out.println("Generating the DOM tree...");
         // Get input source
         org.w3c.dom.Node security = (Node)sec;
         //if (debug) {
         // dumpDOMDocument(root);
         // Generate a DSA key pair
         System.out.println("Generating the DSA keypair...");
         KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
         kpg.initialize(1024, new SecureRandom("not so random".getBytes()));
         KeyPair keypair = kpg.generateKeyPair();
    // Assemble the signature parts
         System.out.println("Preparing the signature...");
         String providerName = System.getProperty
    ("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
         XMLSignatureFactory sigFactory = XMLSignatureFactory.getInstance("DOM",
    (Provider) Class.forName(providerName).newInstance());
    Reference ref = sigFactory.newReference("#1",
         sigFactory.newDigestMethod(DigestMethod.SHA1, null));
    SignedInfo signedInfo = sigFactory.newSignedInfo(
         sigFactory.newCanonicalizationMethod(
              CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
              (C14NMethodParameterSpec) null),
    sigFactory.newSignatureMethod(SignatureMethod.DSA_SHA1, null),
         Collections.singletonList(ref));
         KeyInfoFactory kif = sigFactory.getKeyInfoFactory();
         KeyValue kv = kif.newKeyValue(keypair.getPublic());
    KeyInfo keyInfo = kif.newKeyInfo(Collections.singletonList(kv));
    XMLSignature sig = sigFactory.newXMLSignature(signedInfo, keyInfo);
         // Insert XML signature into DOM tree and sign
         System.out.println("Signing the SOAP message...");
         // Find where to insert signature
         Element ts = getFirstChildElement(envelope);
         DOMSignContext sigContext =
         new DOMSignContext(keypair.getPrivate(), sec);
         // Need to distinguish the Signature element in DSIG (from that in SOAP)
         sigContext.putNamespacePrefix(XMLSignature.XMLNS, "ds");
         // register Body ID attribute getNextSiblingElement(
         sigContext.setIdAttributeNS
         (ts,
         "http://schemas.xmlsoap.org/soap/security/2000-12","id");
         sig.sign(sigContext);
         if (debug) {
         dumpDOMDocument(envelope);
         // Validate the XML signature
    // Locate the signature element
         Element sigElement = getNextSiblingElement(ts);
    // Validate the signature using the public key generated above
    DOMValidateContext valContext =
         new DOMValidateContext(keypair.getPublic(), sigElement);
         // register Body ID attribute getNextSiblingElement(
         valContext.setIdAttributeNS
         (ts,
         "http://schemas.xmlsoap.org/soap/security/2000-12","id");
    boolean isValid = sig.validate(valContext);
         System.out.println("Validating the signature... " +
         (isValid ? "valid" : "invalid"));
    * Outputs DOM representation to the standard output stream.
    * @param root The DOM representation to be outputted
    private static void dumpDOMDocument(org.w3c.dom.Node root)
         throws TransformerException, TransformerConfigurationException {
         System.out.println("\n");
         // Create a new transformer object
         Transformer transformer =
         TransformerFactory.newInstance().newTransformer();
         transformer.setOutputProperty(OutputKeys.INDENT, "yes");
         // Dump the DOM representation to standard output
         transformer.transform(new DOMSource(root), new StreamResult(System.out));
         System.out.println("\n");
    * Returns the first child element of the specified node, or null if there
    * is no such element.
    * @param node the node
    * @return the first child element of the specified node, or null if there
    *     is no such element
    * @throws NullPointerException if <code>node == null</code>
    private static Element getFirstChildElement(org.w3c.dom.Node node) {
         org.w3c.dom.Node child = node.getFirstChild();
         while (child != null &&
         child.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
    child = child.getNextSibling();
    return (Element) child;
    * Returns the next sibling element of the specified node, or null if there
    * is no such element.
    * @param node the node
    * @return the next sibling element of the specified node, or null if there
    *     is no such element
    * @throws NullPointerException if <code>node == null</code>
    public static Element getNextSiblingElement(org.w3c.dom.Node node) {
         org.w3c.dom.Node sibling = node.getNextSibling();
         while (sibling != null &&
         sibling.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
    sibling = sibling.getNextSibling();
    return (Element) sibling;
    Thanks in advance

    I've done further advancemets. It seems that the element to feed the sign validator MUST be a document AND that the ID attribute has to be registered in it even if has been already located in inner elements of the message. Now my code looks as follows but I'm not validating the reference. The sign itself can validate though.
    The problem is the reference validation. Any ideas? Could it be the prefixes or namespaces? I've been making tests changing both but no luck so far.
    Thanks in advance.
    package _2006_08.sa.liberty;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.Provider;
    import java.security.SecureRandom;
    import java.util.Calendar;
    import java.util.Collections;
    import java.util.Iterator;
    import javax.xml.crypto.URIDereferencer;
    import javax.xml.crypto.URIReference;
    import javax.xml.crypto.dsig.*;
    import javax.xml.crypto.dom.*;
    import javax.xml.crypto.dsig.dom.*;
    import javax.xml.crypto.dsig.keyinfo.*;
    import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
    import javax.xml.soap.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.sax.SAXSource;
    import javax.xml.transform.stream.*;
    import org.apache.axiom.om.OMAttribute;
    import org.apache.axiom.om.OMElement;
    import org.apache.axiom.om.OMNamespace;
    import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
    import org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader;
    import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0_xsd.SecurityDocument;
    import org.w3c.dom.*;
    import org.w3c.dom.Node;
    import org.xml.sax.InputSource;
    //import org.xmlsoap.schemas.soap.encoding.DateTime;
    * Construct a SOAP message, sign it and then validate the signature.
    * This implementation follows the
    * <a ref="http://www.w3.org/TR/SOAP-dsig/">
    * W3C Note on digital signatures in SOAP messages
    * </a>.
    * The validating key is included in the signature.
    * DOM Level 2 is used throughout.
    * <p>
    * The following SOAP message is signed:
    * <pre><code>
    * <?xml version="1.0" encoding="UTF-8"?>
    * <soap-env:Envelope
    * xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    * <soap-env:Header>
    * <SOAP-SEC:Signature
    * mustUnderstand="1"
    * xmlns:SOAP-SEC="http://schemas.xmlsoap.org/soap/security/2000-12"/>
    * </soap-env:Header>
    * <soap-env:Body id="Body">
    * <m:GetLastTradePrice xmlns:m="http://wombats.ztrade.com">
    * <symbol>SUNW</symbol>
    * </m:GetLastTradePrice>
    * </soap-env:Body>
    * </soap-env:Envelope>
    * </code></pre>
    public class SignedSoap {
    private static boolean debug = false;
    public static void main(String[] args) throws Exception {
         int argc = args.length;
         if (argc == 1) {
         if (args[0].equalsIgnoreCase("-help")) {
              System.out.println("Usage: SignedSoap [-debug]");
              System.out.println(" -debug\tactivates debug messages");
              return;
         debug = args[0].equalsIgnoreCase("-debug");
         // Create the SOAP message
         System.out.println("Creating the SOAP message...");
         SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
         SOAPPart soapPart = soapMessage.getSOAPPart();
         SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
         if(soapEnvelope instanceof Source){
              System.out.println("0");
         if(soapEnvelope instanceof Node){
         System.out.println("1");
         if(soapEnvelope instanceof Element){
         System.out.println("2");
         if(soapEnvelope instanceof Document){
              System.out.println("3");
         SOAPHeader soapHeader = soapEnvelope.getHeader();
         SOAPHeaderElement headerElement = soapHeader.addHeaderElement(
    soapEnvelope.createName("Signature", "SOAP-SEC",
    "http://schemas.xmlsoap.org/soap/security/2000-12"));
         SOAPBody soapBody = soapEnvelope.getBody();
         soapBody.addAttribute(soapEnvelope.createName("id", "SOAP-SEC",
         "http://schemas.xmlsoap.org/soap/security/2000-12"), "1");
         Name bodyName =soapEnvelope.createName("GetLastTradePrice", "m",
         "http://wombats.ztrade.com");
         SOAPBodyElement gltp = soapBody.addBodyElement(bodyName);
         Name name = soapEnvelope.createName("symbol");
         SOAPElement symbol = gltp.addChildElement(name);
         symbol.addTextNode("SUNW");
         // Generate a DOM representation of the SOAP message
         OMDOMFactory omfact=new OMDOMFactory();
         //Node nodo1=fd.newDomNode(options);
         OMNamespace namespace=omfact.createOMNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "wsu");
         OMNamespace namespace2=omfact.createOMNamespace("http://www.w3.org/2002/12/soap-envelope", "S");
         OMAttribute attr=omfact.createOMAttribute("mustUnderstand",namespace,"1");
         OMAttribute id=omfact.createOMAttribute("Id",namespace2,"1");
         OMAttribute id2=omfact.createOMAttribute("Id",namespace2,"2");
         OMElement sec=omfact.createOMElement("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse");
         OMElement timestamp=omfact.createOMElement("Timestamp",namespace);
         OMElement created=omfact.createOMElement("Created",namespace);
         OMElement expires=omfact.createOMElement("Expires",namespace);
         OMElement frame=omfact.createOMElement("Framework",namespace2);
         OMElement signa=omfact.createOMElement("Signature",namespace2);
         timestamp.declareDefaultNamespace(namespace.getNamespaceURI());
         timestamp.setNamespace(namespace);
         Calendar now=Calendar.getInstance();
         Calendar exp=Calendar.getInstance();
         exp.add(now.MINUTE, 5);
         System.out.println("test");
         created.setText("created");
         expires.setText("expires");
         System.out.println("test");
         timestamp.addAttribute(id);
         System.out.println("test");
         timestamp.addChild(created);
         timestamp.addChild(expires);
         //sec.addChild(signa);
         sec.addAttribute(id2);
         sec.addChild(timestamp);
         //sec.addChild(frame);
         //System.out.println(sec.getParent().toString());
         System.out.println("Generating the DOM tree...");
         // Get input source
         Source source = soapPart.getContent();
         if(soapPart instanceof Source){
                   System.out.println("10");
              if(soapPart instanceof Node){
              System.out.println("11");
              if(soapPart instanceof Element){
              System.out.println("12");
              if(soapPart instanceof Document){
                   System.out.println("13");
         //Source source2 = soapPart.getFirstChild();
         //System.out.println(source.toString());
              //javax.xml.stream.XMLStreamReader inSource = sec.getXMLStreamReader();
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         DocumentBuilder db = null;
         System.out.println("13");
         //synchronized (dbf) {
              db = dbf.newDocumentBuilder();
              System.out.println("13");
         Document doc = db.newDocument();
         doc.appendChild((Node)sec);
         org.w3c.dom.Node root = (org.w3c.dom.Node) doc.getDocumentElement();
         System.out.println("13");
         System.out.println("13: "+root.getFirstChild().getLocalName());
         org.w3c.dom.Node envelope = (Node)sec;//soapPart.getFirstChild();
    /* Node) sec;
         if (source instanceof DOMSource) {
         root = ((DOMSource)source).getNode();
         } else if (source instanceof SAXSource) {
         InputSource inSource = ((SAXSource)source).getInputSource();
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         DocumentBuilder db = null;
         synchronized (dbf) {
              db = dbf.newDocumentBuilder();
         Document doc = db.parse(inSource);
         root = (org.w3c.dom.Node) doc.getDocumentElement();
         } else {
         System.err.println("error: cannot convert SOAP message (" +
              source.getClass().getName() + ") into a W3C DOM tree");
         System.exit(-1);
         //if (debug) {
         // dumpDOMDocument(root);
         // Generate a DSA key pair
         System.out.println("Generating the DSA keypair...");
         KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
         kpg.initialize(1024, new SecureRandom("not so random".getBytes()));
         KeyPair keypair = kpg.generateKeyPair();
    // Assemble the signature parts
         System.out.println("Preparing the signature...");
         String providerName = System.getProperty
    ("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
         XMLSignatureFactory sigFactory = XMLSignatureFactory.getInstance("DOM",
    (Provider) Class.forName(providerName).newInstance());
    Reference ref = sigFactory.newReference("#1",
         sigFactory.newDigestMethod(DigestMethod.SHA1, null));
    SignedInfo signedInfo = sigFactory.newSignedInfo(
         sigFactory.newCanonicalizationMethod(
              CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
              (C14NMethodParameterSpec) null),
    sigFactory.newSignatureMethod(SignatureMethod.DSA_SHA1, null),
         Collections.singletonList(ref));
         KeyInfoFactory kif = sigFactory.getKeyInfoFactory();
         KeyValue kv = kif.newKeyValue(keypair.getPublic());
    KeyInfo keyInfo = kif.newKeyInfo(Collections.singletonList(kv));
    XMLSignature sig = sigFactory.newXMLSignature(signedInfo, keyInfo);
         // Insert XML signature into DOM tree and sign
         System.out.println("Signing the SOAP message...");
         // Find where to insert signature
         //Element envelope = getFirstChildElement(root);
         Element header = getFirstChildElement(envelope);
         System.out.println("Signing the SOAP message...");
         //System.out.println(header.getLocalName());
         DOMSignContext sigContext =
         new DOMSignContext(keypair.getPrivate(), envelope);
         // Need to distinguish the Signature element in DSIG (from that in SOAP)
         System.out.println("Signing the SOAP message...");
         sigContext.putNamespacePrefix(XMLSignature.XMLNS, "ds");
         // register Body ID attribute getNextSiblingElement(
         sigContext.setIdAttributeNS
         (header,
                   "http://www.w3.org/2002/12/soap-envelope","Id");
         System.out.println("Signing the SOAP message...");
         sig.sign(sigContext);
         if (debug) {
         dumpDOMDocument(envelope);
         // Validate the XML signature
         String providerName2 = System.getProperty
    ("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
    XMLSignatureFactory sigFactory2 = XMLSignatureFactory.getInstance("DOM",
    (Provider) Class.forName(providerName2).newInstance());
    SecurityDocument secdoc=SecurityDocument.Factory.parse(envelope);
    System.out.println(secdoc.xmlText());
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         Document doc = dbf.newDocumentBuilder().parse(secdoc.newInputStream());
    // Locate the signature element
         //Element sigElement = //getFirstChildElement(header);
              //getNextSiblingElement(header);
    // Validate the signature using the public key generated above
         System.out.println(doc.getFirstChild().getLastChild().getLocalName());
         DOMValidateContext valContext = new DOMValidateContext
    (keypair.getPublic(), doc.getElementsByTagName("ds:Signature").item(0));
              valContext.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
              System.out.println(doc.getElementsByTagName("ds:Signature").item(0).getLocalName());
    // DOMValidateContext valContext =
         // new DOMValidateContext(keypair.getPublic(), sigElement);
         // register Body ID attribute getNextSiblingElement(
    // System.out.println(header.getNamespaceURI());
              //valContext.setIdAttributeNS((Element) doc.
                   //     getElementsByTagNameNS("wsu", "Timestamp").item
                        //(0), null, "Id");
              ((Element)doc.getElementsByTagName("wsu:Timestamp").item(0)).setAttributeNS("S", "Id", "1");
              ((Element)doc.getElementsByTagName("wsu:Timestamp").item(0)).setPrefix("wsu");
              valContext.setIdAttributeNS((Element)doc.getElementsByTagName("wsu:Timestamp").item(0),
         "http://www.w3.org/2002/12/soap-envelope","Id");
         //System.out.println(valContext.getElementById("1").getLocalName());
         //valContext.setBaseURI("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
         System.out.println("1");
         XMLSignature signature = sigFactory2.unmarshalXMLSignature(valContext);
         System.out.println("2: "+valContext.getDefaultNamespacePrefix());
         System.out.println(valContext.getElementById("1").getLocalName());
         //System.out.println(header.getLocalName());
         //System.out.println(getNextSiblingElement(header).getLocalName());
         //System.out.println(header.getAttribute("id"));
         //System.out.println(header.getBaseURI());
         if(signature.getSignatureValue().validate(valContext))
         System.out.println("Firma OK");
         Iterator it = signature.getSignedInfo().getReferences().iterator();
    if (((Reference) it.next()).validate(valContext))
         System.out.println("ref OK");
    boolean isValid = signature.validate(valContext);
         System.out.println("Validating the signature... " +
         (isValid ? "valid" : "invalid"));
    * Outputs DOM representation to the standard output stream.
    * @param root The DOM representation to be outputted
    private static void dumpDOMDocument(org.w3c.dom.Node root)
         throws TransformerException, TransformerConfigurationException {
         System.out.println("\n");
         // Create a new transformer object
         Transformer transformer =
         TransformerFactory.newInstance().newTransformer();
         transformer.setOutputProperty(OutputKeys.INDENT, "yes");
         // Dump the DOM representation to standard output
         transformer.transform(new DOMSource(root), new StreamResult(System.out));
         System.out.println("\n");
    * Returns the first child element of the specified node, or null if there
    * is no such element.
    * @param node the node
    * @return the first child element of the specified node, or null if there
    *     is no such element
    * @throws NullPointerException if <code>node == null</code>
    private static Element getFirstChildElement(org.w3c.dom.Node node) {
         org.w3c.dom.Node child = node.getFirstChild();
         while (child != null &&
         child.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
    child = child.getNextSibling();
    return (Element) child;
    * Returns the next sibling element of the specified node, or null if there
    * is no such element.
    * @param node the node
    * @return the next sibling element of the specified node, or null if there
    *     is no such element
    * @throws NullPointerException if <code>node == null</code>
    public static Element getNextSiblingElement(org.w3c.dom.Node node) {
         org.w3c.dom.Node sibling = node.getNextSibling();
         while (sibling != null &&
         sibling.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
    sibling = sibling.getNextSibling();
    return (Element) sibling;
    }

  • Install blocked does not have a valid digital signature verifying publisher.

    Windows XP blocked the install. Error message was:
    Unknown Publisher. Does not have a valid digital signature that verifies its puiblisher.

    That suggests that the installer is getting damaged during the download.
    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/itunes/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • Legally valid electronic signatures

    My boss has asked me to research legally valid electronic signatures. I was wondering if Adobe provided these so they can be used to sign certain documents for business and banking?

    You should checkout Adobe EchoSign:
    https://www.echosign.adobe.com

  • On my ipad, is it possible to use stylus or fingers to copy and paste a specific area on a document, PDF., web page, etc... It would be great to pull specific areas out of a PDF. And paste into a note app I'm thinking of downloading.  Thank you.

    On my ipad, is it possible to use a stylus or fingers to draw out a specific area to copy and paste;  I'm looking to copy from a word document, PDF., web page, etc... It would be great to pull specific areas out of a PDF. And paste into a note app I'm thinking of downloading.  Thank you.

    Yes. I do it using Adobe Reader for PDF files, Pages for Word files, I can copy from Safari or iCab Mobile and paste into another app. I use my finger even though I do have a stylus. I rarely use my stylus anymore, but yes it's possible.

  • Acrobat vs Livecyle - which is better for making accessible PDF's

    I am having a very hard time making my PDF accessible. The source program I use to create my document is InDesign 5.5. I convert to PDF and am attempting to tag it using Acrobat X. I tried tagging my form using the articles panel in InDesign but it doesnt convert to PDF properly (which i learned at this forum is a system glitch). Someone at work suggesting using LiveCycle but I am not familiar with LiveCycle at all. I thougt it was an add-on extension to Acrobat so I'm confused why someone would tell me to use LiveCycle instead of Acrobat X. Can someone please clarify for me what the diff is between Acrobat and Livecyle. I need to make my document accessible by the end of the week and having a lot of problems doing it but i want to make sure that Acrobat is the best adobe product to use before going any further.
    Any help is GREATLY appreciated!

    Hi miss forms,
    I'm out of the country just now and "on-line" time is occasional. However, here are some observations for your consideration.
    All this may sound daunting. It is not (honest). Think of it as becoming a competent cook.
    Some study. Some practice then it is Rachael Ray time.
    ~~~~~~~~~~~
    Here's a short take:
    Use InD CS 5.5 to master the underlying "form text".
    Master content with accessible PDF in mind.
    Example - if any "headings" are to be used then use InD built-in paragraph tags.
    Output the tagged PDF.
    Walk the structure tree. Perform requisite post-processing activities.
    Goal is to acquire that well-formed tagged PDF.
    Next, build the form fields.
    Properly fold these into the structure tree.
    ~~~~~~~~~~~
    Observations:
    "... but i want to make sure that Acrobat is the best adobe product to use before going any further."
    Currently and for the foreseeable future - if  you must provide accessible PDF as a deliverable you must have Acrobat Pro.
    You want the most current version and you want to keep it updated.
    Currently there is no such thing as an accessible PDF that does not require post-processing by a knowledgeable "warm-body".
    As the 'warm-body' you perform the essential V&V prior to release of the deliverable.
    While there are tools to help with they still do not replace the 'warm-body'.
    "I need to make my document accessible by the end of the week ..."
    This could be problematic. Unless you are all ready well versed in what a well-formed tagged PDF is and how to stage it in the authoring file I suspect that you won't have a proper deliverable by 30 November.
    Using InD CS 5.5 is 'good' but it is not (as you've discovered) adequately robust for well-formed tagged PDF output compared to the current release.
    The output PDF needs manual remediation (only possible with Acrobat Pro).
    As to any current authoring application used -
    Whatever is used it needs to provide robust "tag management".
    Currently the first string consists of:
    Adobe FrameMaker,
    Adobe InDesign,
    (n.b., Adobe has invested significant resources in improving mastering content for accessible PDF and output of tagged PDF InDesign versions released since CS5.5. So, if InD is your requisite authoring application I'd recommend you move into the current release.)
    MS Word 2010.
    When using MS Word 2010 one can use the MS Save As PDF - XPS configured to provide accessible PDF or use
    PDFMaker.
    For Word 2010 you'd need at least Acrobat X in order to have a compatible PDFMaker.
    Some other applications are also providing for authoring / tagged PDF output (such as Open Office).
    Regardless of the authoring application used Acrobat Pro is still need for requisite post-processing (structure tree V&V, cleanup, etc).
    What form "type" to use?
    I'd recommend Acrobat forms rather than XFA forms.
    Accessible XFA forms are possible.
    But, As George said - a non-trivial learning curve for the basics. Then comes the learning / practice to develop the accessible XFA form.
    If you go with XFA I suggest obtaining the XFA spec that Adobe provides.
    Considering the improvements Adobe has made in Acrobat XI for Acrobat forms I'd recommend you use that.
    However, if you have an older version you can still get there from here (using Acrobat Pro).
    "Tools" considerations:
    Common Look PDF - An enterprise level tool.
    A plug-in for Acrobat.
    Common Look Office Pro
    (Pro supports PDF forms (Acrobat forms - not XFA forms)
    An add-in / plug-in for MS Office 2007/2010.
    Used with Power Point or Word.
    Provides check points on mastered content. You resolve identified issues then use it to output a tagged PDF.
    Perfom requisite post-processing with Acrobat Pro.
    http://www.commonlook.com/CommonLook-office
    MS Word 2010
    Provides content mastering "coaching" for output of accessible PDF.
    PDF Accessibility Checker
    A "validation" tool.
    http://www.access-for-all.ch/en/pdf-lab/pdf-accessibility-checker-pac.html
    AIIM's PDF/UA, Universal Accessiblity
    http://www.aiim.org/Research-and-Publications/Standards/Committees/PDFUA
    The "Achieving WCAG 2.0 with PDF/UA" is available.
    The Implementation Guides are in the oven.
    ISO 14289-1:2012 (ISO standard for PDF/UA)
    Available for purchase at ANSI's web store.
    ISO 32000-1 (ISO standard for PDF)
    Section 14.8 discusses tagged PDF.
    Free, ISO approved copy available from Adobe.
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_200 8.pdf
    I've tried to harvest accessible PDF documentation Adobe's provided since Acrobat 5.
    Have most of it my "eReference Shelves"; but, that's at home.
    What's nice about these documents is that you can harvest activity specific information with confidence that it is an appropriate "reciepe".
    If interested in adding these to your "shelves" let me know.
    Use this forum's PM feature.
    Be well...

Maybe you are looking for

  • Exporting to QT produces garbage video

    I am at a complete loss. I export to QT self-playing movie (CD-ROM Movie, Medium), set the duration and build duration and all seems to work. When I play back the movie in QT, the duration of Slide 1 is correct, Slide 2 has a shorter duration than se

  • GT784WNV not working in Bridge Mode! Fed up with lack of Customer Service

    I don't even know where to start but I am this close to just cancelling Verizon and switching to cable internet.  If you want to skip the rant, jump down a paragraph. I recently moved from a house a few miles away in which I had a solid DSL connectio

  • Logical vs. Physical Partitioning

    Hi, In a discussion of logical partition the author pointed out that “… if a query that needs data from all 5 years would then automatically (you can control this) be split into 5 separate queries, one against each cube, running at the same time. The

  • I have updated to Lion OK. Do I need to download updates to Pages and Numbers as well?

    I have updated to Lion OK.   Do I need to download updates to Pages and Numbers as well?

  • Oracle 10.2.0.3 does not use hugepages..

    Hello, We have RHEL4 x86_64 AMD server. Oracle 10.2.0.3 database is running on it. We want to configure hugepage for database. We followed the belov step; 1. we added vm.nr_hugepages = 1024 into /etc/sysctl.conf 2. we added <dblinuxuser> hard memlock