Skip to content

Commit

Permalink
check null
Browse files Browse the repository at this point in the history
  • Loading branch information
KannarFr committed May 5, 2020
1 parent adc4b6d commit 14064e5
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -656,18 +656,25 @@ protected void handleConnect(CommandConnect connect) {
// 3. no credentials were passed
if (connect.hasOriginalPrincipal() && service.getPulsar().getConfig().isAuthenticateOriginalAuthData()) {
// init authentication
String originalAuthMethod;
if (connect.hasOriginalAuthMethod()) {
authMethod = connect.getOriginalAuthMethod();
originalAuthMethod = connect.getOriginalAuthMethod();
} else if (connect.hasOriginalAuthMethod()) {
// Legacy client is passing enum
authMethod = connect.getOriginalAuthMethod().substring(10).toLowerCase();
originalAuthMethod = connect.getOriginalAuthMethod().substring(10).toLowerCase();
} else {
authMethod = "none";
originalAuthMethod = "none";
}

AuthenticationProvider originalAuthenticationProvider = getBrokerService()
.getAuthenticationService()
.getAuthenticationProvider(authMethod);
.getAuthenticationProvider(originalAuthMethod);

if (originalAuthenticationProvider == null) {
throw new AuthenticationException(String.format("Can't find AuthenticationProvider for original role" +
" using auth method [%s] is not available", originalAuthMethod));
}

originalAuthState = originalAuthenticationProvider.newAuthState(
AuthData.of(connect.getOriginalAuthData().getBytes()),
remoteAddress,
Expand Down

0 comments on commit 14064e5

Please sign in to comment.