This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Security and the fly likes Signing PDF with SecurSign Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Signing PDF with SecurSign" Watch "Signing PDF with SecurSign" New topic

Signing PDF with SecurSign

vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hi guys, I need to sign my pDF files using SecurSign, I have never did this before, would really appretiate any help given on this.


I'm not available, my BF's name is WORK.
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
hello guys, I use the following code to execute SecurSign batch file :
public boolean secursignEncryption(String filePath, String accessID) {
boolean status = false;
String newFile = filePath.replaceAll("_c", "_e");


String cmd = "e:\\Appligent\\SecurSign\\secursign -p -encrypt -ownerpass estatement -userpass 654321 -nomodify -nocopy -nonotes -noaccess -noassembly -nofill -o ";
cmd = cmd + newFile + " " + filePath;
cmd = cmd.replaceAll("-userpass 654321", "-userpass " +


status = runExternal(cmd);

return status;

public boolean runExternal(String path) {
boolean execute = false;
try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(path);
InputStream in = p.getInputStream();
OutputStream out = p.getOutputStream();
InputStream err = p.getErrorStream();
execute = true;
} catch (IOException e) {
return execute;

and I got this exception instead:

AFAIK the error=2 means that the file is not found, but I have specified the exact file path, can anyone tell me what is wrong actually?
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
ok, I solved the error. The correct code should be:

I didn't add the .bat extension

Although there are no errors now, SecurSign is not creating a new file for me in the specified new file path. Can anyone tell me how I should write the command so that SecurSign will take an old file, encrypt it with password, and save the encrypted file to a new location, which the encrypted file is not previously created before?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
Does the command work correctly on the command-line? Runtime.exec has some issues one needs to be aware of.
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
hmmm... solved the problem finally!

2 interesting things:
1. Secursign only works with PDF files. Previously I was testing using txt files
2. Even if it is a PDF file I'm using, if the path is too long, the command wouldn't work either. The command for SecurSign to run itself is already very long. I suggest that you put it under c: or e: what ever, then at most only make a folder and cram all the PDFs in there.

Anyway thanks Ulf
I agree. Here's the link:
subject: Signing PDF with SecurSign
It's not a secret anymore!