use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project product-is by wso2.
the class IDENTITY4776SCIMServiceWithOAuthTestCase method addSecondaryUserStore.
private void addSecondaryUserStore() throws Exception {
String jdbcClass = "org.wso2.carbon.user.core.jdbc.UniqueIDJDBCUserStoreManager";
H2DataBaseManager dbmanager = new H2DataBaseManager("jdbc:h2:" + Utils.getResidentCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME, DB_USER_NAME, DB_USER_PASSWORD);
dbmanager.executeUpdate(new File(Utils.getResidentCarbonHome() + "/dbscripts/h2.sql"));
dbmanager.disconnect();
PropertyDTO[] propertyDTOs = new PropertyDTO[11];
for (int i = 0; i < 11; i++) {
propertyDTOs[i] = new PropertyDTO();
}
propertyDTOs[0].setName("driverName");
propertyDTOs[0].setValue("org.h2.Driver");
propertyDTOs[1].setName("url");
propertyDTOs[1].setValue("jdbc:h2:./repository/database/" + USER_STORE_DB_NAME);
propertyDTOs[2].setName("userName");
propertyDTOs[2].setValue(DB_USER_NAME);
propertyDTOs[3].setName("password");
propertyDTOs[3].setValue(DB_USER_PASSWORD);
propertyDTOs[4].setName("PasswordJavaRegEx");
propertyDTOs[4].setValue("^[\\S]{5,30}$");
propertyDTOs[5].setName("UsernameJavaRegEx");
propertyDTOs[5].setValue("^[\\S]{5,30}$");
propertyDTOs[6].setName("Disabled");
propertyDTOs[6].setValue("false");
propertyDTOs[7].setName("PasswordDigest");
propertyDTOs[7].setValue("SHA-256");
propertyDTOs[8].setName("StoreSaltedPassword");
propertyDTOs[8].setValue("true");
propertyDTOs[9].setName("SCIMEnabled");
propertyDTOs[9].setValue("true");
propertyDTOs[10].setName("UserIDEnabled");
propertyDTOs[10].setValue("true");
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(jdbcClass, DOMAIN_ID, propertyDTOs);
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, DOMAIN_ID);
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project product-is by wso2.
the class UserStoreConfigUtils method waitForUserStoreDeployment.
public boolean waitForUserStoreDeployment(UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient, String domain) throws Exception {
// wait for 45 seconds
long waitTime = System.currentTimeMillis() + 30000;
while (System.currentTimeMillis() < waitTime) {
UserStoreDTO[] userStoreDTOs = userStoreConfigAdminServiceClient.getActiveDomains();
if (userStoreDTOs != null) {
for (UserStoreDTO userStoreDTO : userStoreDTOs) {
if (userStoreDTO != null) {
if (userStoreDTO.getDomainId().equalsIgnoreCase(domain)) {
return true;
}
}
}
}
Thread.sleep(500);
}
return false;
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project product-is by wso2.
the class UserStoreConfigUtils method waitForUserStoreUnDeployment.
public boolean waitForUserStoreUnDeployment(UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient, String domain) throws Exception {
// wait for 15 seconds
long waitTime = System.currentTimeMillis() + 20000;
while (System.currentTimeMillis() < waitTime) {
UserStoreDTO[] userStoreDTOs = userStoreConfigAdminServiceClient.getActiveDomains();
userStoreConfigAdminServiceClient.getActiveDomains();
if (userStoreDTOs != null) {
for (UserStoreDTO userStoreDTO : userStoreDTOs) {
if (userStoreDTO != null && userStoreDTO.getDomainId() != null) {
if (userStoreDTO.getDomainId().equalsIgnoreCase(domain)) {
Thread.sleep(500);
}
}
}
}
}
return true;
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project identity-api-server by wso2.
the class ServerUserStoreService method buildUserStoreListResponse.
/**
* Construct response list with configured user stores details.
*
* @param userStoreDTOS array of UserStoreDTO object.
* @return List<UserStoreListResponse>.
*/
private List<UserStoreListResponse> buildUserStoreListResponse(UserStoreDTO[] userStoreDTOS, String requiredAttributes) {
List<UserStoreListResponse> userStoreListResponseToAdd = new ArrayList<>();
Map<String, Boolean> userStoreManagersType = UserStoreManagerRegistry.getUserStoreManagersType();
if (ArrayUtils.isNotEmpty(userStoreDTOS)) {
for (UserStoreDTO jsonObject : userStoreDTOS) {
UserStoreListResponse userStoreList = new UserStoreListResponse();
userStoreList.setDescription(jsonObject.getDescription());
userStoreList.setName(jsonObject.getDomainId());
userStoreList.setId(base64URLEncodeId(jsonObject.getDomainId()));
userStoreList.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + UserStoreConstants.USER_STORE_PATH_COMPONENT + "/%s", base64URLEncodeId(jsonObject.getDomainId()))).toString());
userStoreList.setEnabled(jsonObject.getDisabled() != null && !jsonObject.getDisabled());
userStoreList.setTypeName(getUserStoreTypeName(jsonObject.getClassName()));
if (StringUtils.isNotBlank(requiredAttributes)) {
String[] requiredAttributesArray = requiredAttributes.split(REGEX_COMMA);
addUserstoreProperties(jsonObject, userStoreList, Arrays.asList(requiredAttributesArray));
}
if (userStoreManagersType.containsKey(jsonObject.getClassName())) {
userStoreList.setIsLocal(userStoreManagersType.get(jsonObject.getClassName()));
}
userStoreListResponseToAdd.add(userStoreList);
}
}
return userStoreListResponseToAdd;
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project identity-api-server by wso2.
the class ServerUserStoreService method buildUserStoreForPatch.
private UserStoreDTO buildUserStoreForPatch(String domainId, List<PatchDocument> patchDocuments) {
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
UserStoreDTO userStoreDTO;
try {
userStoreDTO = userStoreConfigService.getUserStore(base64URLDecodeId(domainId));
if (userStoreDTO == null) {
throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND);
}
PropertyDTO[] propertyDTOS = userStoreDTO.getProperties();
for (PatchDocument patchDocument : patchDocuments) {
String path = patchDocument.getPath();
String value = patchDocument.getValue();
if (StringUtils.isBlank(path)) {
throw handleException(Response.Status.BAD_REQUEST, UserStoreConstants.ErrorMessage.ERROR_CODE_INVALID_INPUT);
}
if (path.startsWith(UserStoreConstants.USER_STORE_PROPERTIES)) {
String propName = extractPropertyName(path);
if (StringUtils.isNotEmpty(propName)) {
for (PropertyDTO propertyDTO : propertyDTOS) {
if (propName.equals(propertyDTO.getName())) {
propertyDTO.setValue(value);
}
}
}
} else if (path.equals(UserStoreConstants.USER_STORE_DESCRIPTION)) {
userStoreDTO.setDescription(value);
} else {
throw handleException(Response.Status.BAD_REQUEST, UserStoreConstants.ErrorMessage.ERROR_CODE_INVALID_INPUT);
}
}
userStoreDTO.setProperties(propertyDTOS);
} catch (IdentityUserStoreMgtException e) {
UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_USER_STORE;
throw handleIdentityUserStoreMgtException(e, errorEnum);
}
return userStoreDTO;
}
Aggregations