Java Code Examples for org.wso2.carbon.user.api.RealmConfiguration#getUserStoreProperties()
The following examples show how to use
org.wso2.carbon.user.api.RealmConfiguration#getUserStoreProperties() .
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: SecondaryUserStoreConfigurationUtil.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
public static Map<String, String> getSecondaryUserStorePropertiesFromTenantUserRealm(String userStoreDomain) throws IdentityUserStoreMgtException { Map<String, String> secondaryUserStoreProperties = null; try { RealmConfiguration realmConfiguration = UserStoreConfigComponent.getRealmService().getTenantUserRealm( getTenantIdInTheCurrentContext()).getRealmConfiguration(); while (realmConfiguration != null) { String domainName = realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig .PROPERTY_DOMAIN_NAME); if (StringUtils.equalsIgnoreCase(domainName, userStoreDomain)) { secondaryUserStoreProperties = realmConfiguration.getUserStoreProperties(); break; } else { realmConfiguration = realmConfiguration.getSecondaryRealmConfig(); } } } catch (UserStoreException e) { String errorMessage = "Error while retrieving user store configurations for user store domain: " + userStoreDomain; throw new IdentityUserStoreMgtException(errorMessage, e); } return secondaryUserStoreProperties; }
Example 2
Source File: DatabaseBasedUserStoreDAOImpl.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
private UserStoreDTO getUserStoreDTO(RealmConfiguration realmConfiguration) { Map<String, String> userStoreProperties = realmConfiguration.getUserStoreProperties(); String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT); if (uuid == null) { uuid = UUID.randomUUID().toString(); } String className = realmConfiguration.getUserStoreClass(); UserStoreDTO userStoreDTO = getUserStoreDTO(realmConfiguration, userStoreProperties); userStoreProperties.put("Class", className); userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid); MaskedProperty[] maskedProperties = setMaskInUserStoreProperties(realmConfiguration, userStoreProperties, ENCRYPTED_PROPERTY_MASK, className); userStoreDTO.setProperties(convertMapToArray(userStoreProperties)); // Now revert back to original password. for (MaskedProperty maskedProperty : maskedProperties) { userStoreProperties.put(maskedProperty.getName(), maskedProperty.getValue()); } return userStoreDTO; }
Example 3
Source File: ServerUserStoreService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * Retrieve primary user store. * * @return UserStoreConfigurationsRes. */ public UserStoreConfigurationsRes getPrimaryUserStore() { if (primaryUserstoreConfigs == null) { RealmService realmService = UserStoreConfigServiceHolder.getInstance().getRealmService(); RealmConfiguration realmConfiguration = realmService.getBootstrapRealmConfiguration(); if (realmConfiguration == null) { throw handleException(Response.Status.INTERNAL_SERVER_ERROR, UserStoreConstants.ErrorMessage. ERROR_CODE_ERROR_RETRIEVING_PRIMARY_USERSTORE); } List<AddUserStorePropertiesRes> propertiesTobeAdd = new ArrayList<>(); primaryUserstoreConfigs = new UserStoreConfigurationsRes(); primaryUserstoreConfigs.setClassName(realmConfiguration.getUserStoreClass()); primaryUserstoreConfigs.setDescription(realmConfiguration.getDescription()); primaryUserstoreConfigs.setName(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME); primaryUserstoreConfigs.setTypeId(base64URLEncodeId(Objects.requireNonNull (getUserStoreTypeName(realmConfiguration.getUserStoreClass())))); primaryUserstoreConfigs.setTypeName(getUserStoreTypeName(realmConfiguration.getUserStoreClass())); Map<String, String> userstoreProps = realmConfiguration.getUserStoreProperties(); if (MapUtils.isNotEmpty(userstoreProps)) { for (String propKey : userstoreProps.keySet()) { AddUserStorePropertiesRes userStorePropertiesRes = new AddUserStorePropertiesRes(); userStorePropertiesRes.setName(propKey); userStorePropertiesRes.setValue(userstoreProps.get(propKey)); propertiesTobeAdd.add(userStorePropertiesRes); } } primaryUserstoreConfigs.setProperties(propertiesTobeAdd); } return primaryUserstoreConfigs; }
Example 4
Source File: FileBasedUserStoreDAOImpl.java From carbon-identity-framework with Apache License 2.0 | 4 votes |
@Override public UserStoreDTO[] getUserStores() throws IdentityUserStoreMgtException { RealmConfiguration secondaryRealmConfiguration; List<UserStoreDTO> domains = new ArrayList<>(); try { secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm(). getRealmConfiguration().getSecondaryRealmConfig(); } catch (UserStoreException e) { String errorMessage = "Error while retrieving user store configurations"; throw new IdentityUserStoreMgtException(errorMessage); } if (secondaryRealmConfiguration == null) { if (log.isDebugEnabled()) { log.debug("SecondaryRealmConfiguration is null. Can not find any userStore."); } return new UserStoreDTO[0]; } else { do { Map<String, String> userStoreProperties = secondaryRealmConfiguration.getUserStoreProperties(); String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT); if (uuid == null) { uuid = UUID.randomUUID().toString(); } String className = secondaryRealmConfiguration.getUserStoreClass(); UserStoreDTO userStoreDTO = getUserStoreDTO(secondaryRealmConfiguration, userStoreProperties); userStoreProperties.put("Class", className); userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid); MaskedProperty[] maskedProperties = setMaskInUserStoreProperties(secondaryRealmConfiguration, userStoreProperties, ENCRYPTED_PROPERTY_MASK, className); userStoreDTO.setProperties(convertMapToArray(userStoreProperties)); // Now revert back to original password. for (MaskedProperty maskedProperty : maskedProperties) { userStoreProperties.put(maskedProperty.getName(), maskedProperty.getValue()); } domains.add(userStoreDTO); secondaryRealmConfiguration = secondaryRealmConfiguration.getSecondaryRealmConfig(); } while (secondaryRealmConfiguration != null); } return domains.toArray(new UserStoreDTO[domains.size()]); }
Example 5
Source File: FileBasedUserStoreDAOImpl.java From carbon-identity-framework with Apache License 2.0 | 4 votes |
@Override protected UserStorePersistanceDTO[] doGetAllUserStores() throws IdentityUserStoreMgtException { RealmConfiguration secondaryRealmConfiguration; List<UserStorePersistanceDTO> userStorePersistanceDAOList = new ArrayList<>(); UserStorePersistanceDTO userStorePersistanceDTO = new UserStorePersistanceDTO(); try { secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm(). getRealmConfiguration().getSecondaryRealmConfig(); } catch (UserStoreException e) { String errorMessage = "Error while retrieving user store configurations"; throw new IdentityUserStoreMgtException(errorMessage); } if (secondaryRealmConfiguration == null) { if (log.isDebugEnabled()) { log.debug("SecondaryRealmConfiguration is null. Can not find any userStore."); } return new UserStorePersistanceDTO[0]; } else { do { Map<String, String> userStoreProperties = secondaryRealmConfiguration.getUserStoreProperties(); String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT); if (uuid == null) { uuid = UUID.randomUUID().toString(); } String className = secondaryRealmConfiguration.getUserStoreClass(); UserStoreDTO userStoreDTO = getUserStoreDTO(secondaryRealmConfiguration, userStoreProperties); userStoreProperties.put("Class", className); userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid); MaskedProperty[] maskedProperties = setMaskInUserStoreProperties(secondaryRealmConfiguration, userStoreProperties, ENCRYPTED_PROPERTY_MASK, className); userStoreDTO.setProperties(convertMapToArray(userStoreProperties)); // Now revert back to original password. for (MaskedProperty maskedProperty : maskedProperties) { userStoreProperties.put(maskedProperty.getName(), maskedProperty.getValue()); } userStorePersistanceDTO.setUserStoreDTO(userStoreDTO); userStorePersistanceDAOList.add(userStorePersistanceDTO); secondaryRealmConfiguration = secondaryRealmConfiguration.getSecondaryRealmConfig(); } while (secondaryRealmConfiguration != null); } return userStorePersistanceDAOList.toArray(new UserStorePersistanceDTO[userStorePersistanceDAOList.size()]); }
Example 6
Source File: UserStoreConfigAdminService.java From carbon-identity with Apache License 2.0 | 4 votes |
/** * Get details of current secondary user store configurations * * @return : Details of all the configured secondary user stores * @throws UserStoreException */ public UserStoreDTO[] getSecondaryRealmConfigurations() throws IdentityUserStoreMgtException { ArrayList<UserStoreDTO> domains = new ArrayList<UserStoreDTO>(); RealmConfiguration secondaryRealmConfiguration = null; try { secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm(). getRealmConfiguration().getSecondaryRealmConfig(); } catch (UserStoreException e) { String errorMessage = "Error while retrieving user store configurations"; log.error(errorMessage, e); throw new IdentityUserStoreMgtException(errorMessage); } //not editing primary store if (secondaryRealmConfiguration == null) { return null; } else { do { Map<String, String> userStoreProperties = secondaryRealmConfiguration.getUserStoreProperties(); UserStoreDTO userStoreDTO = new UserStoreDTO(); String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT); if (uuid == null) { uuid = UUID.randomUUID().toString(); } String randomPhrase = UserStoreConfigurationConstant.RANDOM_PHRASE_PREFIX + uuid; String className = secondaryRealmConfiguration.getUserStoreClass(); userStoreDTO.setClassName(secondaryRealmConfiguration.getUserStoreClass()); userStoreDTO.setDescription(secondaryRealmConfiguration.getUserStoreProperty(DESCRIPTION)); userStoreDTO.setDomainId(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigConstants.DOMAIN_NAME)); if (userStoreProperties.get(DISABLED) != null) { userStoreDTO.setDisabled(Boolean.valueOf(userStoreProperties.get(DISABLED))); } userStoreProperties.put("Class", className); userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid); RandomPassword[] randomPasswords = getRandomPasswordProperties(className, randomPhrase, secondaryRealmConfiguration); if (randomPasswords != null) { updatePasswordContainer(randomPasswords, uuid); } String originalPassword = null; if (userStoreProperties.containsKey(UserStoreConfigConstants.connectionPassword)) { originalPassword = userStoreProperties.get(UserStoreConfigConstants.connectionPassword); userStoreProperties.put(UserStoreConfigConstants.connectionPassword, randomPhrase); } if (userStoreProperties.containsKey(JDBCRealmConstants.PASSWORD)) { originalPassword = userStoreProperties.get(JDBCRealmConstants.PASSWORD); userStoreProperties.put(JDBCRealmConstants.PASSWORD, randomPhrase); } userStoreDTO.setProperties(convertMapToArray(userStoreProperties)); //Now revert back to original password if (userStoreProperties.containsKey(UserStoreConfigConstants.connectionPassword)) { if (originalPassword != null) { userStoreProperties.put(UserStoreConfigConstants.connectionPassword, originalPassword); } } if (userStoreProperties.containsKey(JDBCRealmConstants.PASSWORD)) { if (originalPassword != null) { userStoreProperties.put(JDBCRealmConstants.PASSWORD, originalPassword); } } domains.add(userStoreDTO); secondaryRealmConfiguration = secondaryRealmConfiguration.getSecondaryRealmConfig(); } while (secondaryRealmConfiguration != null); } return domains.toArray(new UserStoreDTO[domains.size()]); }