Skip to content

Commit

Permalink
fix possible NPEs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuradhaSK committed Oct 23, 2023
1 parent cecd552 commit 74a7c7a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.RoleMapping;
import org.wso2.carbon.identity.application.common.model.RoleV2;
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
import org.wso2.carbon.identity.application.common.model.ServiceProviderProperty;
import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants;
Expand Down Expand Up @@ -139,7 +140,8 @@ private AssociatedRolesConfig buildAssociatedRoles(ServiceProvider application)
break;
}
associatedRolesConfig.setAllowedAudience(allowedAudienceEnum);
application.getAssociatedRolesConfig().getRoles().forEach(role -> associatedRolesConfig.addRolesItem(
RoleV2[] roles = application.getAssociatedRolesConfig().getRoles();
Arrays.asList(roles).forEach(role -> associatedRolesConfig.addRolesItem(
new Role().id(role.getId()).name(role.getName())));
return associatedRolesConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import org.wso2.carbon.identity.api.server.application.management.v1.core.functions.UpdateFunction;
import org.wso2.carbon.identity.application.common.model.RoleV2;
import org.wso2.carbon.identity.application.common.model.ServiceProvider;

import java.util.List;
Expand All @@ -41,7 +42,7 @@ public void apply(ServiceProvider serviceProvider, AssociatedRolesConfig associa
associatedRolesConfig.getRoles().stream()
.map(role -> new org.wso2.carbon.identity.application.common.model.RoleV2(role.getId()))
.collect(Collectors.toList());
rolesConfig.setRoles(listOfRoles);
rolesConfig.setRoles(listOfRoles.toArray(new RoleV2[0]));
}
serviceProvider.setAssociatedRolesConfig(rolesConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void apply(ServiceProvider serviceProvider, ApplicationPatchModel applica
patchProvisioningConfiguration(applicationPatchModel.getProvisioningConfigurations(), serviceProvider);
}

private void patchAssociatedRolesConfigurations(ServiceProvider serviceProvider, AssociatedRolesConfig associatedRoles) {
private void patchAssociatedRolesConfigurations(ServiceProvider serviceProvider,
AssociatedRolesConfig associatedRoles) {

if (associatedRoles != null) {
new UpdateAssociatedRoles().apply(serviceProvider, associatedRoles);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
<maven.buildnumber.plugin.version>1.4</maven.buildnumber.plugin.version>
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
<identity.governance.version>1.8.62</identity.governance.version>
<carbon.identity.framework.version>5.25.416</carbon.identity.framework.version>
<carbon.identity.framework.version>5.25.424-SNAPSHOT</carbon.identity.framework.version>
<maven.findbugsplugin.version>3.0.5</maven.findbugsplugin.version>
<identity.workflow.impl.bps.version>5.2.0</identity.workflow.impl.bps.version>
<maven.checkstyleplugin.excludes>**/gen/**/*</maven.checkstyleplugin.excludes>
Expand Down

0 comments on commit 74a7c7a

Please sign in to comment.