Skip to content

Commit

Permalink
Fix #1569: Missing timeout options for PowerAuth REST clients
Browse files Browse the repository at this point in the history
  • Loading branch information
banterCZ committed Jun 10, 2024
1 parent 12b25c4 commit e27dcb5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ public class PowerAuthFido2RestClient implements PowerAuthFido2Client {
* @param baseUrl BASE URL of REST endpoints.
*/
public PowerAuthFido2RestClient(String baseUrl) throws PowerAuthFido2Exception {
this(baseUrl, new PowerAuthRestClientConfiguration());
this(baseUrl, new PowerAuthFido2RestClientConfiguration());
}

/**
* PowerAuth REST client constructor.
*
* @param baseUrl Base URL of REST endpoints.
*/
public PowerAuthFido2RestClient(String baseUrl, PowerAuthRestClientConfiguration config) throws PowerAuthFido2Exception {
public PowerAuthFido2RestClient(String baseUrl, PowerAuthFido2RestClientConfiguration config) throws PowerAuthFido2Exception {
final DefaultRestClient.Builder builder = DefaultRestClient.builder().baseUrl(baseUrl)
.acceptInvalidCertificate(config.getAcceptInvalidSslCertificate())
.connectionTimeout(config.getConnectTimeout())
.responseTimeout(config.getResponseTimeout())
.maxIdleTime(config.getMaxIdleTime())
.maxLifeTime(config.getMaxLifeTime())
.maxInMemorySize(config.getMaxMemorySize());
if (config.isProxyEnabled()) {
final DefaultRestClient.ProxyBuilder proxyBuilder = builder.proxy().host(config.getProxyHost()).port(config.getProxyPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package com.wultra.security.powerauth.rest.client;

import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;

Expand All @@ -29,12 +31,29 @@
* @author Roman Strobl, roman.strobl@wultra.com
*
*/
@Getter @Setter
public class PowerAuthFido2RestClientConfiguration {

// Use 1 MB as default maximum memory size
private int maxMemorySize = 1024 * 1024;
// Use 5 seconds as default connect timeout
private Duration connectTimeout = Duration.ofMillis(5000);

/**
* The maximum duration allowed between each network-level read operations.
*/
private Duration responseTimeout;

/**
* The options to use for configuring ConnectionProvider max idle time. {@code Null} means no max idle time.
*/
private Duration maxIdleTime;

/**
* The options to use for configuring ConnectionProvider max life time. {@code Null} means no max life time.
*/
private Duration maxLifeTime;

private boolean proxyEnabled = false;
private String proxyHost;
private int proxyPort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public PowerAuthRestClient(String baseUrl, PowerAuthRestClientConfiguration conf
final DefaultRestClient.Builder builder = DefaultRestClient.builder().baseUrl(baseUrl)
.acceptInvalidCertificate(config.getAcceptInvalidSslCertificate())
.connectionTimeout(config.getConnectTimeout())
.responseTimeout(config.getResponseTimeout())
.maxIdleTime(config.getMaxIdleTime())
.maxLifeTime(config.getMaxLifeTime())
.maxInMemorySize(config.getMaxMemorySize());
if (config.isProxyEnabled()) {
final DefaultRestClient.ProxyBuilder proxyBuilder = builder.proxy().host(config.getProxyHost()).port(config.getProxyPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package com.wultra.security.powerauth.rest.client;

import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;

Expand All @@ -28,12 +30,29 @@
* @author Roman Strobl, roman.strobl@wultra.com
*
*/
@Getter @Setter
public class PowerAuthRestClientConfiguration {

// Use 1 MB as default maximum memory size
private int maxMemorySize = 1024 * 1024;
// Use 5 seconds as default connect timeout
private Duration connectTimeout = Duration.ofMillis(5000);

/**
* The maximum duration allowed between each network-level read operations.
*/
private Duration responseTimeout;

/**
* The options to use for configuring ConnectionProvider max idle time. {@code Null} means no max idle time.
*/
private Duration maxIdleTime;

/**
* The options to use for configuring ConnectionProvider max life time. {@code Null} means no max life time.
*/
private Duration maxLifeTime;

private boolean proxyEnabled = false;
private String proxyHost;
private int proxyPort;
Expand Down

0 comments on commit e27dcb5

Please sign in to comment.