use of org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty in project carbon-identity-framework by wso2.
the class FileBasedUserStoreDAOImpl method getUserStores.
@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()]);
}
use of org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty in project carbon-identity-framework by wso2.
the class SecondaryUserStoreConfigurationUtil method getMaskedProperties.
private static MaskedProperty[] getMaskedProperties(String userStoreClass, String maskValue, RealmConfiguration secondaryRealmConfiguration) {
// First check for mandatory field with #encrypt
Property[] mandatoryProperties = getMandatoryProperties(userStoreClass);
ArrayList<MaskedProperty> maskedProperties = new ArrayList<>();
for (Property property : mandatoryProperties) {
String propertyName = property.getName();
if (property.getDescription().contains(UserStoreConfigurationConstant.ENCRYPT_TEXT)) {
MaskedProperty maskedProperty = new MaskedProperty();
maskedProperty.setName(propertyName);
maskedProperty.setValue(secondaryRealmConfiguration.getUserStoreProperty(propertyName));
maskedProperty.setMask(maskValue);
maskedProperties.add(maskedProperty);
}
}
return maskedProperties.toArray(new MaskedProperty[0]);
}
use of org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty in project carbon-identity-framework by wso2.
the class DatabaseBasedUserStoreDAOImpl method getUserStoreDTO.
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;
}
use of org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty in project carbon-identity-framework by wso2.
the class FileBasedUserStoreDAOImpl method doGetAllUserStores.
@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()]);
}
Aggregations