Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 934d029

Browse files
Merge branch 'authentication-standardization' of https://github.com/Venafi/vcert-java.git into authentication-standardization
2 parents 9be2ed8 + 73ec605 commit 934d029

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,43 @@ shows snippets for VCert-Java v0.6.2.
4444

4545
## Usage
4646

47+
4748
Instantiate a client for Trust Protection Platform using token authentication with an existing
4849
access token:
4950

5051
```java
52+
//Create an Authentication object with the access token
5153
final Authentication auth = Authentication.builder()
5254
.accessToken("9PQwQeiTLhcB8/W3/z2Lbw==")
5355
.build();
5456

57+
//Create a Config object setting the Authentication object
5558
final Config config = Config.builder()
5659
.connectorType(ConnectorType.TPP_TOKEN)
5760
.baseUrl("https://tpp.venafi.example")
5861
.credentials(auth)
5962
.build();
6063

64+
//Create the client with the Config object. The client will be authenticated
6165
final VCertTknClient client = new VCertTknClient(config);
6266
```
6367

6468
Or instantiate a client for Venafi Cloud:
6569

6670
```java
71+
//Create an Authentication object with the API Key
6772
final Authentication auth = Authentication.builder()
6873
.apiKey("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
6974
.build();
7075

76+
//Create a Config object setting the Authentication object
7177
final Config config = Config.builder()
7278
.connectorType(ConnectorType.CLOUD)
79+
.credentials(auth)
7380
.build();
7481

82+
//Create the client with the Config object. The client will be authenticated
7583
final VCertClient client = new VCertClient(config);
76-
client.authenticate(auth);
7784
```
7885

7986
Then use your client to request certificates:
@@ -187,21 +194,54 @@ _without_ an existing token by providing a username/password. Such a token is g
187194
short-term or temporary use and as such should be revoked upon completion of your tasks:
188195

189196
```java
197+
//Create an Authentication object with the user and password
190198
final Authentication auth = Authentication.builder()
191199
.user("local:apiuser")
192200
.password("password")
193201
.build();
194202

203+
//Create a Config object
195204
final Config config = Config.builder()
196205
.connectorType(ConnectorType.TPP_TOKEN)
197206
.baseUrl("https://tpp.venafi.example")
198207
.build();
199-
208+
209+
//Create the client with the Config object. The client is not authenticated yet
200210
final VCertTknClient client = new VCertTknClient(config);
211+
212+
//Get the access token. It will cause the client's authentication
201213
client.getAccessToken(auth);
202214

203215
///// REQUEST, RENEW, AND/OR REVOKE CERTIFICATES...
204216

217+
//Revoke the access token
218+
client.revokeAccessToken();
219+
```
220+
221+
Or you can try the authentication in constructor way:
222+
223+
```java
224+
//Create an Authentication object with the user and password
225+
final Authentication auth = Authentication.builder()
226+
.user("local:apiuser")
227+
.password("password")
228+
.build();
229+
230+
//Create a Config object setting the Authentication object
231+
final Config config = Config.builder()
232+
.connectorType(ConnectorType.TPP_TOKEN)
233+
.baseUrl("https://tpp.venafi.example")
234+
.credentials(auth)
235+
.build();
236+
237+
//Create the client with the Config object. The client will be authenticated
238+
//Internally the access token will be gotten and accessible
239+
//via the getTokenInfo() method.
240+
final VCertTknClient client = new VCertTknClient(config);
241+
242+
///// REQUEST, RENEW, AND/OR REVOKE CERTIFICATES...
243+
244+
//Revoke the access token
205245
client.revokeAccessToken();
206246
```
207247

0 commit comments

Comments
 (0)