Skip to content

Commit

Permalink
Refactor application-mgt component to utilize certificate-mgt compone…
Browse files Browse the repository at this point in the history
…nt for certificate management (#6087)

* Add certificate-mgt dependency to application-mgt component

* Refactor application-mgt to untilize certificate-mgt component for application certificate management

* Add sonarcloud suggestions

* Remove unused imports

* Add unit tests for application certificate management

* Modify unit tests

* Refactor application-certificate unit tests

* Improve line coverage

* Add sonarCloud suggestion to reduce method complexity

* Change CERTIFICATE property name to the defined constant variable

* address comments

* Remove schema change

* Add comments to the test methods

* Improve assertions

* Minor improvement
  • Loading branch information
ashanthamara authored Nov 3, 2024
1 parent 497c049 commit 8a2cbb2
Show file tree
Hide file tree
Showing 7 changed files with 581 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.secret.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.certificate.management</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -260,6 +264,9 @@
version="${org.wso2.carbon.identity.organization.management.core.version.range}",
org.wso2.carbon.identity.api.resource.mgt.model; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.api.resource.mgt.util; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.certificate.management.service; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.certificate.management.exception; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.certificate.management.model; version="${carbon.identity.package.import.version.range}",
</Import-Package>
<Export-Package>
!org.wso2.carbon.identity.application.mgt.internal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
import static org.wso2.carbon.identity.application.mgt.inbound.InboundFunctions.updateOrInsertInbound;
import static org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils.triggerAuditLogEvent;
import static org.wso2.carbon.identity.core.util.IdentityUtil.getInitiatorId;
import static org.wso2.carbon.identity.core.util.IdentityUtil.isValidPEMCertificate;
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.ROLE_MANAGEMENT_ERROR_CODE_PREFIX;
import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.Error.ROLE_NOT_FOUND;
import static org.wso2.carbon.utils.multitenancy.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
Expand Down Expand Up @@ -3036,7 +3035,6 @@ private void doPreUpdateChecks(String storedAppName, ServiceProvider updatedApp,

validateAuthorization(updatedAppName, storedAppName, username, tenantDomain);
validateAppName(storedAppName, updatedApp, tenantDomain);
validateApplicationCertificate(updatedApp, tenantDomain);
boolean isValid = isAssociatedRolesConfigValid(updatedApp, tenantDomain);
if (!isValid) {
throw new IdentityApplicationManagementClientException(
Expand All @@ -3058,17 +3056,6 @@ private void updateApplicationPermissions(ServiceProvider updatedApp, String upd
}
}

private void validateApplicationCertificate(ServiceProvider updatedApp,
String tenantDomain) throws IdentityApplicationManagementException {

if (!isValidPEMCertificate(updatedApp.getCertificateContent())) {
String error = "Provided application certificate for application with name: %s in tenantDomain: %s " +
"is malformed.";
throw buildClientException(INVALID_REQUEST,
String.format(error, updatedApp.getApplicationName(), tenantDomain));
}
}

private void validateApplicationConfigurations(ServiceProvider application,
String tenantDomain,
String username) throws IdentityApplicationManagementException {
Expand Down
Loading

0 comments on commit 8a2cbb2

Please sign in to comment.