aspose file tools*
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
JavaRanch » Java Forums » Engineering » Security
Bookmark "Signing PDF with SecurSign" Watch "Signing PDF with SecurSign" New topic
Author

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.

Thanks!!


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");

System.out.println(newFile);

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 " +
accessID.trim());

System.out.println(cmd);

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) {
e.printStackTrace();
}
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
Marshal

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


Ping & DNS - my free Android networking tools app
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Signing PDF with SecurSign