A modified patch from Pierre Smits for "Remove superfluous .properties extension from EntityUtilProperties requests" https://issues.apache.org/jira/browse/OFBIZ-6719

Currently many EntityUtilProperties requests have the .properties extension in the parameters for the resource, but this is not needed as it is stripped later on.

jleroux: I found 5 others, replaced also


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1713985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2015-11-12 09:22:38 +00:00
parent ec34fab02e
commit 87f4513d2b
47 changed files with 176 additions and 176 deletions
@@ -395,7 +395,7 @@ public class CommonEvents {
try {
Delegator delegator = (Delegator) request.getAttribute("delegator");
final String captchaSizeConfigName = StringUtils.defaultIfEmpty(request.getParameter("captchaSize"), "default");
final String captchaSizeConfig = EntityUtilProperties.getPropertyValue("captcha.properties", "captcha." + captchaSizeConfigName, delegator);
final String captchaSizeConfig = EntityUtilProperties.getPropertyValue("captcha", "captcha." + captchaSizeConfigName, delegator);
final String[] captchaSizeConfigs = captchaSizeConfig.split("\\|");
final String captchaCodeId = StringUtils.defaultIfEmpty(request.getParameter("captchaCodeId"), ""); // this is used to uniquely identify in the user session the attribute where the captcha code for the last captcha for the form is stored
@@ -403,7 +403,7 @@ public class CommonEvents {
final int height = Integer.parseInt(captchaSizeConfigs[1]);
final int width = Integer.parseInt(captchaSizeConfigs[2]);
final int charsToPrint = UtilProperties.getPropertyAsInteger("captcha.properties", "captcha.code_length", 6);
final char[] availableChars = EntityUtilProperties.getPropertyValue("captcha.properties", "captcha.characters", delegator).toCharArray();
final char[] availableChars = EntityUtilProperties.getPropertyValue("captcha", "captcha.characters", delegator).toCharArray();
//It is possible to pass the font size, image width and height with the request as well
Color backgroundColor = Color.gray;
@@ -43,7 +43,7 @@ public class CommonWorkers {
public static List<GenericValue> getCountryList(Delegator delegator) {
List<GenericValue> geoList = new LinkedList<GenericValue>();
String defaultCountry = EntityUtilProperties.getPropertyValue("general.properties", "country.geo.id.default", delegator);
String defaultCountry = EntityUtilProperties.getPropertyValue("general", "country.geo.id.default", delegator);
GenericValue defaultGeo = null;
if (UtilValidate.isNotEmpty(defaultCountry)) {
try {
@@ -54,7 +54,7 @@ public class CommonWorkers {
}
List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("geoTypeId", EntityOperator.EQUALS, "COUNTRY"));
List<String> countriesAvailable = StringUtil.split(EntityUtilProperties.getPropertyValue("general.properties", "countries.geo.id.available", delegator), ",");
List<String> countriesAvailable = StringUtil.split(EntityUtilProperties.getPropertyValue("general", "countries.geo.id.available", delegator), ",");
if (UtilValidate.isNotEmpty(countriesAvailable)) {
// only available countries (we don't verify the list of geoId in countries.geo.id.available)
exprs.add(EntityCondition.makeCondition("geoId", EntityOperator.IN, countriesAvailable));
@@ -108,7 +108,7 @@ public class CommonWorkers {
public static List<GenericValue> getAssociatedStateList(Delegator delegator, String country, String listOrderBy) {
if (UtilValidate.isEmpty(country)) {
// Load the system default country
country = EntityUtilProperties.getPropertyValue("general.properties", "country.geo.id.default", delegator);
country = EntityUtilProperties.getPropertyValue("general", "country.geo.id.default", delegator);
}
if (UtilValidate.isEmpty(listOrderBy)) {
@@ -135,7 +135,7 @@ public class EmailServices {
String sendBcc = (String) context.get("sendBcc");
// check to see if we should redirect all mail for testing
String redirectAddress = EntityUtilProperties.getPropertyValue("general.properties", "mail.notifications.redirectTo", delegator);
String redirectAddress = EntityUtilProperties.getPropertyValue("general", "mail.notifications.redirectTo", delegator);
if (UtilValidate.isNotEmpty(redirectAddress)) {
String originalRecipients = " [To: " + sendTo + ", Cc: " + sendCc + ", Bcc: " + sendBcc + "]";
subject += originalRecipients;
@@ -167,34 +167,34 @@ public class EmailServices {
if (sendType == null || sendType.equals("mail.smtp.host")) {
sendType = "mail.smtp.host";
if (UtilValidate.isEmpty(sendVia)) {
sendVia = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.relay.host", "localhost", delegator);
sendVia = EntityUtilProperties.getPropertyValue("general", "mail.smtp.relay.host", "localhost", delegator);
}
if (UtilValidate.isEmpty(authUser)) {
authUser = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.auth.user", delegator);
authUser = EntityUtilProperties.getPropertyValue("general", "mail.smtp.auth.user", delegator);
}
if (UtilValidate.isEmpty(authPass)) {
authPass = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.auth.password", delegator);
authPass = EntityUtilProperties.getPropertyValue("general", "mail.smtp.auth.password", delegator);
}
if (UtilValidate.isNotEmpty(authUser)) {
useSmtpAuth = true;
}
if (UtilValidate.isEmpty(port)) {
port = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.port", delegator);
port = EntityUtilProperties.getPropertyValue("general", "mail.smtp.port", delegator);
}
if (UtilValidate.isEmpty(socketFactoryPort)) {
socketFactoryPort = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.port", delegator);
socketFactoryPort = EntityUtilProperties.getPropertyValue("general", "mail.smtp.socketFactory.port", delegator);
}
if (UtilValidate.isEmpty(socketFactoryClass)) {
socketFactoryClass = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.class", delegator);
socketFactoryClass = EntityUtilProperties.getPropertyValue("general", "mail.smtp.socketFactory.class", delegator);
}
if (UtilValidate.isEmpty(socketFactoryFallback)) {
socketFactoryFallback = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.fallback", "false", delegator);
socketFactoryFallback = EntityUtilProperties.getPropertyValue("general", "mail.smtp.socketFactory.fallback", "false", delegator);
}
if (sendPartial == null) {
sendPartial = EntityUtilProperties.propertyValueEqualsIgnoreCase("general.properties", "mail.smtp.sendpartial", "true", delegator) ? true : false;
sendPartial = EntityUtilProperties.propertyValueEqualsIgnoreCase("general", "mail.smtp.sendpartial", "true", delegator) ? true : false;
}
if (isStartTLSEnabled == null) {
isStartTLSEnabled = EntityUtilProperties.propertyValueEqualsIgnoreCase("general.properties", "mail.smtp.starttls.enable", "true", delegator);
isStartTLSEnabled = EntityUtilProperties.propertyValueEqualsIgnoreCase("general", "mail.smtp.starttls.enable", "true", delegator);
}
} else if (sendVia == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMissingParameterSendVia", locale));
@@ -238,7 +238,7 @@ public class EmailServices {
}
session = Session.getInstance(props);
boolean debug = EntityUtilProperties.propertyValueEqualsIgnoreCase("general.properties", "mail.debug.on", "Y", delegator);
boolean debug = EntityUtilProperties.propertyValueEqualsIgnoreCase("general", "mail.debug.on", "Y", delegator);
session.setDebug(debug);
mail = new MimeMessage(session);
@@ -309,7 +309,7 @@ public class EmailServices {
}
// check to see if sending mail is enabled
String mailEnabled = EntityUtilProperties.getPropertyValue("general.properties", "mail.notifications.enabled", "N", delegator);
String mailEnabled = EntityUtilProperties.getPropertyValue("general", "mail.notifications.enabled", "N", delegator);
if (!"Y".equalsIgnoreCase(mailEnabled)) {
// no error; just return as if we already processed
Debug.logImportant("Mail notifications disabled in general.properties; mail with subject [" + subject + "] not sent to addressee [" + sendTo + "]", module);
@@ -95,7 +95,7 @@ public class LdapAuthenticationServices {
}
// Synchronize user's OFBiz password with user's LDAP password
if (userLogin != null) {
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.encrypt", delegator));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
String currentPassword = userLogin.getString("currentPassword");
boolean samePassword;
if (useEncryption) {
@@ -92,7 +92,7 @@ public class LoginServices {
}
Map<String, Object> result = new LinkedHashMap<String, Object>();
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.encrypt", delegator));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
// if isServiceAuth is not specified, default to not a service auth
boolean isServiceAuth = context.get("isServiceAuth") != null && ((Boolean) context.get("isServiceAuth")).booleanValue();
@@ -112,10 +112,10 @@ public class LoginServices {
errMsg = UtilProperties.getMessage(resource,"loginservices.password_missing", locale);
} else {
if ("true".equalsIgnoreCase(EntityUtilProperties.getPropertyValue("security.properties", "username.lowercase", delegator))) {
if ("true".equalsIgnoreCase(EntityUtilProperties.getPropertyValue("security", "username.lowercase", delegator))) {
username = username.toLowerCase();
}
if ("true".equalsIgnoreCase(EntityUtilProperties.getPropertyValue("security.properties", "password.lowercase", delegator))) {
if ("true".equalsIgnoreCase(EntityUtilProperties.getPropertyValue("security", "password.lowercase", delegator))) {
password = password.toLowerCase();
}
@@ -155,7 +155,7 @@ public class LoginServices {
}
if (userLogin != null) {
String ldmStr = EntityUtilProperties.getPropertyValue("security.properties", "login.disable.minutes", delegator);
String ldmStr = EntityUtilProperties.getPropertyValue("security", "login.disable.minutes", delegator);
long loginDisableMinutes = 30;
try {
@@ -265,7 +265,7 @@ public class LoginServices {
userLogin.set("successiveFailedLogins", currentFailedLogins);
// if failed logins over amount in properties file, disable account
String mflStr = EntityUtilProperties.getPropertyValue("security.properties", "max.failed.logins", delegator);
String mflStr = EntityUtilProperties.getPropertyValue("security", "max.failed.logins", delegator);
long maxFailedLogins = 3;
try {
maxFailedLogins = Long.parseLong(mflStr);
@@ -302,11 +302,11 @@ public class LoginServices {
userLogin.store();
}
if ("true".equals(EntityUtilProperties.getPropertyValue("security.properties", "store.login.history", delegator))) {
if ("true".equals(EntityUtilProperties.getPropertyValue("security", "store.login.history", delegator))) {
boolean createHistory = true;
// only save info on service auth if option set to true to do so
if (isServiceAuth && !"true".equals(EntityUtilProperties.getPropertyValue("security.properties", "store.login.history.on.service.auth", delegator))) {
if (isServiceAuth && !"true".equals(EntityUtilProperties.getPropertyValue("security", "store.login.history.on.service.auth", delegator))) {
createHistory = false;
}
@@ -320,7 +320,7 @@ public class LoginServices {
}
// ONLY save the password if it was incorrect
if ("N".equals(successfulLogin) && !"false".equals(EntityUtilProperties.getPropertyValue("security.properties", "store.login.history.incorrect.password", delegator))) {
if ("N".equals(successfulLogin) && !"false".equals(EntityUtilProperties.getPropertyValue("security", "store.login.history.incorrect.password", delegator))) {
ulhCreateMap.put("passwordUsed", password);
}
@@ -425,7 +425,7 @@ public class LoginServices {
public static void createUserLoginPasswordHistory(Delegator delegator,String userLoginId, String currentPassword) throws GenericEntityException{
int passwordChangeHistoryLimit = 0;
try {
passwordChangeHistoryLimit = Integer.parseInt(EntityUtilProperties.getPropertyValue("security.properties", "password.change.history.limit", "0", delegator));
passwordChangeHistoryLimit = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "password.change.history.limit", "0", delegator));
} catch (NumberFormatException nfe) {
//No valid value is found so don't bother to save any password history
passwordChangeHistoryLimit = 0;
@@ -460,7 +460,7 @@ public class LoginServices {
// save this password in history
GenericValue userLoginPwdHistToCreate = delegator.makeValue("UserLoginPasswordHistory", UtilMisc.toMap("userLoginId", userLoginId,"fromDate", nowTimestamp));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.encrypt", delegator));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
userLoginPwdHistToCreate.set("currentPassword", useEncryption ? HashCrypt.cryptUTF8(getHashType(), null, currentPassword) : currentPassword);
userLoginPwdHistToCreate.create();
}
@@ -478,7 +478,7 @@ public class LoginServices {
List<String> errorMessageList = new LinkedList<String>();
Locale locale = (Locale) context.get("locale");
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.encrypt", delegator));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
String userLoginId = (String) context.get("userLoginId");
String partyId = (String) context.get("partyId");
@@ -581,7 +581,7 @@ public class LoginServices {
AuthHelper.loadAuthenticators(ctx.getDispatcher());
}
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.encrypt", delegator));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
boolean adminUser = false;
String userLoginId = (String) context.get("userLoginId");
@@ -648,7 +648,7 @@ public class LoginServices {
}
}
if ("true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.lowercase", delegator))) {
if ("true".equals(EntityUtilProperties.getPropertyValue("security", "password.lowercase", delegator))) {
currentPassword = currentPassword.toLowerCase();
newPassword = newPassword.toLowerCase();
newPasswordVerify = newPasswordVerify.toLowerCase();
@@ -713,7 +713,7 @@ public class LoginServices {
String userLoginId = (String) context.get("userLoginId");
String errMsg = null;
if ((userLoginId != null) && ("true".equals(EntityUtilProperties.getPropertyValue("security.properties", "username.lowercase", delegator)))) {
if ((userLoginId != null) && ("true".equals(EntityUtilProperties.getPropertyValue("security", "username.lowercase", delegator)))) {
userLoginId = userLoginId.toLowerCase();
}
@@ -890,7 +890,7 @@ public class LoginServices {
public static void checkNewPassword(GenericValue userLogin, String currentPassword, String newPassword, String newPasswordVerify, String passwordHint, List<String> errorMessageList, boolean ignoreCurrentPassword, Locale locale) {
Delegator delegator = userLogin.getDelegator();
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security.properties", "password.encrypt", delegator));
boolean useEncryption = "true".equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));
String errMsg = null;
@@ -919,7 +919,7 @@ public class LoginServices {
int passwordChangeHistoryLimit = 0;
try {
passwordChangeHistoryLimit = Integer.parseInt(EntityUtilProperties.getPropertyValue("security.properties", "password.change.history.limit", "0", delegator));
passwordChangeHistoryLimit = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "password.change.history.limit", "0", delegator));
} catch (NumberFormatException nfe) {
//No valid value is found so don't bother to save any password history
passwordChangeHistoryLimit = 0;
@@ -952,15 +952,15 @@ public class LoginServices {
int minPasswordLength = 0;
try {
minPasswordLength = Integer.parseInt(EntityUtilProperties.getPropertyValue("security.properties", "password.length.min", "0", delegator));
minPasswordLength = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "password.length.min", "0", delegator));
} catch (NumberFormatException nfe) {
minPasswordLength = 0;
}
if (newPassword != null) {
// Matching password with pattern
String passwordPattern = EntityUtilProperties.getPropertyValue("security.properties", "security.login.password.pattern", "^.*(?=.{5,}).*$", delegator);
boolean usePasswordPattern = UtilProperties.getPropertyAsBoolean("security.properties", "security.login.password.pattern.enable", true);
String passwordPattern = EntityUtilProperties.getPropertyValue("security", "security.login.password.pattern", "^.*(?=.{5,}).*$", delegator);
boolean usePasswordPattern = UtilProperties.getPropertyAsBoolean("security", "security.login.password.pattern.enable", true);
if (usePasswordPattern) {
Pattern pattern = Pattern.compile(passwordPattern);
Matcher matcher = pattern.matcher(newPassword);
@@ -968,7 +968,7 @@ public class LoginServices {
if (!matched) {
// This is a mix to handle the OOTB pattern which is only a fixed length
Map<String, String> messageMap = UtilMisc.toMap("minPasswordLength", Integer.toString(minPasswordLength));
String passwordPatternMessage = EntityUtilProperties.getPropertyValue("security.properties",
String passwordPatternMessage = EntityUtilProperties.getPropertyValue("security",
"security.login.password.pattern.description", "loginservices.password_must_be_least_characters_long", delegator);
errMsg = UtilProperties.getMessage(resource, passwordPatternMessage, messageMap, locale);
messageMap = UtilMisc.toMap("passwordPatternMessage", errMsg);
@@ -994,7 +994,7 @@ public class LoginServices {
}
public static String getHashType() {
String hashType = UtilProperties.getPropertyValue("security.properties", "password.encrypt.hash.type");
String hashType = UtilProperties.getPropertyValue("security", "password.encrypt.hash.type");
if (UtilValidate.isEmpty(hashType)) {
Debug.logWarning("Password encrypt hash type is not specified in security.properties, use SHA", module);
@@ -1013,7 +1013,7 @@ public class LoginServices {
passwordMatches = oldPassword.equals(currentPassword);
}
}
if (!passwordMatches && "true".equals(UtilProperties.getPropertyValue("security.properties", "password.accept.encrypted.and.plain"))) {
if (!passwordMatches && "true".equals(UtilProperties.getPropertyValue("security", "password.accept.encrypted.and.plain"))) {
passwordMatches = currentPassword.equals(oldPassword);
}
return passwordMatches;