8

I have written the following (runable) arara-program, which creates a password-locked pdf with adjustable prohibited access rights:

secure.yaml

!config
# GhostScript-ps2pdf password-security rule for arara
# version: 0.1b
# requires arara 3.0+
identifier: secure
name: Secure
command: <arara> @{program} -sOwnerPassword=@{ownerpw} -sUserPassword=@{userpw} -dEncryptionR=@{encryptionmethode} -dKeyLength=@{keylength} -dPermissions=@{permission} @{getBasename(file)}.pdf @{outputpath}@{getBasename(file)}@{nameaffix}.pdf
arguments:
- identifier: program
  flag: <arara> @{parameters.program}
  default: ps2pdf
- identifier: ownerpw
  flag: <arara> @{parameters.ownerpw}
  default: aaa
- identifier: userpw
  flag: <arara> @{parameters.userpw}
  default: bbb
- identifier: encryptionmethode
  flag: <arara> @{parameters.encryptionmethode}
  default: 3
- identifier: keylength
  flag: <arara> @{parameters.keylength}
  default: 128
- identifier: permission
  flag: <arara> @{parameters.permission}
  default: 0
- identifier: nameaffix
  flag: <arara> @{parameters.nameaffix}
  default: _sec
- identifier: outputpath
  flag: <arara> @{parameters.outputpath}
  default: C:\Secret\

I would like to change, the last both identifier s.

1. Problem "nameaffix"

Without the ouputpath-Option, there will be created a file jobname_sec.pdf per default in the same working folder.

I would like to have an option like %arara: secure: {nameaffix: false}, so there would be generated a "secured"file jobname.pdf, that means, the the "unsecured" file will be 'overwritten'.


Edit 1:

So, I think the first problem is not a problem, because:

% arara: pdflatex
% #arara: secure: { userpw: foo } 
% #arara: secure: { userpw: foo , nameaffix: -mostsecret } 
% #arara: secure: { userpw: foo , nameaffix: "" }

% in this order:
% <"nothing">  yields: jobname_sec.pdf, the default
% <nameaffix: -mostsecret> yields jobname-mostsecret.pdf
% <nameaffix: "">  yields jobname.pdf; but a different outputpath is needed!!!

\documentclass{article}       
\begin{document}
\section{My very secret Text}
......
\end{document}

2. Problem "outputpath"

How can I have this option as a pure optional parameter? That means: %arara: secure: {...} If there is no ... outputpath: C:/... declared, the same working folder will be used for writing the "secured" file.

I hope, I have explained my problems understandable ;) Thank you for reading and for your interest.


Edit 2:

For the 2nd problem, I think something like:

- identifier: outputpath
  flag: <arara> @{parameters.outputpath}
  default: <arara> @{ getDirname(file) }

is needed. But this could not be completely right, because:

In the case

% #arara: secure: { userpw: foo , outputpath: \SecrectDocuments\TodaysSecretDocuments } 

an 'outputpath' was used (with a correct file inside).

But:

In the case

% arara: secure: { userpw: foo } 

that means, without outputpath, a file named nulljobname_sec.pdf was created in the working folder. How can I erase this prefix 'null'?


PS: Improvement suggestions / ideas in general are welcome too!

PPS: I forgot, for testing arara-secure, use the following MWE for example:

% arara: pdflatex
% arara: secure: { userpw: foo , permission: 0 } 

\documentclass{article}       
\begin{document}
\section{My very secret Text}
......
\end{document}
  • Now you are here ;-) – Marco Daniel Jun 29 '14 at 7:21
  • On TeXwelt.de they said, I should go to the authors on problems with arara. BTW: You could use the program in the answer for the official rule-collection, if you want. – cis Jun 29 '14 at 9:01
  • 1
    I've rolled back an edit here: just a title really isn't likely to cover things here! – Joseph Wright Jul 4 '14 at 15:08
  • Ok. ________________________________________ – cis Jul 4 '14 at 15:28
2

I am sorry, I searched for things, which was not really needed.

