Skip to content

Commit

Permalink
Merge pull request #781 from amanda-ariyaratne/patch-1
Browse files Browse the repository at this point in the history
Reuse sso login recaptcha connector constant
  • Loading branch information
asha15 authored Nov 16, 2023
2 parents 25978f7 + 4750c80 commit 2825fee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2023, WSO2 LLC (http://www.wso2.org).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import static org.wso2.carbon.identity.captcha.util.CaptchaConstants.ENABLE_GENERIC_CAPTCHA_VALIDATION;
import static org.wso2.carbon.identity.captcha.util.CaptchaConstants.ON_FAILED_LOGIN_REDIRECT_URL;
import static org.wso2.carbon.identity.captcha.util.CaptchaConstants.ReCaptchaConnectorPropertySuffixes;
import static org.wso2.carbon.identity.captcha.util.CaptchaConstants.SSO_LOGIN_RECAPTCHA_CONNECTOR_NAME;

/**
* Captcha util functions.
Expand Down Expand Up @@ -449,13 +450,11 @@ public static boolean isMaximumFailedLoginAttemptsReached(String usernameWithDom
public static boolean isMaximumFailedLoginAttemptsReached(String usernameWithDomain, String tenantDomain,
String failedAttemptsClaim) throws CaptchaException {

String CONNECTOR_NAME = "sso.login.recaptcha";

Property[] connectorConfigs;
try {
connectorConfigs = CaptchaDataHolder.getInstance().getIdentityGovernanceService()
.getConfiguration(new String[]{CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.ENABLE,
CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.MAX_ATTEMPTS}, tenantDomain);
.getConfiguration(new String[]{SSO_LOGIN_RECAPTCHA_CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.ENABLE,
SSO_LOGIN_RECAPTCHA_CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.MAX_ATTEMPTS}, tenantDomain);
} catch (Exception e) {
// Can happen due to invalid user/ invalid tenant/ invalid configuration
if (log.isDebugEnabled()) {
Expand All @@ -470,10 +469,10 @@ public static boolean isMaximumFailedLoginAttemptsReached(String usernameWithDom

String maxAttemptsStr = null;
for (Property property : connectorConfigs) {
if ((CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.ENABLE).equals(property.getName())
if ((SSO_LOGIN_RECAPTCHA_CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.ENABLE).equals(property.getName())
&& !Boolean.valueOf(property.getValue())) {
return false;
} else if ((CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.MAX_ATTEMPTS).equals(property.getName())) {
} else if ((SSO_LOGIN_RECAPTCHA_CONNECTOR_NAME + ReCaptchaConnectorPropertySuffixes.MAX_ATTEMPTS).equals(property.getName())) {
maxAttemptsStr = property.getValue();
}
}
Expand Down

0 comments on commit 2825fee

Please sign in to comment.