Skip to content

Commit

Permalink
Add LogoutReturnUrl property to application management API models.
Browse files Browse the repository at this point in the history
  • Loading branch information
RushanNanayakkara committed Jan 18, 2024
1 parent 799837b commit f118c60
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +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 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 @@ -39,6 +39,7 @@ public class ApplicationListItem {
private String description;
private String image;
private String accessUrl;
private String logoutReturnUrl;
private String clientId;
private String issuer;
private String realm;
Expand Down Expand Up @@ -171,6 +172,24 @@ public void setAccessUrl(String accessUrl) {
this.accessUrl = accessUrl;
}

/**
**/
public ApplicationListItem logoutReturnUrl(String logoutReturnUrl) {

this.logoutReturnUrl = logoutReturnUrl;
return this;
}

@ApiModelProperty(example = "https://example.com/app/logout", value = "")
@JsonProperty("logoutReturnUrl")
@Valid
public String getLogoutReturnUrl() {
return logoutReturnUrl;
}
public void setLogoutReturnUrl(String logoutReturnUrl) {
this.logoutReturnUrl = logoutReturnUrl;
}

/**
**/
public ApplicationListItem clientId(String clientId) {
Expand Down Expand Up @@ -332,6 +351,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.description, applicationListItem.description) &&
Objects.equals(this.image, applicationListItem.image) &&
Objects.equals(this.accessUrl, applicationListItem.accessUrl) &&
Objects.equals(this.logoutReturnUrl, applicationListItem.logoutReturnUrl) &&
Objects.equals(this.clientId, applicationListItem.clientId) &&
Objects.equals(this.issuer, applicationListItem.issuer) &&
Objects.equals(this.realm, applicationListItem.realm) &&
Expand All @@ -344,7 +364,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(id, name, description, image, accessUrl, clientId, issuer, realm, access, self, advancedConfigurations, templateId, associatedRoles);
return Objects.hash(id, name, description, image, accessUrl, logoutReturnUrl, clientId, issuer, realm, access, self, advancedConfigurations, templateId, associatedRoles);
}

