Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
Addressing comments
  • Loading branch information
RushanNanayakkara committed Jan 22, 2024
1 parent d5e8f97 commit fd5ca13
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ private ApplicationManagementConstants() {
public static final String FAPI_ALLOWED_CLIENT_AUTHENTICATION_METHODS = "OAuth.OpenIDConnect.FAPI." +
"AllowedClientAuthenticationMethods.AllowedClientAuthenticationMethod";
public static final String RSA1_5 = "RSA1_5";
public static final String PROP_LOGOUT_RETURN_URL = "logoutReturnURL";
public static final String PROP_LOGOUT_RETURN_URL = "logoutReturnUrl";
public static final String DEFAULT_LOGOUT_RETURN_URL_VALUE = ".*";
public static final String LOGOUT_RETURN_URL_DISPLAY_NAME = "Logout Return URL";

public static final String NON_EXISTING_USER_CODE = "30007 - ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public ServiceProvider apply(ApplicationModel applicationModel) {

private void addLogoutReturnUrl(ServiceProvider application, String logoutReturnUrl) {

if (logoutReturnUrl != null) {
new UpdateLogoutReturnUrl().apply(application, logoutReturnUrl);
}
new UpdateLogoutReturnUrl().apply(application, logoutReturnUrl);
}

private void addAssociatedRolesConfigurations(ServiceProvider application, AssociatedRolesConfig associatedRoles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public ApplicationResponseModel apply(ServiceProvider application) {
.description(application.getDescription())
.imageUrl(application.getImageUrl())
.accessUrl(application.getAccessUrl())
.logoutReturnUrl(loadLogoutReturnUrl(application))
.logoutReturnUrl(getLogoutReturnUrl(application))
.clientId(getInboundKey(application, "oauth2"))
.issuer(getInboundKey(application, "samlsso"))
.realm(getInboundKey(application, "passivests"))
Expand All @@ -137,14 +137,14 @@ public ApplicationResponseModel apply(ServiceProvider application) {
}
}

private String loadLogoutReturnUrl(ServiceProvider application) {
private String getLogoutReturnUrl(ServiceProvider application) {

for (ServiceProviderProperty property : application.getSpProperties()) {
if (ApplicationManagementConstants.PROP_LOGOUT_RETURN_URL.equals(property.getName())) {
return property.getValue();
}
}
return null;
return null; // null value returned to avoid API response returning an empty string.
}

private AssociatedRolesConfig buildAssociatedRoles(ServiceProvider application) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wso2.carbon.identity.api.server.application.management.v1.core.functions.application;

import org.apache.commons.lang.StringUtils;
import org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants;
import org.wso2.carbon.identity.api.server.application.management.v1.core.functions.UpdateFunction;
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
Expand All @@ -15,26 +16,34 @@ public class UpdateLogoutReturnUrl implements UpdateFunction<ServiceProvider, St
@Override
public void apply(ServiceProvider serviceProvider, String logoutReturnUrl) {

if (StringUtils.isBlank(logoutReturnUrl)) {
logoutReturnUrl = ApplicationManagementConstants.DEFAULT_LOGOUT_RETURN_URL_VALUE;
}
ServiceProviderProperty[] spProperties = serviceProvider.getSpProperties();
boolean logoutURLExists = false;
boolean logoutUrlExists = false;

if (spProperties == null) {
spProperties = new ServiceProviderProperty[0];
}
for (ServiceProviderProperty spProperty : spProperties) {
if (ApplicationManagementConstants.PROP_LOGOUT_RETURN_URL.equals(spProperty.getName())) {
spProperty.setValue(logoutReturnUrl);
logoutURLExists = true;
logoutUrlExists = true;
}
}
if (!logoutURLExists) {
ServiceProviderProperty logoutURLProperty = new ServiceProviderProperty();
logoutURLProperty.setName(ApplicationManagementConstants.PROP_LOGOUT_RETURN_URL);
logoutURLProperty.setValue(logoutReturnUrl);
logoutURLProperty.setDisplayName(ApplicationManagementConstants.LOGOUT_RETURN_URL_DISPLAY_NAME);
if (!logoutUrlExists) {
spProperties = Arrays.copyOf(spProperties, spProperties.length + 1);
spProperties[spProperties.length - 1] = logoutURLProperty;
spProperties[spProperties.length - 1] = buildLogoutReturnUrlSpProperty(logoutReturnUrl);
}
serviceProvider.setSpProperties(spProperties);
}

private ServiceProviderProperty buildLogoutReturnUrlSpProperty(String logoutReturnUrl) {

ServiceProviderProperty logoutReturnUrlProperty = new ServiceProviderProperty();
logoutReturnUrlProperty.setName(ApplicationManagementConstants.PROP_LOGOUT_RETURN_URL);
logoutReturnUrlProperty.setValue(logoutReturnUrl);
logoutReturnUrlProperty.setDisplayName(ApplicationManagementConstants.LOGOUT_RETURN_URL_DISPLAY_NAME);
return logoutReturnUrlProperty;
}
}

0 comments on commit fd5ca13

Please sign in to comment.