pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tolen Miller <tolenmil...@gmail.com>
Subject Re: Cannot load pre existing PDF to access fields
Date Thu, 27 Aug 2015 17:18:13 GMT
No XPages development, unfortunately. I had the jar in the Agent
originally, but was met with some instability issues (jar kept
disappearing). After reading around a bit, saw that it could be placed in
the nsf so I stuck it there.  Then I spent a few hours on the phone with
IBM trying to figure out another issue I was having with this
implementation and they suggested I move it to the lib/ext folder...

On Thu, Aug 27, 2015 at 10:07 AM <howardg@tlcc.com> wrote:

> Are you using your Notes/Domino app with XPages? If so, if you import the
> jar file into the nsf instead of copying to the jvm\lib folder you won't
> have this issue.
>
>
> Howard
> Howard Greenberg, CPA
> IBM Certified Application Developer/Instructor - IBM Notes and Domino
> The Learning Continuum Company, Ltd.
> 888-241-8522 or 561-953-0096
> http://www.tlcc.com
> mailto:howardg@tlcc.com
>
>
>
> From:   Tolen Miller <tolenmiller@msn.com>
> To:     users@pdfbox.apache.org
> Date:   08/27/2015 11:55 AM
> Subject:        Re: Cannot load pre existing PDF to access fields
>
>
>
> I was able to reach out to IBM for some help here. To update for
> posterity:
> If anyone else runs across this issue while using Lotus/Domino
> environment,
> locate the java.policy file in both the Domino and Notes file paths by
> drilling down to "jvm\lib\security" folders. Edit both of the java.policy
> files to add the line:
> *permission java.lang.reflect.ReflectPermission
> "suppressAccessChecks","";*
> to the default permissions granted to all domains section.
>
> On Wed, Aug 26, 2015 at 4:35 PM Tolen Miller <tolenmiller@msn.com> wrote:
>
> > forgot stack trace...
> >
> > *Exception in thread "AgentThread: JavaAgent"
> > java.security.AccessControlException: Access denied
> > (java.lang.RuntimePermission createSecurityManager)*
> > * at java.security.AccessController.throwACE(AccessController.java:100)*
> > * at
> >
> java.security.AccessController.checkPermission(AccessController.java:174)*
> > * at
> java.lang.SecurityManager.checkPermission(SecurityManager.java:544)*
> > * at
> >
>
> COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449)*
> > * at
> >
>
> COM.ibm.JEmpower.applet.AppletSecurity.checkRuntimePermission(AppletSecurity.java:1311)*
> > * at
> >
>
> COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1611)*
> > * at
> >
>
> COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464)*
> > * at java.lang.SecurityManager.<init>(SecurityManager.java:294)*
> > * at JavaAgent$MySecurityManager.<init>(JavaAgent.java:159)*
> > * at JavaAgent$MySecurityManager.<init>(JavaAgent.java:159)*
> > * at JavaAgent.NotesMain(JavaAgent.java:36)*
> > * at lotus.domino.AgentBase.runNotes(Unknown Source)*
> > * at lotus.domino.NotesThread.run(Unknown Source)*
> >
> > On Wed, Aug 26, 2015 at 4:35 PM, Tolen Miller <tolenmiller@msn.com>
> wrote:
> >
> >> Well, I'm not sure that will work either:
> >>
> >> On Wed, Aug 26, 2015 at 4:17 PM, Roberto Nibali <rnibali@gmail.com>
> >> wrote:
> >>
> >>> Hi
> >>>
> >>> You use Notes/Domino, which is quiet a challenge when it comes to
> >>> application security. The Java API of Notes/Domino contains two
> different
> >>> SecurityManagers - one for agents and one for servlets. The
> >>> SecurityManager
> >>> for agents is COM.ibm.JEmpower.applet.AppletSecurity and the
> >>> SecurityManager for servlers is lotus.notes.AgentSecurityManager. Both
> >>> inherit directly from java.lang.SecurityManager. Make sure you have
> the
> >>> appropriate settings and talk to the administrator of this node. Last
> but
> >>> not least, I suppose you have a support contract with IBM.
> >>>
> >>> If you can fiddle around with the JVM you'd like to invoke, add your
> own
> >>> grant policy file: -Djava.security.policy=applet.policy
> >>>
> >>> However, I doubt Lotus will let you do this, and most probably you'll
> >>> hit a
> >>> classloader issue. With some luck you could hijack the SecurityManager
> as
> >>> follows:
> >>>
> >>> private class MySecurityManager extends SecurityManager {
> >>>     @Override
> >>>     public void checkPermission(Permission perm) {
> >>>         return;
> >>>     }}
> >>>
> >>>
> >>> At the start of your Applet, you do the following:
> >>>
> >>> SecurityManager sm = new
> >>> MySecurityManager();System.setSecurityManager(sm);
> >>>
> >>>
> >>> Good luck
> >>>
> >>> Roberto
> >>>
> >>> On Thu, Aug 27, 2015 at 12:08 AM, Tolen Miller <tolenmiller@msn.com>
> >>> wrote:
> >>>
> >>> > Hello again,
> >>> >
> >>> > I was able to get the PrintFields example working, so thanks for
> >>> that.  I
> >>> > then applied what I learned to my situation and everything seemed to
> be
> >>> > going well, but now I have run into a roadblock:
> >>> > *java.lang.RuntimeException: java.security.AccessControlException:
> >>> Access
> >>> > denied (java.lang.reflect.ReflectPermission suppressAccessChecks)*
> >>> > * at
> >>> >
> >>>
> org.apache.pdfbox.pdmodel.font.PDType1CFont.load(PDType1CFont.java:411)*
> >>> > * at
> >>> >
> >>>
> org.apache.pdfbox.pdmodel.font.PDType1CFont.<init>(PDType1CFont.java:102)*
> >>> > * at
> >>> >
> >>>
> org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:162)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:92)*
> >>> > * at
> >>> org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:213)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdateResources(PDAppearance.java:820)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:316)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131)*
> >>> > * at JavaAgent.NotesMain(JavaAgent.java:69)*
> >>> > * at lotus.domino.AgentBase.runNotes(Unknown Source)*
> >>> > * at lotus.domino.NotesThread.run(Unknown Source)*
> >>> > *Caused by: java.security.AccessControlException: Access denied
> >>> > (java.lang.reflect.ReflectPermission suppressAccessChecks)*
> >>> > * at
> >>> java.security.AccessController.throwACE(AccessController.java:100)*
> >>> > * at
> >>> >
> >>>
> java.security.AccessController.checkPermission(AccessController.java:174)*
> >>> > * at
> >>> java.lang.SecurityManager.checkPermission(SecurityManager.java:544)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1617)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464)*
> >>> > * at
> >>> >
> >>> >
> >>>
>
> java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:118)*
> >>> > * at
> >>> >
> >>>
> org.apache.pdfbox.pdmodel.font.PDType1CFont.load(PDType1CFont.java:406)*
> >>> > * ... 10 more*
> >>> >
> >>> > This occurs just as I am calling PDField.setValue() and assigning a
> >>> value.
> >>> > I checked the java.policy file and the location where the PDFBox JAR
> is
> >>> > stored has "AllPermission". I also ensured that my PDF has no
> security.
> >>> > Any thoughts on what else to look for?
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > On Wed, Aug 26, 2015 at 2:15 AM, Roberto Nibali <rnibali@gmail.com>
> >>> wrote:
> >>> >
> >>> > > Hi
> >>> > >
> >>> > > On Wed, Aug 26, 2015 at 9:27 AM, Maruan Sahyoun <
> >>> sahyoun@fileaffairs.de>
> >>> > > wrote:
> >>> > >
> >>> > > > Hi,
> >>> > > >
> >>> > > > > Am 26.08.2015 um 06:00 schrieb Tolen Miller
> <tolenmiller@msn.com
> >>> >:
> >>> > > > >
> >>> > > > > I uploaded my PDF again, if someone wants to see if
they can
> get
> >>> all
> >>> > of
> >>> > > > the
> >>> > > > > fields to return: http://1drv.ms/1PRKZsI
> >>> > > > >
> >>> > > > > After looking at the sample provided by Maruan, I noticed
that
> I
> >>> was
> >>> > > not
> >>> > > > > passing in a File object, when calling the PDDocument.load()
> >>> method.
> >>> > > > Doing
> >>> > > > > so, I now get the same result from Maruan's code (in
eclipse).
> >>> > > > >
> >>> > > > > Now I am unsure how to get *all* of the fields from
the
> >>> PDAcroForm.
> >>> > I
> >>> > > am
> >>> > > > > trying to get a collection of the fields, so I can loop
> through
> >>> them.
> >>> > > > When
> >>> > > > > I add this code:
> >>> > > > >
> >>> > > > > List<PDField> pdfFields = form.getFields();
> >>> > > > > for (PDField field : pdfFields) {
> >>> > > > > System.out.println("PDF Field Full Name: ".concat(field
> >>> > > > > .getFullyQualifiedName()));
> >>> > > > > }
> >>> > > > >
> >>> > > >
> >>> > > > as there is only one 'root' field you have to get it's kids
and
> >>> process
> >>> > > > the field tree down. Take a look at
> >>> > > > org.apache.pdfbox.examples.fdf.PrintFields of how to do that.
> >>> > > >
> >>> > > >
> >>> > > Having spent the last two months intensively with form fields,
> here
> >>> is my
> >>> > > current code to dump the fields:
> >>> > >
> >>> > > private void executeDumpFields(String srcDocName) throws
> IOException
> >>> {
> >>> > >     PDDocument srcDoc = null;
> >>> > >     try {
> >>> > >         srcDoc = PDDocument.load(new File(srcDocName));
> >>> > >
> >>> > >
> >>> >
> >>>
>
> srcDoc.getDocumentCatalog().getAcroForm().getFields().forEach(this::dumpField);
> >>> > >         srcDoc.close();
> >>> > >     } catch (Exception e) {
> >>> > >         logerr(e.getMessage());
> >>> > >     } finally {
> >>> > >         if (srcDoc != null) {
> >>> > >             srcDoc.close();
> >>> > >         }
> >>> > >     }
> >>> > > }
> >>> > >
> >>> > > private void dumpField(PDField srcField) {
> >>> > >     if (srcField instanceof PDNonTerminalField) {
> >>> > >         ((PDNonTerminalField)
> >>> > > srcField).getChildren().forEach(this::dumpField);
> >>> > >     } else if (!(srcField instanceof PDSignatureField)) {
> >>> > >         System.out.printf("fqName=%s type=%s%n",
> >>> > > srcField.getFullyQualifiedName(),
> >>> > > srcField.getClass().getSimpleName());
> >>> > >     }
> >>> > > }
> >>> > >
> >>> > > Maybe you can use some of it. Just call the executeDumpFields(...)
> >>> with
> >>> > the
> >>> > > appropriate PDF name as a string and go from there. Not
> >>> understanding the
> >>> > > PDF standard and how the dictionary trees are built up inside
PDF,
> I
> >>> had
> >>> > a
> >>> > > hard time initially understanding why I need to kind of
> recursively
> >>> to
> >>> > > through the PDField entries.
> >>> > >
> >>> > > Cheers
> >>> > > Roberto
> >>> > >
> >>> >
> >>>
> >>
> >>
> >
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message