use of org.wso2.broker.core.security.authentication.user.UsersFile in project carbon-apimgt by wso2.
the class BrokerManager method loadUsers.
/**
* Loads the users from users.yaml during broker startup
*/
private static void loadUsers() throws ConfigurationException {
Path usersYamlFile;
String usersFilePath = System.getProperty(BrokerSecurityConstants.SYSTEM_PARAM_USERS_CONFIG);
if (usersFilePath == null || usersFilePath.trim().isEmpty()) {
// use current path.
usersYamlFile = Paths.get("", BrokerSecurityConstants.USERS_FILE_NAME).toAbsolutePath();
} else {
usersYamlFile = Paths.get(usersFilePath).toAbsolutePath();
}
ConfigProvider configProvider = ConfigProviderFactory.getConfigProvider(usersYamlFile, null);
UsersFile usersFile = configProvider.getConfigurationObject(BrokerSecurityConstants.USERS_CONFIG_NAMESPACE, UsersFile.class);
if (usersFile != null) {
List<User> users = usersFile.getUsers();
for (User user : users) {
UserStoreManager.addUser(user);
}
}
}
Aggregations