Venafi / vcert-java

Java client SDK designed to simplify integrations by automating key generation and certificate enrollment using Venafi machine identity services.
Apache License 2.0
9 stars 11 forks source link

Standardize the initialization for VCertClient and VCertTknClient #99

Closed marcos-albornoz closed 2 years ago

marcos-albornoz commented 2 years ago

BUSINESS PROBLEM On VCertTknClient exists two ways to ensure that a new VCertTknClient will have the correct credentials to perform interactions with TPP. The first one is create an Authentication object setting into it the accessToken and then put it as credentials on the Config object which is passed to the VCertTknClient constructor. The second option is to create an Authentication object setting into it the user and password, and then after the VCertTknClient is created then call to VCertTknClient.getAccessToken passing the Authentication object as argument.

On VCertClient, no matter the flavor used, it will needed to provide the credentials(apiKey for Cloud and user&password for TPP) in an Authentication object and then pass it to the created VCertClient object calling the authenticate method.

Additional to the evident differences, on VCertTknClient when it's used the first option, the accessToken provided to the Authentication object is not validated resulting that until an operation is performed it will determined if the accessToken is valid or not. Opposite to that, the calling to the VCertTknClient.getAccessToken returns a TokenInfo which needs to be analized to determine if the credentials are valid and VCertClient.authenticate even is validating the credentials, there is not any result/exception returned to identify if the credentials are valid or not, so until an operation is performed it will determined that situation.

PROPOSED SOLUTION Homologate the first option on VCertTknClient to VCertClient, that is provide the Authentication object to the Config object avoiding the use of the authenticate method.

Ensure throws an Exception if the credentials are not valid in the VCertTknClient.getAccessToken and VCertClient.authenticate methods.

marcos-albornoz commented 2 years ago

@tr1ck3r @rvelaVenafi @angelmoo when you have free time, please tell me what you think or suggestions about of this issue.

marcos-albornoz commented 2 years ago

Covered in v0.9.0