Created
July 31, 2019 07:39
-
-
Save usman-aziz/e5ea6bfa3e2a52c740cb77f442d39ae3 to your computer and use it in GitHub Desktop.
GroupDocs.Signature for Java 19.7
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
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java | |
public static class DocumentSignature | |
{ | |
public String getVersion(){ return Version; } | |
public void setVersion(String value){ Version = value; } | |
// specify SkipSerialization attribute to skip this field on serialization | |
@SkipSerializationAttribute() | |
public String Version; | |
public boolean isProcessed(){ return IsProcessed; } | |
public void setProcessed(boolean value){ IsProcessed = value; } | |
// specify SkipSerialization attribute to skip this field on serialization | |
@SkipSerializationAttribute() | |
public boolean IsProcessed; | |
public String getID(){ return ID; } | |
public void setID(String value){ ID = value; } | |
@FormatAttribute(propertyName = "SignatureID") | |
public String ID; | |
public String getAuthor(){ return Author; } | |
public void setAuthor(String value){ Author = value; } | |
@FormatAttribute (propertyName = "Author") | |
public String Author; | |
public java.util.Date getSigned() { return Signed; } | |
public void setSigned(java.util.Date value) { Signed = value; } | |
@FormatAttribute (propertyName = "SignatureDate",propertyFormat = "yyyy-MM-dd") | |
public java.util.Date Signed = new java.util.Date(); | |
public java.math.BigDecimal getDataFactor() { return DataFactor; } | |
public void setDataFactor(java.math.BigDecimal value) { DataFactor = value; } | |
@FormatAttribute (propertyName = "Factor", propertyFormat = "N2") | |
public java.math.BigDecimal DataFactor = new java.math.BigDecimal(0.01); | |
} |
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
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java | |
// setup key and pasphrase | |
String key = "1234567890"; | |
String salt = "1234567890"; | |
// create data encryption | |
IDataEncryption encryption = new SymmetricEncryption(SymmetricAlgorithmType.Rijndael, key, salt); | |
// setup Signature configuration | |
SignatureConfig signConfig = new SignatureConfig(); | |
signConfig.setStoragePath(BaseTestData.getTestDataPath() +"\\Storage"); | |
signConfig.setOutputPath(BaseTestData.getTestDataPath() +"\\Output"); | |
// instantiate the signature handler | |
SignatureHandler handler = new SignatureHandler(signConfig); | |
// setup search options | |
WordsSearchMetadataOptions searchOptions = new WordsSearchMetadataOptions(); | |
// search document | |
SearchResult result = handler.search("SignedMedataDataEncrypted.docx", searchOptions); | |
// output signatures | |
java.util.List<WordsMetadataSignature> signatures = result.toList(WordsMetadataSignature.class); | |
Iterator tmp0 = ( signatures).iterator(); | |
while (tmp0.hasNext()){ | |
WordsMetadataSignature signature = (WordsMetadataSignature)tmp0.next(); | |
if (signature != null && signature.getName().equals("DocumentSignature")){ | |
DocumentSignature docSignature = signature.<DocumentSignature>getData(DocumentSignature.class, encryption); | |
if (docSignature != null){ | |
System.out.print("Found DocumentSignature signature: #"+docSignature.getID()+". Author "+docSignature.getAuthor()+" from "+docSignature.getDataFactor()+". Factor: " +docSignature.getDataFactor() ); | |
} | |
} | |
} |
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
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java | |
// setup key and passphrase | |
String key = "1234567890"; | |
String salt = "1234567890"; | |
// create data encryption | |
IDataEncryption encryption = new SymmetricEncryption(SymmetricAlgorithmType.Rijndael, key, salt); | |
// setup Signature configuration | |
SignatureConfig signConfig = new SignatureConfig(); | |
signConfig.setStoragePath(BaseTestData.getTestDataPath() +"\\Storage"); | |
signConfig.setOutputPath(BaseTestData.getTestDataPath() +"\\Output"); | |
// instantiate the signature handler | |
SignatureHandler<String> handler = new SignatureHandler<String>(signConfig); | |
// setup signature options | |
WordsMetadataSignOptions signOptions = new WordsMetadataSignOptions(); | |
// create custom object | |
DocumentSignature signature = new DocumentSignature(); | |
signature.setID(Guid.newGuid().toString()); | |
signature.setAuthor(System.getenv("USERNAME")); | |
signature.setSigned(new java.util.Date()); | |
signature.setDataFactor(new java.math.BigDecimal("11.22")); | |
// add custom object to sigature collection | |
WordsMetadataSignature mdDocument = signOptions.addSignature("DocumentSignature", signature); | |
// set encryption | |
mdDocument.setDataEncryption(encryption); | |
SaveOptions so = new SaveOptions(); | |
so.setOutputType(OutputType.String); | |
so.setOutputFileName("SignedMedataDataEncrypted.docx"); | |
// sign document | |
String signedPath = handler.<String>sign("test.docx", signOptions, so); | |
System.out.print("Signed file path is: " + signedPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment