Search in sources :

Example 26 with PermissionsAndRoleConfig

use of org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig in project product-is by wso2.

the class ApplicationManagementTestCase method testUpdateApplicationPermissions.

@Test(alwaysRun = true, description = "2.1.2.9")
public void testUpdateApplicationPermissions() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        PermissionsAndRoleConfig permAndRoleConfig = new PermissionsAndRoleConfig();
        List<ApplicationPermission> appPermList = new ArrayList<ApplicationPermission>();
        ApplicationPermission appPermission = new ApplicationPermission();
        appPermission.setValue("app_permission");
        appPermList.add(appPermission);
        permAndRoleConfig.setPermissions(appPermList.toArray(new ApplicationPermission[appPermList.size()]));
        serviceProvider.setPermissionAndRoleConfig(permAndRoleConfig);
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        PermissionsAndRoleConfig updatedPermissionsAndRoleConfig = updatedServiceProvider.getPermissionAndRoleConfig();
        Assert.assertEquals(updatedPermissionsAndRoleConfig.getPermissions()[0].getValue(), "app_permission", "Failed update application permissions");
    } catch (Exception e) {
        Assert.fail("Error while trying to update Application Permissions", e);
    }
}
Also used : PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.xsd.PermissionsAndRoleConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ArrayList(java.util.ArrayList) ApplicationPermission(org.wso2.carbon.identity.application.common.model.xsd.ApplicationPermission) Test(org.testng.annotations.Test)

Example 27 with PermissionsAndRoleConfig

use of org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig in project product-is by wso2.

the class ApplicationManagementTestCase method testUpdateRoles.

@Test(alwaysRun = true, description = "2.1.2.10")
public void testUpdateRoles() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        PermissionsAndRoleConfig permAndRoleConfig = new PermissionsAndRoleConfig();
        List<RoleMapping> roleMappingList = new ArrayList<RoleMapping>();
        RoleMapping mapping = new RoleMapping();
        LocalRole localRole = new LocalRole();
        localRole.setLocalRoleName(IDP_ROLE_1);
        mapping.setLocalRole(localRole);
        mapping.setRemoteRole("spRole_1");
        roleMappingList.add(mapping);
        permAndRoleConfig.setRoleMappings(roleMappingList.toArray(new RoleMapping[roleMappingList.size()]));
        serviceProvider.setPermissionAndRoleConfig(permAndRoleConfig);
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        PermissionsAndRoleConfig updatedPermissionsAndRoleConfig = updatedServiceProvider.getPermissionAndRoleConfig();
        Assert.assertEquals(updatedPermissionsAndRoleConfig.getRoleMappings()[0].getLocalRole().getLocalRoleName(), IDP_ROLE_1, "Failed update local role");
        Assert.assertEquals(updatedPermissionsAndRoleConfig.getRoleMappings()[0].getRemoteRole(), "spRole_1", "Failed update remote role");
    } catch (Exception e) {
        Assert.fail("Error while trying to update Roles", e);
    }
}
Also used : PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.xsd.PermissionsAndRoleConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ArrayList(java.util.ArrayList) LocalRole(org.wso2.carbon.identity.application.common.model.xsd.LocalRole) RoleMapping(org.wso2.carbon.identity.application.common.model.xsd.RoleMapping) Test(org.testng.annotations.Test)

Example 28 with PermissionsAndRoleConfig

use of org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig in project product-is by wso2.

the class ApplicationManagementTestCase method testUpdateApplicationPermissions.

@Test(alwaysRun = true, description = "Testing update Application Permissions")
public void testUpdateApplicationPermissions() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        PermissionsAndRoleConfig permAndRoleConfig = new PermissionsAndRoleConfig();
        List<ApplicationPermission> appPermList = new ArrayList<ApplicationPermission>();
        ApplicationPermission appPermission = new ApplicationPermission();
        appPermission.setValue("app_permission");
        appPermList.add(appPermission);
        permAndRoleConfig.setPermissions(appPermList.toArray(new ApplicationPermission[appPermList.size()]));
        serviceProvider.setPermissionAndRoleConfig(permAndRoleConfig);
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        PermissionsAndRoleConfig updatedPermissionsAndRoleConfig = updatedServiceProvider.getPermissionAndRoleConfig();
        Assert.assertEquals(updatedPermissionsAndRoleConfig.getPermissions()[0].getValue(), "app_permission", "Failed update application permissions");
    } catch (Exception e) {
        Assert.fail("Error while trying to update Application Permissions", e);
    }
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ArrayList(java.util.ArrayList) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 29 with PermissionsAndRoleConfig

use of org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig in project identity-api-server by wso2.

the class UpdateClaimConfiguration method updateRoleClaimConfigs.

private void updateRoleClaimConfigs(RoleConfig roleApiModel, ServiceProvider application) {
    if (roleApiModel != null) {
        ClaimConfig claimConfig = getClaimConfig(application);
        if (roleApiModel.getClaim() != null) {
            claimConfig.setRoleClaimURI(roleApiModel.getClaim().getUri());
        }
        PermissionsAndRoleConfig permissionAndRoleConfig = getPermissionAndRoleConfig(application);
        permissionAndRoleConfig.setRoleMappings(getRoleMappings(roleApiModel));
        LocalAndOutboundAuthenticationConfig localAndOutboundConfig = getLocalAndOutboundConfig(application);
        setIfNotNull(roleApiModel.getIncludeUserDomain(), localAndOutboundConfig::setUseUserstoreDomainInRoles);
    }
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)

Example 30 with PermissionsAndRoleConfig

use of org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig in project identity-api-server by wso2.

the class ServerIdpManagementService method updateRoles.

private void updateRoles(IdentityProvider idp, Roles roles) {
    if (roles != null) {
        PermissionsAndRoleConfig permissionsAndRoleConfig = new PermissionsAndRoleConfig();
        List<org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping> mappings = roles.getMappings();
        List<RoleMapping> internalMappings = new ArrayList<>();
        List<String> idpRoles = new ArrayList<>();
        if (mappings != null) {
            for (org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping mapping : mappings) {
                RoleMapping internalMapping = new RoleMapping();
                internalMapping.setLocalRole(new LocalRole(mapping.getLocalRole()));
                internalMapping.setRemoteRole(mapping.getIdpRole());
                idpRoles.add(mapping.getIdpRole());
                internalMappings.add(internalMapping);
            }
        }
        permissionsAndRoleConfig.setIdpRoles(idpRoles.toArray(new String[0]));
        permissionsAndRoleConfig.setRoleMappings(internalMappings.toArray(new RoleMapping[0]));
        idp.setPermissionAndRoleConfig(permissionsAndRoleConfig);
        idp.setProvisioningRole(StringUtils.join(roles.getOutboundProvisioningRoles(), ","));
    }
}
Also used : ArrayList(java.util.ArrayList) RoleMapping(org.wso2.carbon.identity.application.common.model.RoleMapping) PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig) LocalRole(org.wso2.carbon.identity.application.common.model.LocalRole)

Aggregations

PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)20 RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)16 ArrayList (java.util.ArrayList)10 LocalRole (org.wso2.carbon.identity.application.common.model.LocalRole)10 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)9 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)9 Claim (org.wso2.carbon.identity.application.common.model.Claim)7 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)7 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)7 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)7 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)6 Property (org.wso2.carbon.identity.application.common.model.Property)6 DataProvider (org.testng.annotations.DataProvider)4 Test (org.testng.annotations.Test)4 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)4 HashSet (java.util.HashSet)3 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)3 PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.xsd.PermissionsAndRoleConfig)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2