diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/IdentityRecoveryConstants.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/IdentityRecoveryConstants.java index 4d12152d06..1bd55319c9 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/IdentityRecoveryConstants.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/IdentityRecoveryConstants.java @@ -142,7 +142,7 @@ public class IdentityRecoveryConstants { public static final String EXECUTE_ACTION = "ui.execute"; public static final String UTF_8 = "UTF-8"; public static final String CALLBACK = "callback"; - public static final String ACCESS_URL = "accessUrl"; + public static final String IS_ACCESS_URL_AVAILABLE = "isAccessUrlAvailable"; public static final String IS_LITE_SIGN_UP = "isLiteSignUp"; public static final String DEFAULT_CALLBACK_REGEX = ".*"; public static final String IS_USER_PORTAL_URL = "isUserPortalURL"; diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/password/NotificationPasswordRecoveryManager.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/password/NotificationPasswordRecoveryManager.java index 0628203361..a52c9e1a83 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/password/NotificationPasswordRecoveryManager.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/password/NotificationPasswordRecoveryManager.java @@ -484,11 +484,9 @@ private HashMap buildPropertyMap(Property[] properties) { private void validateCallback(Property[] properties, String tenantDomain) throws IdentityRecoveryServerException { String callbackURL = null; - String appAccessURL = null; try { - callbackURL = Utils.getCallbackURL(properties); - appAccessURL = Utils.getAccessUrl(properties); - if (StringUtils.isEmpty(appAccessURL) && !callbackURL.equals(appAccessURL)) { + if (!Utils.isAccessUrlAvailable(properties)) { + callbackURL = Utils.getCallbackURL(properties); if (StringUtils.isNotBlank(callbackURL) && !Utils.validateCallbackURL(callbackURL, tenantDomain, IdentityRecoveryConstants.ConnectorConfig.RECOVERY_CALLBACK_REGEX)) { throw Utils.handleServerException( diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManager.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManager.java index 7c57b2d53c..5b55365428 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManager.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/signup/UserSelfRegistrationManager.java @@ -154,18 +154,16 @@ public NotificationResponseBean registerUser(User user, String password, Claim[] // Callback URL validation String callbackURL = null; - String appAccessUrl = null; try { - callbackURL = Utils.getCallbackURLFromRegistration(properties); - appAccessUrl = Utils.getAccessUrl(properties); - if (StringUtils.isEmpty(appAccessUrl) && !callbackURL.equals(appAccessUrl)) { + if (!Utils.isAccessUrlAvailable(properties)) { + callbackURL = Utils.getCallbackURLFromRegistration(properties); if (StringUtils.isNotBlank(callbackURL) && !Utils.validateCallbackURL(callbackURL, tenantDomain, IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX)) { throw Utils.handleServerException( IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID, callbackURL); } } - } catch (MalformedURLException | UnsupportedEncodingException | IdentityEventException | URISyntaxException e) { + } catch (MalformedURLException | UnsupportedEncodingException | IdentityEventException e) { throw Utils.handleServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID, callbackURL); } diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/util/Utils.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/util/Utils.java index 2ec1ec0b39..53d940b5a4 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/util/Utils.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/util/Utils.java @@ -719,25 +719,17 @@ public static String getCallbackURL(org.wso2.carbon.identity.recovery.model.Prop return callbackURL; } - public static String getAccessUrl(org.wso2.carbon.identity.recovery.model.Property[] properties) - throws UnsupportedEncodingException, URISyntaxException { - + public static boolean isAccessUrlAvailable(org.wso2.carbon.identity.recovery.model.Property[] properties) { if (properties == null) { - return null; + return false; } - String accessURL = null; + boolean accessURL = false; for (org.wso2.carbon.identity.recovery.model.Property property : properties) { - if (IdentityRecoveryConstants.ACCESS_URL.equals(property.getKey())) { - accessURL = property.getValue(); + if (IdentityRecoveryConstants.IS_ACCESS_URL_AVAILABLE.equals(property.getKey())) { + accessURL = Boolean.parseBoolean(property.getValue()) ; break; } } - - if (StringUtils.isNotBlank(accessURL)) { - URI uri = new URI(accessURL); - accessURL = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), null, null) - .toString(); - } return accessURL; }