Skip to content

Commit

Permalink
changed accessUrl property to isAccessUrlAvailable boolean property
Browse files Browse the repository at this point in the history
  • Loading branch information
ashanthamara committed Dec 5, 2023
1 parent 2ba104b commit 47e973b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,9 @@ private HashMap<String, String> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 47e973b

Please sign in to comment.