Java Implementation of the IETF draft for HTTP Message Signing. It provides bridges with the following libraries:
The most recent release is http-messages-signing 1.0.0, released 2018-02-20 and available on Maven central. Javadoc is available.
To add a dependency on http-messages-signing using Maven, use the following:
<dependency>
<groupId>tech.barbero.http-messages-signing</groupId>
<artifactId>http-messages-signing-core</artifactId>
<version>1.0.0</version>
</dependency>
To add a dependency using Gradle:
dependencies {
compile 'tech.barbero.http-messages-signing:http-messages-signing:1.0.0'
}
And one of the bridge if required.
<dependency>
<groupId>tech.barbero.http-messages-signing</groupId>
<artifactId>http-messages-signing-ahc4</artifactId>
<version>1.0.0</version>
</dependency>
dependencies {
compile 'tech.barbero.http-messages-signing:http-messages-signing-ahc4:1.0.0'
}
<dependency>
<groupId>tech.barbero.http-messages-signing</groupId>
<artifactId>http-messages-signing-okhttp3</artifactId>
<version>1.0.0</version>
</dependency>
dependencies {
compile 'tech.barbero.http-messages-signing:http-messages-signing-okhttp3:1.0.0'
}
Snapshots of http-messages-signing built from the master branch are available on Sonatype Snapshot Repository. Javadoc is available.
HttpMessageSigner signer = HttpMessageSigner.builder()
.algorithm(Algorithm.RSA_SHA256)
.keyMap(keyMap)
.addHeaderToSign(HttpMessageSigner.REQUEST_TARGET)
.addHeaderToSign("Date")
.addHeaderToSign("Content-Length")
.addHeaderToSign("Digest")
.keyId("myKeyId")
.build();
HttpClientBuilder builder = HttpClientBuilder.create();
builder.addLast(new RequestSignature(signer));
try (CloseableHttpClient client = builder.build()) {
HttpGet httpget = new HttpGet(uri);
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
...
}
}
Copyright (c) 2017-2018 Eclipse Foundation and others.
Eclipse and the Eclipse logo are registered trademarks of The Eclipse Foundation.
Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/
Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country’s laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.