3 Replies Latest reply on Jul 7, 2016 5:52 AM by gkaiseril

    Password protecting text field or text document

    michaelb41184333 Level 1

      I have a pdf document that has fillable fields and needs to be accessible and editable by any user to begin with. The trick is when they enter their Social Security Number (a text field). I need to protect that piece of information, whether it be the entire document or the text box, but it cannot have a required password to start. But it still needs to be accessible to the authorized people.

       

      Currently I have an empty black box that goes from hide to show after the SSN field is blurred. Which works for protecting the SSN only if the user does not move the cover up box and is a security flaw.

       

      The options that I figured would be best are:

       

      1. Set a password for the whole document as soon as the SSN has been entered but will allow the user to still fill out the available fields.

           - I was not able to find much information on this method but think the script would be fairly simple.

       

      2. Set a password for the cover up box to prompt the user to enter a password which only the authorized people will be given.

           - I had found some information on this method and made the script below, but had no luck.

       

      //Prompts user to enter a password that will remove the box when the Cover up box is on focus

      this.getField("CoverUp").setAction({

                                cTrigger: "OnFocus",

                                cScript: " var cResponse = app.response({ "        +

                                             " cQuestion: \"Please enter password\", "       +

                                             " cTitle: \"Quality Assurance\", "        +

                                             " bPassword: true, "            +

                                             " cDefault: \"\", "           +

                                             " cLabel: \"Password:\" "          +

                                                 " }); "              +

       

                                            " if(cResponse == \'password\') "        + 

                                                        "this.getField(\"CoverUp\").display.hidden = true; "  +

                                            " else if(cResponse == null) "         +

                                                        "app.alert(\"Please Contact Julia.\"); " +

                                            " else "              +

                                                        "app.alert(\"Incorrect Password\"); "  

       

      }); //End of revealing action

       

       

      I am not too familiar with JavaScript but I do have some coding knowledge and can figure it out. I just need some help getting the ball rolling or if anyone could tell me if I am even headed in the right direction with my ideas or script so far.

       

      I am also open to other options that might be more efficient.

       

      Thanks for your time and any help.

        • 1. Re: Password protecting text field or text document
          gkaiseril MVP & Adobe Community Professional

          Can you be more specific about "... but had no luck."?

           

          What do you think the script you have provided does?

           

          Do you think the what the script does could be done another way?

           

          Will your users be using Reader to run this script?

           

          We cannot see you form nor any error messages that may be thrown.

           

          Have you looked at any documentation provided about security and security handlers?

          • 2. Re: Password protecting text field or text document
            michaelb41184333 Level 1

            Hi gkaiseril,

             

            Can you be more specific about "... but had no luck."?

            The only way I can be more specific is that the form does not do anything different that what it did before the script was added.

            What do you think the script you have provided does?

            Generally: Prompts user to enter a password that will remove the box when the Cover up box is on focus

            Specifically: When the cover up box is on focus it prompts the user asking for a password, which they will have to enter in the pop up dialog box.

            Then based on their credentials entered it will

            a.) If the password is correct, hide the cover up box exposing the SSN

            b.) If the password is empty, prompt the user to contact someone

            c.) If the password is wrong, prompt the user that the password was incorrect

            Do you think the what the script does could be done another way?

            It's code so I'm sure it could be done another way, but after searching around and looking at the Adobe JavaScript reference guide this way seemed to be my best option.

            Will your users be using Reader to run this script?

            They could be using either Reader or Adobe Acrobat Standard X or XI

            We cannot see you form nor any error messages that may be thrown.

            I did not receive any error messages.

            Have you looked at any documentation provided about security and security handlers?

            I have spent quite a bit of time researching the Adobe JavaScript reference guide and other similar issues but could not find anything that really fit my case. I know that I have read in multiple threads that PDF can only lock the entire document, which would work but I could not find any methods to lock a document only after an event happens in the PDF.

             

             

            Thanks

            • 3. Re: Password protecting text field or text document
              gkaiseril MVP & Adobe Community Professional

              You will not see any change because the code adds some code to the on focus action of the field "CoverUp".  I have run to code and it has no errors. I ran the code by opening the Acrobat JavaScript console and pasting the code into the "Console View" and executing the code. Then I went into the preview mode and tabbed into the field. A pop prompt came up and asked for the "password" and then I was able to enter the SSN into the field. When tabbing out of the field and the SSN I entered remained visible.

               

              I would use a custom format script to cover the SSN.

               

              If one disables Acrobat's or Reader's JavaScript option, one will not be prompted.

               

              The script will not work with Reader since the setAction method is not available to Reader.

               

              You can search for a question like "display last 4 characters".