Search in sources :

Example 1 with JDBCUserStoreManager

use of org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager in project product-is by wso2.

the class UserStoreConfigAdminTestCase method testAddDuplicateUserStore.

@Test(expectedExceptions = UserStoreConfigAdminServiceIdentityUserStoreMgtException.class, groups = "wso2.is", description = "Check add user store via DTO", dependsOnMethods = "testAddUserStore")
public void testAddDuplicateUserStore() throws Exception {
    Property[] properties = (new JDBCUserStoreManager()).getDefaultUserStoreProperties().getMandatoryProperties();
    PropertyDTO[] propertyDTOs = new PropertyDTO[properties.length];
    for (int i = 0; i < properties.length; i++) {
        PropertyDTO propertyDTO = new PropertyDTO();
        propertyDTO.setName(properties[i].getName());
        propertyDTO.setValue(properties[i].getValue());
        propertyDTOs[i] = propertyDTO;
    }
    UserStoreDTO userStoreDTO = userStoreConfigurationClient.createUserStoreDTO(jdbcClass, "lanka.com", propertyDTOs);
    userStoreConfigurationClient.addUserStore(userStoreDTO);
}
Also used : JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) Property(org.wso2.carbon.user.api.Property) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 2 with JDBCUserStoreManager

use of org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager in project identity-inbound-provisioning-scim2 by wso2-extensions.

the class SCIMUserManager method getTotalUsers.

private long getTotalUsers(String domainName) throws CharonException {
    long totalUsers = 0;
    AbstractUserStoreManager secondaryUserStoreManager = null;
    if (StringUtils.isNotBlank(domainName)) {
        secondaryUserStoreManager = (AbstractUserStoreManager) carbonUM.getSecondaryUserStoreManager(domainName);
    }
    try {
        if (secondaryUserStoreManager instanceof JDBCUserStoreManager) {
            totalUsers = secondaryUserStoreManager.countUsersWithClaims(USERNAME_CLAIM, "*");
        }
    } catch (org.wso2.carbon.user.core.UserStoreException e) {
        throw resolveError(e, "Error while getting total user count in domain: " + domainName);
    }
    return totalUsers;
}
Also used : JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager)

Example 3 with JDBCUserStoreManager

use of org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager in project carbon-identity-framework by wso2.

the class UserRealmProxy method canLimitAndFilterUsersFromUMLevel.

/**
 *  Checks whether the user store containing the given role name supports filter and limit.
 */
private boolean canLimitAndFilterUsersFromUMLevel(String roleName, UserStoreManager userStoreManager) {
    // Currently filter and limit for users in the role is supported only with the JDBC user store manager.
    boolean canLimitAndFilterWithUM = false;
    int domainSeparatorIndex = roleName.indexOf(CarbonConstants.DOMAIN_SEPARATOR);
    if (domainSeparatorIndex > 0) {
        String domainInRole = roleName.substring(0, domainSeparatorIndex);
        UserStoreManager secondaryUserStoreManager = userStoreManager.getSecondaryUserStoreManager(domainInRole);
        if (secondaryUserStoreManager != null) {
            canLimitAndFilterWithUM = secondaryUserStoreManager instanceof JDBCUserStoreManager;
        }
    } else {
        canLimitAndFilterWithUM = userStoreManager instanceof JDBCUserStoreManager;
    }
    return canLimitAndFilterWithUM;
}
Also used : JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager) UserStoreManager(org.wso2.carbon.user.core.UserStoreManager) JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager)

Example 4 with JDBCUserStoreManager

use of org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager in project product-is by wso2.

the class UserStoreConfigTestForIDENTITY5573 method testAddUserStoreWithAdvPropertiesAndSpecialChars.

@Test(groups = "wso2.is", description = "Check add user store via DTO")
public void testAddUserStoreWithAdvPropertiesAndSpecialChars() throws Exception {
    Property[] properties = (new JDBCUserStoreManager()).getDefaultUserStoreProperties().getMandatoryProperties();
    List<PropertyDTO> propertyDTOList = new ArrayList<PropertyDTO>();
    for (Property property : properties) {
        PropertyDTO propertyDTO = new PropertyDTO();
        propertyDTO.setName(property.getName());
        propertyDTO.setValue(property.getValue());
        propertyDTOList.add(propertyDTO);
    }
    PropertyDTO dummySqlProperty = new PropertyDTO();
    dummySqlProperty.setName("DummySQLWithSpecialChar");
    dummySqlProperty.setValue("SELECT UM_USER_NAME FROM UM_USER WHERE UM_USER_NAME LIKE ? AND UM_TENANT_ID>? ORDER BY UM_USER_NAME");
    propertyDTOList.add(dummySqlProperty);
    UserStoreDTO userStoreDTO = userStoreConfigurationClient.createUserStoreDTO(JDBC_USM_CLASS, USER_STORE_NAME, propertyDTOList.toArray(new PropertyDTO[0]));
    userStoreConfigurationClient.addUserStore(userStoreDTO);
    Assert.assertTrue("Domain addition via DTO has failed.", userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigurationClient, USER_STORE_NAME));
    // Now check whether the config file is properly encoded,
    // Since the carbon home system property is changed when servers are started we use the original carbon home
    // captured by a listener.
    String carbonHome = System.getProperty("original.carbon.home");
    if (StringUtils.isBlank(carbonHome)) {
        carbonHome = System.getProperty("carbon.home");
    }
    String pathToConfig = String.format("%s/repository/deployment/server/userstores/%s.xml", carbonHome, USER_STORE_NAME);
    File configFile = new File(pathToConfig);
    Assert.assertTrue(String.format("Config file is not found at %s", pathToConfig), waitForUserStoreFileDeployment(configFile));
    String content = FileUtils.readFileToString(configFile);
    Assert.assertFalse("Query not encoded properly, it contains '&amp;gt;'", content.contains("&amp;gt;"));
}
Also used : JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) ArrayList(java.util.ArrayList) Property(org.wso2.carbon.user.api.Property) File(java.io.File) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 5 with JDBCUserStoreManager

use of org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager in project product-is by wso2.

the class UserStoreConfigAdminTestCase method testAddUserStore.

@Test(groups = "wso2.is", description = "Check add user store via DTO", dependsOnMethods = "testAvailableUserStoreClasses")
public void testAddUserStore() throws Exception {
    Property[] properties = (new JDBCUserStoreManager()).getDefaultUserStoreProperties().getMandatoryProperties();
    PropertyDTO[] propertyDTOs = new PropertyDTO[properties.length];
    for (int i = 0; i < properties.length; i++) {
        PropertyDTO propertyDTO = new PropertyDTO();
        propertyDTO.setName(properties[i].getName());
        propertyDTO.setValue(properties[i].getValue());
        propertyDTOs[i] = propertyDTO;
    }
    UserStoreDTO userStoreDTO = userStoreConfigurationClient.createUserStoreDTO(jdbcClass, "lanka.com", propertyDTOs);
    userStoreConfigurationClient.addUserStore(userStoreDTO);
    Assert.assertTrue("Domain addition via DTO has failed.", userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigurationClient, "lanka.com"));
}
Also used : JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) Property(org.wso2.carbon.user.api.Property) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

JDBCUserStoreManager (org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager)5 Test (org.testng.annotations.Test)3 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)3 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO)3 Property (org.wso2.carbon.user.api.Property)3 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)3 AbstractUserStoreManager (org.wso2.carbon.user.core.common.AbstractUserStoreManager)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 UserStoreManager (org.wso2.carbon.user.core.UserStoreManager)1