use of org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreListResponse in project product-is by wso2.
the class UserStoreSuccessTest method testGetUserStore.
@Test(dependsOnMethods = { "testGetSecondaryUserStoreByDomainId" })
public void testGetUserStore() throws IOException {
String expectedResponse = readResource("get-user-store-response.json");
ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
List<UserStoreListResponse> userStoreListResponseList = Arrays.asList(jsonWriter.readValue(expectedResponse, UserStoreListResponse[].class));
Map<String, UserStoreListResponse> userStoreListResMap = userStoreListResponseList.stream().collect(Collectors.toMap(UserStoreListResponse::getId, c -> c));
Response response = getResponseOfGet(USER_STORE_PATH_COMPONENT);
ValidatableResponse validatableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK);
for (Map.Entry<String, UserStoreListResponse> resEntry : userStoreListResMap.entrySet()) {
validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.name", equalTo(resEntry.getValue().getName()));
validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.description", equalTo(resEntry.getValue().getDescription()));
validatableResponse.body("find{ it.id == '" + resEntry.getKey() + "' }.self", equalTo("/t/" + tenant + "/api/server/v1" + USER_STORE_PATH_COMPONENT + PATH_SEPARATOR + resEntry.getValue().getId()));
}
}
use of org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreListResponse in project identity-api-server by wso2.
the class ServerUserStoreService method getUserStoreList.
/**
* To retrieve the configured user store lists.
*
* @param limit items per page.
* @param offset 0 based index to get the results starting from this index + 1.
* @param filter to specify the filtering capabilities.
* @param sort to specify the sorting order.
* @return List<UserStoreListResponse>.
*/
public List<UserStoreListResponse> getUserStoreList(Integer limit, Integer offset, String filter, String sort, String requiredAttributes) {
handleNotImplementedBehaviour(limit, offset, filter, sort);
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
try {
UserStoreDTO[] userStoreDTOS = userStoreConfigService.getUserStores();
return buildUserStoreListResponse(userStoreDTOS, requiredAttributes);
} catch (IdentityUserStoreMgtException e) {
UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE;
throw handleIdentityUserStoreMgtException(e, errorEnum);
}
}
use of org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreListResponse 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);
}
}
}
use of org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreListResponse 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;
}
Aggregations