mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-11 00:21:18 +00:00
[java][jersey2] Add support for (expires) and (created) fields in HTTP signature (#6632)
* Add support for (expires) and (created) fields in HTTP signature * Add support for (expires) and (created) fields in HTTP signature
This commit is contained in:
@@ -60,6 +60,9 @@ public class HttpSignatureAuth implements Authentication {
|
||||
// The digest algorithm which is used to calculate a cryptographic digest of the HTTP request body.
|
||||
private String digestAlgorithm;
|
||||
|
||||
// The maximum validity duration of the HTTP signature.
|
||||
private Long maxSignatureValidity;
|
||||
|
||||
/**
|
||||
* Construct a new HTTP signature auth configuration object.
|
||||
*
|
||||
@@ -68,19 +71,23 @@ public class HttpSignatureAuth implements Authentication {
|
||||
* @param algorithm The cryptographic algorithm.
|
||||
* @param digestAlgorithm The digest algorithm.
|
||||
* @param headers The list of HTTP headers that should be included in the HTTP signature.
|
||||
* @param maxSignatureValidity The maximum validity duration of the HTTP signature.
|
||||
* Used to set the '(expires)' field in the HTTP signature.
|
||||
*/
|
||||
public HttpSignatureAuth(String keyId,
|
||||
SigningAlgorithm signingAlgorithm,
|
||||
Algorithm algorithm,
|
||||
String digestAlgorithm,
|
||||
AlgorithmParameterSpec parameterSpec,
|
||||
List<String> headers) {
|
||||
List<String> headers,
|
||||
Long maxSignatureValidity) {
|
||||
this.keyId = keyId;
|
||||
this.signingAlgorithm = signingAlgorithm;
|
||||
this.algorithm = algorithm;
|
||||
this.parameterSpec = parameterSpec;
|
||||
this.digestAlgorithm = digestAlgorithm;
|
||||
this.headers = headers;
|
||||
this.maxSignatureValidity = maxSignatureValidity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,6 +197,14 @@ public class HttpSignatureAuth implements Authentication {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum validity duration of the HTTP signature.
|
||||
* @return The maximum validity duration of the HTTP signature.
|
||||
*/
|
||||
public Long getMaxSignatureValidity() {
|
||||
return maxSignatureValidity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signer instance used to sign HTTP messages.
|
||||
*
|
||||
@@ -220,7 +235,7 @@ public class HttpSignatureAuth implements Authentication {
|
||||
if (key == null) {
|
||||
throw new ApiException("Private key (java.security.Key) cannot be null");
|
||||
}
|
||||
signer = new Signer(key, new Signature(keyId, signingAlgorithm, algorithm, parameterSpec, null, headers));
|
||||
signer = new Signer(key, new Signature(keyId, signingAlgorithm, algorithm, parameterSpec, null, headers, maxSignatureValidity));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user