org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO Java Examples
The following examples show how to use
org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractUserStoreDAO.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
private UserStoreDTO getUserStoreProperty(UserStoreDTO userStoreDTO) throws IdentityUserStoreMgtException { boolean newState = userStoreDTO.getDisabled(); UserStoreDTO userStoreDTOTemp = getUserStore(userStoreDTO.getDomainId()); if (userStoreDTOTemp != null) { userStoreDTO = userStoreDTOTemp; userStoreDTO.setDisabled(newState); PropertyDTO[] propertyDTO = userStoreDTO.getProperties(); for (PropertyDTO propertyDTOValue : propertyDTO) { if (propertyDTOValue.getName().equals(DISABLED)) { propertyDTOValue.setValue(String.valueOf(newState)); } } } return userStoreDTO; }
Example #2
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * 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); } 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); return userStoreConfigurations; } catch (IdentityUserStoreMgtException e) { UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE_BY_DOMAIN_ID; throw handleIdentityUserStoreMgtException(e, errorEnum); } }
Example #3
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * To handle the patch REPLACE request. * * @param domainId user store domain id. * @param path patch operation path * @param value property value * @return UserStoreResponse */ private UserStoreResponse performPatchReplace(String domainId, String path, String value) { UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance() .getUserStoreConfigService(); try { UserStoreDTO userStoreDTO = userStoreConfigService.getUserStore(base64URLDecodeId(domainId)); if (userStoreDTO == null) { throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND); } if (StringUtils.isBlank(path)) { throw handleException(Response.Status.BAD_REQUEST, UserStoreConstants.ErrorMessage .ERROR_CODE_INVALID_INPUT); } PropertyDTO[] propertyDTOS = userStoreDTO.getProperties(); if (path.startsWith(UserStoreConstants.USER_STORE_PROPERTIES)) { String[] propertiesList = path.split("/"); for (PropertyDTO propertyDTO : propertyDTOS) { if (propertiesList[2].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); userStoreConfigService.updateUserStore(userStoreDTO, false); return buildResponseForPatchReplace(userStoreDTO, propertyDTOS); } catch (IdentityUserStoreMgtException e) { UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_USER_STORE; throw handleIdentityUserStoreMgtException(e, errorEnum); } }
Example #4
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * 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; }
Example #5
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * 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); } } }
Example #6
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * Construct PropertyDTO array for POST request. * * @param userStoreReq {@link UserStoreReq}. * @return PropertyDTO[]. */ private PropertyDTO[] createPropertyListDTO(UserStoreReq userStoreReq) { List<org.wso2.carbon.identity.api.server.userstore.v1.model.Property> values = userStoreReq.getProperties(); ArrayList<PropertyDTO> propertiesToAdd = new ArrayList<>(); for (org.wso2.carbon.identity.api.server.userstore.v1.model.Property value : values) { PropertyDTO propertyDTO = new PropertyDTO(); propertyDTO.setName(value.getName()); propertyDTO.setValue(value.getValue()); propertiesToAdd.add(propertyDTO); } return generatePropertiesWithUniqueIDProperty (propertiesToAdd); }
Example #7
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * Construct PropertyDTO array with UniqueID. * * @param propertiesToAdd Array list of properties. * @return PropertyDTO[]. */ private PropertyDTO[] generatePropertiesWithUniqueIDProperty(ArrayList<PropertyDTO> propertiesToAdd) { PropertyDTO propertyDTO = new PropertyDTO(); propertyDTO.setName("UniqueID"); propertyDTO.setValue(UUID.randomUUID().toString()); propertiesToAdd.add(propertyDTO); return propertiesToAdd.toArray(new PropertyDTO[0]); }
Example #8
Source File: SecondaryUserStoreConfigurationUtil.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * Obtain the UniqueID ID constant value from the propertyDTO object which was set well * before sending the edit request. * * @param propertyDTOs PropertyDTO[] object passed from JSP page * @return unique id string value */ private static String getUniqueIDFromUserDTO(PropertyDTO[] propertyDTOs) { int length = propertyDTOs.length; for (int i = length - 1; i >= 0; i--) { PropertyDTO propertyDTO = propertyDTOs[i]; if (propertyDTO != null && propertyDTO.getName() != null && propertyDTO.getName() .equalsIgnoreCase(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT)) { return propertyDTO.getValue(); } } return null; }
Example #9
Source File: SecondaryUserStoreConfigurationUtil.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * To convert user store properties map to an array. * @param properties user store properties map * @return userstore properties array */ public static PropertyDTO[] convertMapToArray(Map<String, String> properties) { Set<Map.Entry<String, String>> propertyEntries = properties.entrySet(); ArrayList<PropertyDTO> propertiesList = new ArrayList<PropertyDTO>(); String key; String value; for (Map.Entry<String, String> entry : propertyEntries) { key = (String) entry.getKey(); value = (String) entry.getValue(); PropertyDTO propertyDTO = new PropertyDTO(key, value); propertiesList.add(propertyDTO); } return propertiesList.toArray(new PropertyDTO[propertiesList.size()]); }
Example #10
Source File: UserStoreConfigAdminService.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * Get user store properties of a given active user store manager as an array * * @param properties: properties of the user store * @return key#value */ private PropertyDTO[] convertMapToArray(Map<String, String> properties) { Set<Map.Entry<String, String>> propertyEntries = properties.entrySet(); ArrayList<PropertyDTO> propertiesList = new ArrayList<PropertyDTO>(); String key; String value; for (Map.Entry<String, String> entry : propertyEntries) { key = (String) entry.getKey(); value = (String) entry.getValue(); PropertyDTO propertyDTO = new PropertyDTO(key, value); propertiesList.add(propertyDTO); } return propertiesList.toArray(new PropertyDTO[propertiesList.size()]); }
Example #11
Source File: UserStoreConfigAdminService.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * Obtain the UniqueID ID constant value from the propertyDTO object which was set well * before sending the edit request. * * @param propertyDTOs PropertyDTO[] object passed from JSP page * @return unique id string value */ private String getUniqueIDFromUserDTO(PropertyDTO[] propertyDTOs) { int length = propertyDTOs.length; for (int i = length - 1; i >= 0; i--) { PropertyDTO propertyDTO = propertyDTOs[i]; if (propertyDTO != null && propertyDTO.getName() != null && propertyDTO.getName() .equalsIgnoreCase(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT)) { return propertyDTO.getValue(); } } return null; }
Example #12
Source File: SecondaryUserStoreConfigurationUtil.java From carbon-identity-framework with Apache License 2.0 | 4 votes |
/** * Adds an array of properties * * @param propertyDTOs List of user store properties * @param doc Document * @param parent Parent element of the properties to be added */ private static void addProperties(String userStoreDomain, String userStoreClass, PropertyDTO[] propertyDTOs, Document doc, Element parent, boolean editSecondaryUserStore) throws IdentityUserStoreMgtException { if (editSecondaryUserStore) { String uniqueID = getUniqueIDFromUserDTO(propertyDTOs); if (uniqueID == null) { throw new IdentityUserStoreMgtException("UniqueID property is not provided."); } } //First check for mandatory field with #encrypt Property[] mandatoryProperties = getMandatoryProperties(userStoreClass); Map<String, String> secondaryUserStoreProperties = getSecondaryUserStorePropertiesFromTenantUserRealm(userStoreDomain); for (PropertyDTO propertyDTO : propertyDTOs) { String propertyDTOName = propertyDTO.getName(); if (UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT.equalsIgnoreCase(propertyDTOName)) { continue; } String propertyDTOValue = propertyDTO.getValue(); if (propertyDTOValue != null) { boolean encrypted = false; if (isPropertyToBeEncrypted(mandatoryProperties, propertyDTOName)) { propertyDTOValue = getPropertyValueIfMasked(secondaryUserStoreProperties, propertyDTOName, propertyDTOValue); try { propertyDTOValue = SecondaryUserStoreConfigurationUtil.encryptPlainText(propertyDTOValue); encrypted = true; } catch (IdentityUserStoreMgtException e) { LOG.error("addProperties failed to encrypt", e); //its ok to continue from here } } addProperty(propertyDTOName, propertyDTOValue, doc, parent, encrypted); } } }
Example #13
Source File: UserStoreConfigAdminService.java From carbon-identity with Apache License 2.0 | 4 votes |
/** * Adds an array of properties * * @param propertyDTOs : List of user store properties * @param doc: Document * @param parent : Parent element of the properties to be added */ private void addProperties(String userStoreClass, PropertyDTO[] propertyDTOs, Document doc, Element parent, boolean editSecondaryUserStore) throws IdentityUserStoreMgtException { RandomPasswordContainer randomPasswordContainer = null; if (editSecondaryUserStore) { String uniqueID = getUniqueIDFromUserDTO(propertyDTOs); randomPasswordContainer = getAndRemoveRandomPasswordContainer(uniqueID); if (randomPasswordContainer == null) { String errorMsg = "randomPasswordContainer is null for uniqueID therefore " + "proceeding without encryption=" + uniqueID; log.error(errorMsg);//need this error log to further identify the reason for throwing this exception throw new IdentityUserStoreMgtException("Longer delay causes the edit operation be to " + "abandoned"); } } //First check for mandatory field with #encrypt Property[] mandatoryProperties = getMandatoryProperties(userStoreClass); for (PropertyDTO propertyDTO : propertyDTOs) { String propertyDTOName = propertyDTO.getName(); if (UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT.equalsIgnoreCase(propertyDTOName)) { continue; } String propertyDTOValue = propertyDTO.getValue(); if (propertyDTOValue != null) { boolean encrypted = false; if (isPropertyToBeEncrypted(mandatoryProperties, propertyDTOName)) { if (randomPasswordContainer != null) { RandomPassword randomPassword = getRandomPassword(randomPasswordContainer, propertyDTOName); if (randomPassword != null) { if (propertyDTOValue.equalsIgnoreCase(randomPassword.getRandomPhrase())) { propertyDTOValue = randomPassword.getPassword(); } } } try { propertyDTOValue = SecondaryUserStoreConfigurationUtil.encryptPlainText(propertyDTOValue); encrypted = true; } catch (IdentityUserStoreMgtException e) { log.error("addProperties failed to encrypt", e); //its ok to continue from here } } addProperty(propertyDTOName, propertyDTOValue, doc, parent, encrypted); } } }