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);
}
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;
}
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;
}
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 '&gt;'", content.contains("&gt;"));
}
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"));
}
Aggregations