-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// (c) Copyright 2003-2023 Methics Oy. All rights reserved. | ||
// | ||
package fi.methics.laverca.rest; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStream; | ||
|
||
import fi.methics.laverca.rest.util.SignatureProfile; | ||
|
||
/** | ||
* Example for PDF signing | ||
* @see PdfSigner | ||
*/ | ||
public class SignPDF { | ||
|
||
private static final String REST_URL = "http://localhost:9060/rest/service"; | ||
private static final String AP_NAME = "TestAP"; | ||
private static final String PASSWORD = "9TMzfH7EKXETOB8FT5gz"; | ||
private static final String MSISDN = "35847001001"; | ||
|
||
private static final SignatureProfile SIG_PROFILE = SignatureProfile.of("http://alauda.mobi/nonRepudiation"); | ||
|
||
private static final String DOC_PATH = "./example.pdf"; | ||
private static final String SIGNED_DOC_PATH = "./example.signed.pdf"; | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
MssClient client = new MssClient.Builder().withRestUrl(REST_URL) | ||
.withPassword(AP_NAME, PASSWORD) | ||
.build(); | ||
|
||
PdfSigner signer = new PdfSigner(client); | ||
|
||
File doc = new File(DOC_PATH); | ||
InputStream is = new FileInputStream(doc); | ||
ByteArrayOutputStream os = signer.signDocument(MSISDN, | ||
"Please sign example.pdf", | ||
is, | ||
SIG_PROFILE); | ||
try (FileOutputStream fos = new FileOutputStream(new File(SIGNED_DOC_PATH))) { | ||
os.writeTo(fos); | ||
} | ||
|
||
System.out.println("Saved signed document to " + new File(SIGNED_DOC_PATH).getAbsolutePath()); | ||
} | ||
|
||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.