@Override
Expand All @@ -358,6 +378,7 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" image: ").append(toIndentedString(image)).append("\n");
sb.append(" accessUrl: ").append(toIndentedString(accessUrl)).append("\n");
sb.append(" logoutReturnUrl: ").append(toIndentedString(logoutReturnUrl)).append("\n");
sb.append(" clientId: ").append(toIndentedString(clientId)).append("\n");
sb.append(" issuer: ").append(toIndentedString(issuer)).append("\n");
sb.append(" realm: ").append(toIndentedString(realm)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ApplicationModel {
private String description;
private String imageUrl;
private String accessUrl;
private String logoutReturnUrl;
private String templateId;
private Boolean isManagementApp = false;
private Boolean isB2BSelfServiceApp = false;
Expand Down Expand Up @@ -145,6 +146,24 @@ public void setAccessUrl(String accessUrl) {
this.accessUrl = accessUrl;
}

/**
**/
public ApplicationModel logoutReturnUrl(String logoutReturnUrl) {

this.logoutReturnUrl = logoutReturnUrl;
return this;
}

@ApiModelProperty(example = "https://example.com/app/logout", value = "")
@JsonProperty("logoutReturnUrl")
@Valid
public String getLogoutReturnUrl() {
return logoutReturnUrl;
}
public void setLogoutReturnUrl(String logoutReturnUrl) {
this.logoutReturnUrl = logoutReturnUrl;
}

/**
**/
public ApplicationModel templateId(String templateId) {
Expand All @@ -171,7 +190,7 @@ public ApplicationModel isManagementApp(Boolean isManagementApp) {
this.isManagementApp = isManagementApp;
return this;
}

@ApiModelProperty(example = "false", value = "Decides whether the application used to access System APIs")
@JsonProperty("isManagementApp")
@Valid
Expand All @@ -190,12 +209,11 @@ public ApplicationModel isB2BSelfServiceApp(Boolean isB2BSelfServiceApp) {
this.isB2BSelfServiceApp = isB2BSelfServiceApp;
return this;
}

@ApiModelProperty(example = "false", value = "Decides whether the application used to for B2B self service")
@JsonProperty("isB2BSelfServiceApp")
@Valid
public Boolean getIsB2BSelfServiceApp() {

return isB2BSelfServiceApp;
}
public void setIsB2BSelfServiceApp(Boolean isB2BSelfServiceApp) {
Expand Down Expand Up @@ -327,6 +345,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.description, applicationModel.description) &&
Objects.equals(this.imageUrl, applicationModel.imageUrl) &&
Objects.equals(this.accessUrl, applicationModel.accessUrl) &&
Objects.equals(this.logoutReturnUrl, applicationModel.logoutReturnUrl) &&
Objects.equals(this.templateId, applicationModel.templateId) &&
Objects.equals(this.isManagementApp, applicationModel.isManagementApp) &&
Objects.equals(this.isB2BSelfServiceApp, applicationModel.isB2BSelfServiceApp) &&
Expand All @@ -340,7 +359,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(id, name, description, imageUrl, accessUrl, templateId, isManagementApp, isB2BSelfServiceApp, associatedRoles, claimConfiguration, inboundProtocolConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
return Objects.hash(id, name, description, imageUrl, accessUrl, logoutReturnUrl, templateId, isManagementApp, isB2BSelfServiceApp, associatedRoles, claimConfiguration, inboundProtocolConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
}

@Override
Expand All @@ -354,6 +373,7 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n");
sb.append(" accessUrl: ").append(toIndentedString(accessUrl)).append("\n");
sb.append(" logoutReturnUrl: ").append(toIndentedString(logoutReturnUrl)).append("\n");
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" isManagementApp: ").append(toIndentedString(isManagementApp)).append("\n");
sb.append(" isB2BSelfServiceApp: ").append(toIndentedString(isB2BSelfServiceApp)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ApplicationPatchModel {
private String description;
private String imageUrl;
private String accessUrl;
private String logoutReturnUrl;
private String templateId;
private AssociatedRolesConfig associatedRoles;
private ClaimConfiguration claimConfiguration;
Expand Down Expand Up @@ -120,6 +121,24 @@ public void setAccessUrl(String accessUrl) {
this.accessUrl = accessUrl;
}

/**
**/
public ApplicationPatchModel logoutReturnUrl(String logoutReturnUrl) {

this.logoutReturnUrl = logoutReturnUrl;
return this;
}

@ApiModelProperty(example = "https://example.com/app/logout", value = "")
@JsonProperty("logoutReturnUrl")
@Valid
public String getLogoutReturnUrl() {
return logoutReturnUrl;
}
public void setLogoutReturnUrl(String logoutReturnUrl) {
this.logoutReturnUrl = logoutReturnUrl;
}

/**
**/
public ApplicationPatchModel templateId(String templateId) {
Expand Down Expand Up @@ -244,6 +263,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.description, applicationPatchModel.description) &&
Objects.equals(this.imageUrl, applicationPatchModel.imageUrl) &&
Objects.equals(this.accessUrl, applicationPatchModel.accessUrl) &&
Objects.equals(this.logoutReturnUrl, applicationPatchModel.logoutReturnUrl) &&
Objects.equals(this.templateId, applicationPatchModel.templateId) &&
Objects.equals(this.associatedRoles, applicationPatchModel.associatedRoles) &&
Objects.equals(this.claimConfiguration, applicationPatchModel.claimConfiguration) &&
Expand All @@ -254,7 +274,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(name, description, imageUrl, accessUrl, templateId, associatedRoles, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
return Objects.hash(name, description, imageUrl, accessUrl, logoutReturnUrl, templateId, associatedRoles, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
}

@Override
Expand All @@ -267,6 +287,7 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n");
sb.append(" accessUrl: ").append(toIndentedString(accessUrl)).append("\n");
sb.append(" logoutReturnUrl: ").append(toIndentedString(logoutReturnUrl)).append("\n");
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).append("\n");
sb.append(" claimConfiguration: ").append(toIndentedString(claimConfiguration)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class ApplicationResponseModel {
private String description;
private String imageUrl;
private String accessUrl;
private String logoutReturnUrl;
private String clientId;
private String issuer;
private String realm;
Expand Down Expand Up @@ -185,6 +186,24 @@ public void setAccessUrl(String accessUrl) {
this.accessUrl = accessUrl;
}

/**
**/
public ApplicationResponseModel logoutReturnUrl(String logoutReturnUrl) {

this.logoutReturnUrl = logoutReturnUrl;
return this;
}

@ApiModelProperty(example = "https://example.com/app/logout", value = "")
@JsonProperty("logoutReturnUrl")
@Valid
public String getLogoutReturnUrl() {
return logoutReturnUrl;
}
public void setLogoutReturnUrl(String logoutReturnUrl) {
this.logoutReturnUrl = logoutReturnUrl;
}

/**
**/
public ApplicationResponseModel clientId(String clientId) {
Expand Down Expand Up @@ -446,6 +465,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.description, applicationResponseModel.description) &&
Objects.equals(this.imageUrl, applicationResponseModel.imageUrl) &&
Objects.equals(this.accessUrl, applicationResponseModel.accessUrl) &&
Objects.equals(this.logoutReturnUrl, applicationResponseModel.logoutReturnUrl) &&
Objects.equals(this.clientId, applicationResponseModel.clientId) &&
Objects.equals(this.issuer, applicationResponseModel.issuer) &&
Objects.equals(this.realm, applicationResponseModel.realm) &&
Expand All @@ -463,7 +483,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(id, name, description, imageUrl, accessUrl, clientId, issuer, realm, templateId, isManagementApp, isB2BSelfServiceApp, associatedRoles, claimConfiguration, inboundProtocols, authenticationSequence, advancedConfigurations, provisioningConfigurations, access);
return Objects.hash(id, name, description, imageUrl, accessUrl, logoutReturnUrl, clientId, issuer, realm, templateId, isManagementApp, isB2BSelfServiceApp, associatedRoles, claimConfiguration, inboundProtocols, authenticationSequence, advancedConfigurations, provisioningConfigurations, access);
}

@Override
Expand All @@ -477,6 +497,7 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n");
sb.append(" accessUrl: ").append(toIndentedString(accessUrl)).append("\n");
sb.append(" logoutReturnUrl: ").append(toIndentedString(logoutReturnUrl)).append("\n");
sb.append(" clientId: ").append(toIndentedString(clientId)).append("\n");
sb.append(" issuer: ").append(toIndentedString(issuer)).append("\n");
sb.append(" realm: ").append(toIndentedString(realm)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ public ServiceProvider apply(ApplicationModel applicationModel) {
addProvisioningConfiguration(application, applicationModel.getProvisioningConfigurations());
addInboundAuthenticationProtocolsToApplication(application, applicationModel.getInboundProtocolConfiguration());
addAssociatedRolesConfigurations(application, applicationModel.getAssociatedRoles());
addLogoutReturnUrl(application, applicationModel.getLogoutReturnUrl());
return application;
}

private void addLogoutReturnUrl(ServiceProvider application, String logoutReturnUrl) {

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

private void addAssociatedRolesConfigurations(ServiceProvider application, AssociatedRolesConfig associatedRoles) {

if (associatedRoles != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants;
import org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementServiceHolder;
import org.wso2.carbon.identity.api.server.application.management.v1.AdditionalSpProperty;
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
Expand Down Expand Up @@ -120,6 +121,7 @@ public ApplicationResponseModel apply(ServiceProvider application) {
.description(application.getDescription())
.imageUrl(application.getImageUrl())
.accessUrl(application.getAccessUrl())
.logoutReturnUrl(loadLogoutReturnUrl(application))
.clientId(getInboundKey(application, "oauth2"))
.issuer(getInboundKey(application, "samlsso"))
.realm(getInboundKey(application, "passivests"))
Expand All @@ -135,6 +137,16 @@ public ApplicationResponseModel apply(ServiceProvider application) {
}
}

private String loadLogoutReturnUrl(ServiceProvider application) {

for (ServiceProviderProperty property : application.getSpProperties()) {
if (ApplicationManagementConstants.PROP_LOGOUT_RETURN_URL.equals(property.getName())) {
return property.getValue();
}
}
return null;
}

private AssociatedRolesConfig buildAssociatedRoles(ServiceProvider application) {

AssociatedRolesConfig associatedRolesConfig = new AssociatedRolesConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.wso2.carbon.identity.api.server.application.management.v1.core.functions.application;

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;
import org.wso2.carbon.identity.application.common.model.ServiceProviderProperty;

import java.util.Arrays;

/**
* Update logout return url.
*/
public class UpdateLogoutReturnUrl implements UpdateFunction<ServiceProvider, String> {

@Override
public void apply(ServiceProvider serviceProvider, String logoutReturnUrl) {

ServiceProviderProperty[] spProperties = serviceProvider.getSpProperties();
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;
}
}
if (!logoutURLExists) {
ServiceProviderProperty logoutURLProperty = new ServiceProviderProperty();
logoutURLProperty.setName(ApplicationManagementConstants.PROP_LOGOUT_RETURN_URL);
logoutURLProperty.setValue(logoutReturnUrl);
logoutURLProperty.setDisplayName(ApplicationManagementConstants.LOGOUT_RETURN_URL_DISPLAY_NAME);
spProperties = Arrays.copyOf(spProperties, spProperties.length + 1);
spProperties[spProperties.length - 1] = logoutURLProperty;
}
serviceProvider.setSpProperties(spProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public void apply(ServiceProvider serviceProvider, ApplicationPatchModel applica
patchAuthenticationSequence(applicationPatchModel.getAuthenticationSequence(), serviceProvider);
patchAdvancedConfiguration(serviceProvider, applicationPatchModel.getAdvancedConfigurations());
patchProvisioningConfiguration(applicationPatchModel.getProvisioningConfigurations(), serviceProvider);
patchLogoutReturnUrl(serviceProvider, applicationPatchModel.getLogoutReturnUrl());
}

private void patchLogoutReturnUrl(ServiceProvider application, String logoutReturnUrl) {

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

private void patchAssociatedRolesConfigurations(ServiceProvider serviceProvider,
Expand Down
Loading

0 comments on commit f118c60

Please sign in to comment.