Skip to content

Commit

Permalink
Merge pull request #644 from /issues/630-update-rest-client-documenta…
Browse files Browse the repository at this point in the history
…tion

Fix #630: Update documentation for PowerAuthRestClient
  • Loading branch information
romanstrobl authored Dec 21, 2021
2 parents 4a68c0b + 478c23b commit a8c0b1b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions docs/Configuring-REST-Client-for-Spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,45 @@ In order to connect to the correct PowerAuth Server, you need to add following c

```java
@Configuration
@ComponentScan(basePackages = {"com.wultra.security.powerauth"})
public class PowerAuthClientConfiguration {

@Value("${powerauth.rest.url}")
private String powerAuthRestUrl;

@Bean
public PowerAuthClient powerAuthRestClient() {
return new PowerAuthRestClient(powerAuthRestUrl);
try {
return new PowerAuthRestClient(powerAuthRestUrl);
} catch (PowerAuthClientException ex) {
logger.warn(ex.getMessage(), ex);
}
}

}
```

In case you need to configure the client, use:
The `PowerAuthClientException` is thrown only in case the provided base URL is invalid. The error can occur when the URL is constructed dynamically, for correctly specified static URLs you can skip the error handling.

In case you need to configure the client, use e.g.:
```java
@Bean
public PowerAuthRestClient powerAuthRestClient() {
PowerAuthRestClientConfiguration config = new PowerAuthRestClientConfiguration();
config.setPowerAuthClientToken(clientToken);
config.setPowerAuthClientSecret(clientSecret);
config.setAcceptInvalidSslCertificate(acceptInvalidSslCertificate);
config.setConnectTimeout(3000);
...
return new PowerAuthRestClient(powerAuthRestUrl, config);
try {
return new PowerAuthRestClient(powerAuthRestUrl, config);
} catch (PowerAuthClientException ex) {
logger.warn(ex.getMessage(), ex);
}
}
```

The `PowerAuthClientException` is thrown in case the provided URL is invalid or REST client configuration is invalid.

The following REST client options are available:

- `maxMemorySize` - configures maximum memory size per request, default 1 MB
Expand Down

0 comments on commit a8c0b1b

Please sign in to comment.