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

Commit fbf89fe

Browse files
Missing changes in the previous attempt to avoid nullpointer exceptions
1 parent 893f394 commit fbf89fe

2 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/main/java/com/venafi/vcert/sdk/connectors/tpp/TppTokenConnector.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,18 @@ public TokenInfo getAccessToken(Authentication auth) throws VCertException {
128128

129129
if (auth != null) {
130130

131-
Authentication authTemp = null;
132-
133-
if (auth != null) {
134-
135-
//creating a temp Authentication object based on the one passed as argument
136-
// in order to avoid to modify that original given it's needed that
137-
// the Authentication object to be passed to the authenticate() method needs
138-
// that the accessToken and refreshToken doesn't set
139-
authTemp = Authentication.builder()
140-
.user(auth.user())
141-
.password(auth.password())
142-
.clientId(auth.clientId())
143-
.scope(auth.scope())
144-
.state(auth.state())
145-
.redirectUri(auth.redirectUri())
146-
.build();
147-
}
131+
//creating a temp Authentication object based on the one passed as argument
132+
// in order to avoid to modify that original given it's needed that
133+
// the Authentication object to be passed to the authenticate() method needs
134+
// that the accessToken and refreshToken doesn't set
135+
Authentication authTemp = Authentication.builder()
136+
.user(auth.user())
137+
.password(auth.password())
138+
.clientId(auth.clientId())
139+
.scope(auth.scope())
140+
.state(auth.state())
141+
.redirectUri(auth.redirectUri())
142+
.build();
148143

149144
authenticate(authTemp);
150145

src/test/java/com/venafi/vcert/sdk/VCertTknClientAuthenticationAT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.junit.jupiter.api.Test;
1414

1515
import com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException;
16+
import com.venafi.vcert.sdk.connectors.ConnectorException.NullAuthenticationException;
1617
import com.venafi.vcert.sdk.connectors.tpp.TokenInfo;
1718
import com.venafi.vcert.sdk.endpoint.Authentication;
1819
import com.venafi.vcert.sdk.endpoint.ConnectorType;
@@ -219,7 +220,7 @@ void invalidAuthenticationMissingCredentialsInAccessToken() {
219220
VCertTknClient client = getClientUnauthenticated();
220221

221222
//asserting that the credentials were not provided
222-
assertThrows(MissingCredentialsException.class, () -> client.getAccessToken());
223+
assertThrows(NullAuthenticationException.class, () -> client.getAccessToken());
223224

224225
//asserting that the credentials were not provided
225226
assertThrows(MissingCredentialsException.class, () -> client.getAccessToken(getAuthenticationMissingAccessToken()));

0 commit comments

Comments
 (0)