It works as wished and I like it and I like arara - and I hope you too :()

Note that very tiny changing.

!config
# GhostScript-ps2pdf password-security rule for arara
# version: 0.2b
# requires arara 3.0+
identifier: secure
name: Secure
command: <arara> @{program} -sOwnerPassword=@{ownerpw} -sUserPassword=@{userpw} -dEncryptionR=@{encryptionmethode} -dKeyLength=@{keylength} -dPermissions=@{permission} "@{getBasename(file)}.pdf" "@{outputpath}@{outputfilename}@{nameaffix}.pdf"
arguments:
- identifier: program
  flag: <arara> @{parameters.program}
  default: ps2pdf
- identifier: ownerpw
  flag: <arara> @{parameters.ownerpw}
  default: aaa
- identifier: userpw
  flag: <arara> @{parameters.userpw}
  default: bbb
- identifier: encryptionmethode
  flag: <arara> @{parameters.encryptionmethode}
  default: 3
- identifier: keylength
  flag: <arara> @{parameters.keylength}
  default: 128
- identifier: permission
  flag: <arara> @{parameters.permission}
  default: 0
- identifier: outputpath
  flag: <arara> @{parameters.outputpath}
- identifier: outputfilename
  flag: <arara> @{parameters.outputfilename}
  default: <arara> @{getBasename(file)}
- identifier: nameaffix
  flag: <arara> @{parameters.nameaffix}
  default: _sec

(Please change your own defaults for userpw and ownerpw ;) )

Usage:

%#########################################
%##### %arara: secure ##########################
%#########################################
%# PARAMETERS:
%# See   http://svn.ghostscript.com/ghostscript/trunk/gs/doc/Ps2pdf.htm
%# for further informations.
%
%# program: ps2pdf      (by default)
%
%# ownerpw: <OwnerPasswort>
%#  aaa     (by default)
%
%# userpw: <UserPasswort>
%#  bbb (by default)
%
%# encryptionmethode: <number>
%# 2 or 3 (default)
%
%# keylength: <number>
%: 40, 48, ... , 128 (default)
%
%# permission: <number>
%# => The sum of following numbers ---> allows
%# 0 ----------> all rights prohibited  (default)
%# 4    --> printing
%# 8    --> modifying
%# 16   --> copying contents
%# 32   --> adding / changing text annotations
%# 256  --> filling in (existing) formulary fields 
%# 512  --> extracting text / graphics
%# 1024 --> assembling the document
%# 2048 --> adding / changing text annotations
%# -1 ----------> all rights permitted
%
%# nameaffix: <text>
%# _sec (by default)
%#########################################


% arara: pdflatex
% arara: secure: { userpw: foo , permission: 0 } 

\documentclass{article}
\usepackage{xcolor}
\pagecolor{yellow!50}

\begin{document}
\section{My very secret Text}
......
\end{document}

Some examples.

a1) In the working folder a file with special userpasswort shall be generated, the ownerpasswort shall get it's default-value.

% arara: pdflatex
% arara: secure: { userpw: foo } 

\documentclass{article}
\begin{document}
\section{My very secret Text}
......
\end{document}

=> jobname_sec.pdf

a2) ... in addition there should be generated a special name-prefix.

% arara: pdflatex
% arara: secure: { userpw: foo , nameaffix: -most_secret} 

\documentclass{article}
\begin{document}
\section{My very secret Text}
......
\end{document}

=> jobname-most_secret.pdf

b) A file with same name (jobname.pdf) shall be generated in a special path (this is compulsive, becausse the original has to be overwritten, else).

% arara: pdflatex
% arara: secure: { userpw: foo , outputpath: 'C:\SecretDocuments\TodaysSecretDocuments\' , nameaffix: ''}  

\documentclass{article}
\begin{document}
\section{My very secret Text}
......
\end{document}

=> C:\SecretDocuments\TodaysSecretDocuments\jobname.pdf

nameaffix: '' erases the parameter-value.

c) Feel free, to test some other parameters; ask, if there are problemes with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.