Skip to content

Commit 30cab8a

Browse files
committed
Updated to 9.18.0
1 parent a235633 commit 30cab8a

File tree

155 files changed

+1129
-728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1129
-728
lines changed

SortOrder.mpr

32 KB
Binary file not shown.

javasource/communitycommons/Misc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private static ISession getSessionFor(IContext context, String username) {
316316
try {
317317
session = initializeSessionForUser(newContext, username);
318318
} catch (CoreException e) {
319-
newContext.rollbackTransAction();
319+
newContext.rollbackTransaction();
320320

321321
throw new RuntimeException("Failed to initialize session for user: " + username + ": " + e.getMessage(), e);
322322
} finally {

javasource/communitycommons/StringUtils.java

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import javax.swing.text.html.parser.ParserDelegator;
3737

3838
import org.apache.commons.io.IOUtils;
39-
import org.apache.commons.lang3.StringEscapeUtils;
39+
import org.apache.commons.text.StringEscapeUtils;
4040
import org.owasp.html.PolicyFactory;
4141
import org.owasp.html.Sanitizers;
4242
import system.proxies.FileDocument;
@@ -48,7 +48,8 @@ public class StringUtils {
4848
private static final String UPPERCASE_ALPHA = stringRange('A', 'Z');
4949
private static final String LOWERCASE_ALPHA = stringRange('a', 'z');
5050
private static final String DIGITS = stringRange('0', '9');
51-
private static final String SPECIAL = stringRange('!', '/');
51+
// Used in tests as well
52+
static final String SPECIAL = stringRange('!', '/');
5253
private static final String ALPHANUMERIC = UPPERCASE_ALPHA + LOWERCASE_ALPHA + DIGITS;
5354

5455
static final Map<String, PolicyFactory> SANITIZER_POLICIES =
@@ -279,39 +280,63 @@ public void handleEndTag(HTML.Tag tag, int pos) {
279280
}
280281

281282
/**
282-
* Returns a random strong password containing a specified minimum number of digits, uppercase
283-
* and special characters.
283+
* Returns a random strong password containing a specified minimum number of uppercase, digits
284+
* and the exact number of special characters.
284285
*
285286
* @param minLen Minimum length
286287
* @param maxLen Maximum length
287-
* @param noOfCAPSAlpha Number of capitals
288-
* @param noOfDigits Number of digits
289-
* @param noOfSplChars Number of special characters
290-
* @return
288+
* @param noOfCAPSAlpha Minimum number of capitals
289+
* @param noOfDigits Minimum number of digits
290+
* @param noOfSplChars Exact number of special characters
291+
* @deprecated Use the overload randomStrongPassword instead
291292
*/
293+
@Deprecated
292294
public static String randomStrongPassword(int minLen, int maxLen, int noOfCAPSAlpha, int noOfDigits, int noOfSplChars) {
293295
if (minLen > maxLen) {
294296
throw new IllegalArgumentException("Min. Length > Max. Length!");
295297
}
296298
if ((noOfCAPSAlpha + noOfDigits + noOfSplChars) > minLen) {
297299
throw new IllegalArgumentException("Min. Length should be atleast sum of (CAPS, DIGITS, SPL CHARS) Length!");
298300
}
299-
return generateCommonLangPassword(minLen, maxLen, noOfCAPSAlpha, noOfDigits, noOfSplChars);
301+
return generateCommonLangPassword(minLen, maxLen, noOfCAPSAlpha, 0, noOfDigits, noOfSplChars);
302+
}
303+
304+
/**
305+
* Returns a random strong password containing a specified minimum number of uppercase, lowercase, digits
306+
* and the exact number of special characters.
307+
*
308+
* @param minLen Minimum length
309+
* @param maxLen Maximum length
310+
* @param noOfCAPSAlpha Minimum number of capitals
311+
* @param noOfLowercaseAlpha Minimum number of lowercase letters
312+
* @param noOfDigits Minimum number of digits
313+
* @param noOfSplChars Exact number of special characters
314+
*/
315+
public static String randomStrongPassword(int minLen, int maxLen, int noOfCAPSAlpha, int noOfLowercaseAlpha, int noOfDigits, int noOfSplChars) {
316+
if (minLen > maxLen) {
317+
throw new IllegalArgumentException("Min. Length > Max. Length!");
318+
}
319+
if ((noOfCAPSAlpha + noOfLowercaseAlpha + noOfDigits + noOfSplChars) > minLen) {
320+
throw new IllegalArgumentException("Min. Length should be atleast sum of (CAPS, LOWER, DIGITS, SPL CHARS) Length!");
321+
}
322+
return generateCommonLangPassword(minLen, maxLen, noOfCAPSAlpha, noOfLowercaseAlpha, noOfDigits, noOfSplChars);
300323
}
301324

302325
// See https://www.baeldung.com/java-generate-secure-password
303326
// Implementation inspired by https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-string-apis (under MIT license)
304-
private static String generateCommonLangPassword(int minLen, int maxLen, int noOfCapsAlpha, int noOfDigits, int noOfSplChars) {
327+
private static String generateCommonLangPassword(int minLen, int maxLen, int noOfCapsAlpha, int noOfLowercaseAlpha, int noOfDigits, int noOfSplChars) {
305328
String upperCaseLetters = randomStringFromCharArray(noOfCapsAlpha, UPPERCASE_ALPHA.toCharArray());
329+
String lowerCaseLetters = randomStringFromCharArray(noOfLowercaseAlpha, LOWERCASE_ALPHA.toCharArray());
306330
String numbers = randomStringFromCharArray(noOfDigits, DIGITS.toCharArray());
307331
String specialChar = randomStringFromCharArray(noOfSplChars, SPECIAL.toCharArray());
308332

309-
final int fixedNumber = noOfCapsAlpha + noOfDigits + noOfSplChars;
333+
final int fixedNumber = noOfCapsAlpha + noOfLowercaseAlpha + noOfDigits + noOfSplChars;
310334
final int lowerBound = minLen - fixedNumber;
311335
final int upperBound = maxLen - fixedNumber;
312336
String totalChars = randomStringFromCharArray(lowerBound, upperBound, ALPHANUMERIC.toCharArray());
313337

314338
String combinedChars = upperCaseLetters
339+
.concat(lowerCaseLetters)
315340
.concat(numbers)
316341
.concat(specialChar)
317342
.concat(totalChars);

0 commit comments

Comments
 (0)