Skip to content

Commit

Permalink
fix nullpointer if no overrides defined
Browse files Browse the repository at this point in the history
  • Loading branch information
instipod committed Apr 13, 2021
1 parent 2c9f7e8 commit 88faaf0
Showing 1 changed file with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@ private Client initDuoClient(AuthenticationFlowContext context, String redirectU
String hostname = authConfig.getConfig().get(DuoUniversalAuthenticatorFactory.DUO_API_HOSTNAME);

String overrides = authConfig.getConfig().get(DuoUniversalAuthenticatorFactory.DUO_CUSTOM_CLIENT_IDS);
//multivalue string seperator is ##
String[] overridesSplit = overrides.split("##");
for (String override : overridesSplit) {
String[] parts = override.split(",");
if (parts.length == 3 || parts.length == 4) {
String duoHostname;
if (parts.length == 3) {
duoHostname = hostname;
} else {
duoHostname = parts[3];
}
//valid entries have 3 or 4 parts: keycloak client id, duo id, duo secret, (optional) api hostname
String keycloakClient = parts[0];
String duoId = parts[1];
String duoSecret = parts[2];

if (keycloakClient.equalsIgnoreCase(context.getAuthenticationSession().getClient().getId())) {
//found a specific client override
clientId = duoId;
secret = duoSecret;
hostname = duoHostname;
if (overrides != null && !overrides.equalsIgnoreCase("")) {
//multivalue string seperator is ##
String[] overridesSplit = overrides.split("##");
for (String override : overridesSplit) {
String[] parts = override.split(",");
if (parts.length == 3 || parts.length == 4) {
String duoHostname;
if (parts.length == 3) {
duoHostname = hostname;
} else {
duoHostname = parts[3];
}
//valid entries have 3 or 4 parts: keycloak client id, duo id, duo secret, (optional) api hostname
String keycloakClient = parts[0];
String duoId = parts[1];
String duoSecret = parts[2];

if (keycloakClient.equalsIgnoreCase(context.getAuthenticationSession().getClient().getId())) {
//found a specific client override
clientId = duoId;
secret = duoSecret;
hostname = duoHostname;
}
}
}
}
Expand Down

0 comments on commit 88faaf0

Please sign in to comment.