@@ -44,36 +44,43 @@ shows snippets for VCert-Java v0.6.2.
4444
4545## Usage
4646
47+
4748Instantiate a client for Trust Protection Platform using token authentication with an existing
4849access token:
4950
5051``` java
52+ // Create an Authentication object with the access token
5153final Authentication auth = Authentication . builder()
5254 .accessToken(" 9PQwQeiTLhcB8/W3/z2Lbw==" )
5355 .build();
5456
57+ // Create a Config object setting the Authentication object
5558final 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
6165final VCertTknClient client = new VCertTknClient (config);
6266```
6367
6468Or instantiate a client for Venafi Cloud:
6569
6670``` java
71+ // Create an Authentication object with the API Key
6772final Authentication auth = Authentication . builder()
6873 .apiKey(" aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" )
6974 .build();
7075
76+ // Create a Config object setting the Authentication object
7177final 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
7583final VCertClient client = new VCertClient (config);
76- client. authenticate(auth);
7784```
7885
7986Then use your client to request certificates:
@@ -187,21 +194,54 @@ _without_ an existing token by providing a username/password. Such a token is g
187194short-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
190198final Authentication auth = Authentication . builder()
191199 .user(" local:apiuser" )
192200 .password(" password" )
193201 .build();
194202
203+ // Create a Config object
195204final 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
200210final VCertTknClient client = new VCertTknClient (config);
211+
212+ // Get the access token. It will cause the client's authentication
201213client. 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
205245client. revokeAccessToken();
206246```
207247
0 commit comments