| | |
| | | import java.text.MessageFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Collection;
|
| | | import java.util.Collections;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | |
| | | private static final String DISPLAYNAME = "displayName";
|
| | |
|
| | | private static final String EMAILADDRESS = "emailAddress";
|
| | | |
| | | private static final String ORGANIZATIONALUNIT = "organizationalUnit";
|
| | | |
| | | private static final String ORGANIZATION = "organization";
|
| | | |
| | | private static final String LOCALITY = "locality";
|
| | | |
| | | private static final String STATEPROVINCE = "stateProvince";
|
| | | |
| | | private static final String COUNTRYCODE = "countryCode";
|
| | |
|
| | | private static final String COOKIE = "cookie";
|
| | |
|
| | |
| | | * @since 1.2.0
|
| | | */
|
| | | @Override
|
| | | public boolean updateUserModels(List<UserModel> models) {
|
| | | public boolean updateUserModels(Collection<UserModel> models) {
|
| | | try {
|
| | | read();
|
| | | for (UserModel model : models) {
|
| | |
| | | // Read realm file
|
| | | read();
|
| | | UserModel model = users.remove(username.toLowerCase());
|
| | | if (model == null) {
|
| | | // user does not exist
|
| | | return false;
|
| | | }
|
| | | // remove user from team
|
| | | for (TeamModel team : model.teams) {
|
| | | TeamModel t = teams.get(team.name);
|
| | |
| | | * @since 1.2.0
|
| | | */
|
| | | @Override
|
| | | public boolean updateTeamModels(List<TeamModel> models) {
|
| | | public boolean updateTeamModels(Collection<TeamModel> models) {
|
| | | try {
|
| | | read();
|
| | | for (TeamModel team : models) {
|
| | |
| | | /**
|
| | | * Writes the properties file.
|
| | | *
|
| | | * @param properties
|
| | | * @throws IOException
|
| | | */
|
| | | private synchronized void write() throws IOException {
|
| | |
| | | }
|
| | | if (!StringUtils.isEmpty(model.emailAddress)) {
|
| | | config.setString(USER, model.username, EMAILADDRESS, model.emailAddress);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.organizationalUnit)) {
|
| | | config.setString(USER, model.username, ORGANIZATIONALUNIT, model.organizationalUnit);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.organization)) {
|
| | | config.setString(USER, model.username, ORGANIZATION, model.organization);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.locality)) {
|
| | | config.setString(USER, model.username, LOCALITY, model.locality);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.stateProvince)) {
|
| | | config.setString(USER, model.username, STATEPROVINCE, model.stateProvince);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.countryCode)) {
|
| | | config.setString(USER, model.username, COUNTRYCODE, model.countryCode);
|
| | | }
|
| | |
|
| | | // user roles
|
| | |
| | | user.password = config.getString(USER, username, PASSWORD);
|
| | | user.displayName = config.getString(USER, username, DISPLAYNAME);
|
| | | user.emailAddress = config.getString(USER, username, EMAILADDRESS);
|
| | | user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT);
|
| | | user.organization = config.getString(USER, username, ORGANIZATION);
|
| | | user.locality = config.getString(USER, username, LOCALITY);
|
| | | user.stateProvince = config.getString(USER, username, STATEPROVINCE);
|
| | | user.countryCode = config.getString(USER, username, COUNTRYCODE);
|
| | | user.cookie = config.getString(USER, username, COOKIE);
|
| | | if (StringUtils.isEmpty(user.cookie) && !StringUtils.isEmpty(user.password)) {
|
| | | user.cookie = StringUtils.getSHA1(user.username + user.password);
|