[poppler] [patch] Add additional user access permissions

Albert Astals Cid aacid at kde.org
Mon Jul 4 15:06:39 PDT 2005


It seems these properties are newer in the spec and maybe that's the reason 
they are not in the code? I don't see why we should not support them, other 
thing is how applications enforce them because i don't see how to define 
"hires" and "lores" printing in kpdf but having them is good imho.

Albert

A Dilluns 04 Juliol 2005 23:46, Brad Hards va escriure:
> Section 3.5.2 of the PDF spec is about the standard encryption handler -
> within that, Table 3.20 identifies a number of properties that we aren't
> handling, or aren't handling exacty. Just as an indication, here is a
> simple example about printing - see below.
>
> Any objections to adding the rest of the properties to the API?
>
> Any suggestions for what to do if we get an unknown security handler
> version?
>
> Brad
>
> Index: PDFDoc.h
> ===================================================================
> RCS file: /cvs/poppler/poppler/poppler/PDFDoc.h,v
> retrieving revision 1.1.1.1
> diff -u -4 -p -r1.1.1.1 PDFDoc.h
> --- PDFDoc.h    3 Mar 2005 19:46:01 -0000       1.1.1.1
> +++ PDFDoc.h    4 Jul 2005 21:42:06 -0000
> @@ -131,8 +131,10 @@ public:
>
>    // Check various permissions.
>    GBool okToPrint(GBool ignoreOwnerPW = gFalse)
>      { return xref->okToPrint(ignoreOwnerPW); }
> +  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse)
> +    { return xref->okToPrintHighRes(ignoreOwnerPW); }
>    GBool okToChange(GBool ignoreOwnerPW = gFalse)
>      { return xref->okToChange(ignoreOwnerPW); }
>    GBool okToCopy(GBool ignoreOwnerPW = gFalse)
>      { return xref->okToCopy(ignoreOwnerPW); }
> Index: XRef.h
> ===================================================================
> RCS file: /cvs/poppler/poppler/poppler/XRef.h,v
> retrieving revision 1.1.1.1
> diff -u -4 -p -r1.1.1.1 XRef.h
> --- XRef.h      3 Mar 2005 19:46:01 -0000       1.1.1.1
> +++ XRef.h      4 Jul 2005 21:42:06 -0000
> @@ -60,8 +60,9 @@ public:
>  #endif
>
>    // Check various permissions.
>    GBool okToPrint(GBool ignoreOwnerPW = gFalse);
> +  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse);
>    GBool okToChange(GBool ignoreOwnerPW = gFalse);
>    GBool okToCopy(GBool ignoreOwnerPW = gFalse);
>    GBool okToAddNotes(GBool ignoreOwnerPW = gFalse);
>
> Index: XRef.cc
> ===================================================================
> RCS file: /cvs/poppler/poppler/poppler/XRef.cc,v
> retrieving revision 1.2
> diff -u -4 -p -r1.2 XRef.cc
> --- XRef.cc     16 Mar 2005 15:51:36 -0000      1.2
> +++ XRef.cc     4 Jul 2005 21:42:06 -0000
> @@ -36,14 +36,16 @@
>
>  #ifndef NO_DECRYPTION
>  //------------------------------------------------------------------------
>  // Permission bits
> +// Note that the PDF spec uses 1 base (eg bit 3 is 1<<2)
>  //------------------------------------------------------------------------
>
>  #define permPrint    (1<<2)
>  #define permChange   (1<<3)
>  #define permCopy     (1<<4)
>  #define permNotes    (1<<5)
> +#define permHighResPrint (1<<11)
>  #define defPermFlags 0xfffc
>  #endif
>
>  //------------------------------------------------------------------------
> @@ -898,8 +900,26 @@ GBool XRef::okToPrint(GBool ignoreOwnerP
>    return gTrue;
>  #endif
>  }
>
> +// we can print at high res if we are only doing security handler revision
> +// 2 (and we are allowed to print at all), or with security handler rev
> +// 3 and we are allowed to print, and bit 12 is set.
> +GBool XRef::okToPrintHighRes(GBool ignoreOwnerPW) {
> +#ifndef NO_DECRYPTION
> +  if (2 == encRevision) {
> +    return (okToPrint(ignoreOwnerPW));
> +  } else if (encRevision >= 3) {
> +    return (okToPrint(ignoreOwnerPW) && (permFlags & permHighResPrint));
> +  } else {
> +    // something weird - unknown security handler version
> +    return gFalse;
> +  }
> +#else
> +  return gTrue;
> +#endif
> +}
> +
>  GBool XRef::okToChange(GBool ignoreOwnerPW) {
>  #ifndef NO_DECRYPTION
>    return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permChange);
>  #else

		
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es


More information about the poppler mailing list