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 8423c4b commit a997988
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 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

0 comments on commit a997988

Please sign in to comment.