Java Code Examples for org.wso2.carbon.user.api.RealmConfiguration#getUserStoreClass()
The following examples show how to use
org.wso2.carbon.user.api.RealmConfiguration#getUserStoreClass() .
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: 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 2
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 3
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 4
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()]); }