use of org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService 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.user.store.configuration.UserStoreConfigService in project identity-api-server by wso2.
the class ServerUserStoreService method getUserStoreAttributeMappings.
/**
* Get user store attributes mappings for a given user store type id.
*
* @param typeId String user store type id.
* @param includeIdentityClaimMappings Whether to include claim mapping for identity claims with other userstore.
* attributes.
* @return UserStoreAttributeMapping user store attribute mappings.
*/
public UserStoreAttributeMappingResponse getUserStoreAttributeMappings(String typeId, boolean includeIdentityClaimMappings) {
Set<String> classNames;
String userStoreName = getUserStoreType(base64URLDecodeId(typeId));
if (StringUtils.isBlank(userStoreName)) {
throw handleException(Response.Status.BAD_REQUEST, UserStoreConstants.ErrorMessage.ERROR_CODE_INVALID_INPUT);
}
try {
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
classNames = userStoreConfigService.getAvailableUserStoreClasses();
if (CollectionUtils.isEmpty(classNames) || !classNames.contains(userStoreName)) {
throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND);
}
} catch (IdentityUserStoreMgtException e) {
UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE;
throw handleIdentityUserStoreMgtException(e, errorEnum);
}
UserStoreAttributeMappingResponse userStoreAttributeMappingResponse = new UserStoreAttributeMappingResponse();
List<UserStoreAttribute> attributeMappings = getAttributeMappings(userStoreName, includeIdentityClaimMappings);
userStoreAttributeMappingResponse = userStoreAttributeMappingResponse.attributeMappings(new AttributeMappingsToApiModel().apply(attributeMappings)).typeId(typeId).typeName(userStoreName);
try {
boolean isLocal = UserStoreManagerRegistry.isLocalUserStore(userStoreName);
userStoreAttributeMappingResponse.setIsLocal(isLocal);
} catch (UserStoreException e) {
LOG.error(String.format("Userstore type is not found for %s", userStoreName), e);
}
return userStoreAttributeMappingResponse;
}
use of org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService in project identity-api-server by wso2.
the class ServerUserStoreService method testRDBMSConnection.
/**
* Check the connection heath for JDBC userstores.
*
* @param rdBMSConnectionReq {@link RDBMSConnectionReq}.
* @return ConnectionEstablishedResponse.
*/
public ConnectionEstablishedResponse testRDBMSConnection(RDBMSConnectionReq rdBMSConnectionReq) {
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
ConnectionEstablishedResponse connectionEstablishedResponse = new ConnectionEstablishedResponse();
boolean isConnectionEstablished;
connectionEstablishedResponse.setConnection(false);
try {
isConnectionEstablished = userStoreConfigService.testRDBMSConnection(rdBMSConnectionReq.getDomain(), rdBMSConnectionReq.getDriverName(), rdBMSConnectionReq.getConnectionURL(), rdBMSConnectionReq.getUsername(), rdBMSConnectionReq.getConnectionPassword(), DUMMY_MESSAGE_ID);
if (isConnectionEstablished) {
connectionEstablishedResponse.setConnection(true);
}
} catch (IdentityUserStoreMgtException e) {
connectionEstablishedResponse.setConnection(false);
}
return connectionEstablishedResponse;
}
use of org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService in project identity-api-server by wso2.
the class ServerUserStoreService method deleteUserStore.
/**
* Delete a userStore by its domainId.
*
* @param userstoreDomainId base64 encoded url value of userStore domain Id.
*/
public void deleteUserStore(String userstoreDomainId) {
try {
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
userStoreConfigService.deleteUserStore(base64URLDecodeId(userstoreDomainId));
} catch (IdentityUserStoreClientException e) {
if (LOG.isDebugEnabled()) {
LOG.debug(e);
}
} catch (IdentityUserStoreMgtException e) {
UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_DELETING_USER_STORE;
throw handleIdentityUserStoreMgtException(e, errorEnum);
}
}
use of org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService 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);
}
}
Aggregations