| | |
| | | }
|
| | |
|
| | | /**
|
| | | * Setup the user service.
|
| | | * |
| | | * @param settings
|
| | | * @since 0.6.1
|
| | | */
|
| | | @Override
|
| | | public void setup(IStoredSettings settings) {
|
| | | }
|
| | |
|
| | | /**
|
| | | * Does the user service support cookie authentication?
|
| | | *
|
| | | * @return true or false
|
| | |
| | | UserModel returnedUser = null;
|
| | | UserModel user = getUserModel(username);
|
| | | if (user.password.startsWith(StringUtils.MD5_TYPE)) {
|
| | | // password digest
|
| | | String md5 = StringUtils.MD5_TYPE + StringUtils.getMD5(new String(password));
|
| | | if (user.password.equalsIgnoreCase(md5)) {
|
| | | returnedUser = user;
|
| | | }
|
| | | } else if (user.password.startsWith(StringUtils.COMBINED_MD5_TYPE)) {
|
| | | // username+password digest
|
| | | String md5 = StringUtils.COMBINED_MD5_TYPE
|
| | | + StringUtils.getMD5(username.toLowerCase() + new String(password));
|
| | | if (user.password.equalsIgnoreCase(md5)) {
|
| | | returnedUser = user;
|
| | | }
|
| | | } else if (user.password.equals(new String(password))) {
|
| | | // plain-text password
|
| | | returnedUser = user;
|
| | | }
|
| | | return returnedUser;
|
| | |
| | | // Permissions
|
| | | if (role.equalsIgnoreCase(Constants.ADMIN_ROLE)) {
|
| | | model.canAdmin = true;
|
| | | } else if (role.equalsIgnoreCase(Constants.NOT_FEDERATED_ROLE)) {
|
| | | model.excludeFromFederation = true;
|
| | | }
|
| | | break;
|
| | | default:
|
| | |
| | | // Permissions
|
| | | if (model.canAdmin) {
|
| | | roles.add(Constants.ADMIN_ROLE);
|
| | | }
|
| | | if (model.excludeFromFederation) {
|
| | | roles.add(Constants.NOT_FEDERATED_ROLE);
|
| | | }
|
| | |
|
| | | StringBuilder sb = new StringBuilder();
|
| | |
| | | // If the write is successful, delete the current file and rename
|
| | | // the temporary copy to the original filename.
|
| | | if (realmFileCopy.exists() && realmFileCopy.length() > 0) {
|
| | | if (propertiesFile.delete()) {
|
| | | if (!realmFileCopy.renameTo(propertiesFile)) {
|
| | | throw new IOException(MessageFormat.format("Failed to rename {0} to {1}!",
|
| | | realmFileCopy.getAbsolutePath(), propertiesFile.getAbsolutePath()));
|
| | | if (propertiesFile.exists()) {
|
| | | if (!propertiesFile.delete()) {
|
| | | throw new IOException(MessageFormat.format("Failed to delete {0}!",
|
| | | propertiesFile.getAbsolutePath()));
|
| | | }
|
| | | } else {
|
| | | throw new IOException(MessageFormat.format("Failed to delete (0)!",
|
| | | propertiesFile.getAbsolutePath()));
|
| | | }
|
| | | if (!realmFileCopy.renameTo(propertiesFile)) {
|
| | | throw new IOException(MessageFormat.format("Failed to rename {0} to {1}!",
|
| | | realmFileCopy.getAbsolutePath(), propertiesFile.getAbsolutePath()));
|
| | | }
|
| | | } else {
|
| | | throw new IOException(MessageFormat.format("Failed to save {0}!",
|