Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.luisgoncalves:xades4j:1.7.0'
}
dependencies {
implementation("com.github.luisgoncalves:xades4j:1.7.0")
}
<dependency>
<groupId>com.github.luisgoncalves</groupId>
<artifactId>xades4j</artifactId>
<version>1.7.0</version>
</dependency>
libraryDependencies += "com.github.luisgoncalves" % "xades4j" % "1.7.0"
:dependencies [[com.github.luisgoncalves/xades4j "1.7.0"]]
XAdES4j is a high-level, configurable and extensible Java implementation of XML Advanced Electronic Signatures (XAdES 1.3.2 and 1.4.1). It enables producing, verifying and extending signatures in the main XAdES forms: XAdES-BES, XAdES-EPES, XAdES-T and XAdES-C. Also, extended forms are supported through the enrichment of an existing signature.
The API provides a high level of abstraction, handling all the structural details of XAdES. The library relies on Apache XML Security for the core XML-DSIG processing and uses Guice to assemble the different configurable components.
The library is available on Maven.
<dependency>
<groupId>com.googlecode.xades4j</groupId>
<artifactId>xades4j</artifactId>
<version>{version}</version>
</dependency>
Document doc = /* parse XML document */;
// Define the signing key/certificate
KeyingDataProvider kp = FileSystemKeyStoreKeyingDataProvider
.builder(/* key store location and type */)
.build();
// Define the signed object
DataObjectDesc obj = new DataObjectReference("")
.withTransform(new EnvelopedSignatureTransform())
.withDataObjectFormat(new DataObjectFormatProperty("text/xml"));
// Create the signature
XadesSigner signer = new XadesBesSigningProfile(kp).newSigner();
signer.sign(new SignedDataObjects(obj), doc.getDocumentElement());
xades4j
tag on Stack Overflow.If XAdES4j has been useful to you, consider supporting it!
<a href="https://www.buymeacoffee.com/luisgoncalves" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" width="170px"></a>