use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project product-is by wso2.
the class SCIMUtils method createSecondaryUserStore.
/**
* Create a secondary user store.
*
* @param userStoreType User store type.
* @param userStoreDomain User store domain.
* @param userStoreProperties Configuration properties for the user store.
* @param backendURL Backend URL of the Identity Server.
* @param sessionCookie Session Cookie.
* @throws Exception Thrown if the user store creation fails.
*/
public static void createSecondaryUserStore(String userStoreType, String userStoreDomain, PropertyDTO[] userStoreProperties, String backendURL, String sessionCookie) throws Exception {
UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient = new UserStoreConfigAdminServiceClient(backendURL, sessionCookie);
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(userStoreType, userStoreDomain, userStoreProperties);
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
Assert.assertTrue(userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, userStoreDomain), "Domain addition via DTO has failed.");
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO 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.identity.user.store.configuration.stub.dto.PropertyDTO in project identity-api-server by wso2.
the class ServerUserStoreService method getUserStoreByDomainId.
/**
* Retrieve user store by its domain id.
*
* @param domainId the user store domain id.
* @return UserStoreConfigurationsRes.
*/
public UserStoreConfigurationsRes getUserStoreByDomainId(String domainId) {
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
List<AddUserStorePropertiesRes> propertiesTobeAdd = new ArrayList<>();
try {
UserStoreDTO userStoreDTO = userStoreConfigService.getUserStore(base64URLDecodeId(domainId));
if (userStoreDTO == null) {
throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND);
}
List<ClaimAttributeMapping> claimAttributeMappings = getClaimAttributeMappings(ContextLoader.getTenantDomainFromContext(), base64URLDecodeId(domainId));
UserStoreConfigurationsRes userStoreConfigurations = new UserStoreConfigurationsRes();
userStoreConfigurations.setClassName(userStoreDTO.getClassName());
userStoreConfigurations.setDescription(userStoreDTO.getDescription());
userStoreConfigurations.setName(userStoreDTO.getDomainId());
userStoreConfigurations.setTypeId(base64URLEncodeId(Objects.requireNonNull(getUserStoreTypeName(userStoreDTO.getClassName()))));
userStoreConfigurations.setTypeName(getUserStoreTypeName(userStoreDTO.getClassName()));
PropertyDTO[] dtoProperties = userStoreDTO.getProperties();
for (PropertyDTO propertyDTO : dtoProperties) {
AddUserStorePropertiesRes userStorePropertiesRes = new AddUserStorePropertiesRes();
userStorePropertiesRes.setName(propertyDTO.getName());
userStorePropertiesRes.setValue(propertyDTO.getValue());
propertiesTobeAdd.add(userStorePropertiesRes);
}
userStoreConfigurations.setProperties(propertiesTobeAdd);
try {
userStoreConfigurations.setIsLocal(UserStoreManagerRegistry.isLocalUserStore(userStoreDTO.getClassName()));
userStoreConfigurations.setClaimAttributeMappings(claimAttributeMappings);
} catch (UserStoreException e) {
LOG.error(String.format("Cannot found user store manager type for user store manager: %s", getUserStoreType(userStoreDTO.getClassName())), e);
}
return userStoreConfigurations;
} catch (IdentityUserStoreMgtException e) {
UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE_BY_DOMAIN_ID;
throw handleIdentityUserStoreMgtException(e, errorEnum);
}
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project identity-api-server by wso2.
the class ServerUserStoreService method buildResponseForPatchReplace.
/**
* Construct the response for patch replace.
*
* @param userStoreDTO {@link UserStoreDTO}.
* @param propertyDTOS array of {@link PropertyDTO}.
* @return UserStoreResponse.
*/
private UserStoreResponse buildResponseForPatchReplace(UserStoreDTO userStoreDTO, PropertyDTO[] propertyDTOS) {
UserStoreResponse userStoreResponseDTO = new UserStoreResponse();
userStoreResponseDTO.setId((base64URLEncodeId(userStoreDTO.getDomainId())));
userStoreResponseDTO.setName(userStoreDTO.getDomainId());
userStoreResponseDTO.setTypeId(base64URLEncodeId(Objects.requireNonNull(getUserStoreTypeName(userStoreDTO.getClassName()))));
userStoreResponseDTO.setTypeName(getUserStoreTypeName(userStoreDTO.getClassName()));
userStoreResponseDTO.setDescription(userStoreDTO.getDescription());
userStoreResponseDTO.setProperties(patchUserStoreProperties(propertyDTOS));
return userStoreResponseDTO;
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project identity-api-server by wso2.
the class ServerUserStoreService method addUserstoreProperties.
/**
* Add requested user store properties to the response.
*
* @param userStoreDTO userStoreDTO object.
* @param userStoreListResponse userStoreListResponse object.
* @param requestedAttributesList Requested user store properties name list.
*/
private void addUserstoreProperties(UserStoreDTO userStoreDTO, UserStoreListResponse userStoreListResponse, List<String> requestedAttributesList) {
for (PropertyDTO propertyDTO : userStoreDTO.getProperties()) {
if (requestedAttributesList.contains(propertyDTO.getName()) && StringUtils.isNotBlank(propertyDTO.getValue())) {
AddUserStorePropertiesRes addUserStorePropertiesRes = new AddUserStorePropertiesRes();
addUserStorePropertiesRes.setName(propertyDTO.getName());
addUserStorePropertiesRes.setValue(propertyDTO.getValue());
userStoreListResponse.addPropertiesItem(addUserStorePropertiesRes);
}
}
}
Aggregations