Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0fe2c8b
TextArea now has Validators.
fjalvingh Nov 10, 2022
91cb2f7
Bugfix: Failing validators would not show the actual error message, a…
fjalvingh Nov 10, 2022
cb68d22
[test] Add an UI test for the validation binding error bugfix
fjalvingh Nov 10, 2022
28784c0
bugfix: fix binding trouble caused by the earlier fix
fjalvingh Nov 10, 2022
59ca0cb
code reuse
millevlada Nov 14, 2022
b458512
Merge pull request #412 from fjalvingh/23-reuse
fjalvingh Nov 14, 2022
295262d
Added option to add a check if tab can be selected.
millevlada Nov 14, 2022
b3b9b80
Changed interface to use tab handlers, and added API doc on setter.
millevlada Nov 14, 2022
6d4e9a8
Merge pull request #413 from fjalvingh/tab-selectable
fjalvingh Nov 14, 2022
a427d31
[filetool] Log file delete failures at level DEBUG to hide this usele…
fjalvingh Nov 14, 2022
f4e96b6
Merge branch 'skarp-master' of github.com:fjalvingh/domui into skarp-…
fjalvingh Nov 14, 2022
a49fb72
Enables customization of lookup form search fields and also lookup ta…
millevlada Nov 15, 2022
5708dc5
Merge pull request #414 from fjalvingh/li-customizations
fjalvingh Nov 15, 2022
7d4c172
Merge branch 'skarp-prd' of github.com:fjalvingh/domui into skarp-master
fjalvingh Nov 17, 2022
7703bbd
Enabling customization of max height for search as you type popup for…
millevlada Nov 17, 2022
3191320
Merge branch 'skarp-master' into skarp-master-test5
millevlada Nov 18, 2022
7675ae8
Bugfix: sysout messages supressed, and add a validation error without…
fjalvingh Nov 18, 2022
bc9e943
Add missing nullity annotations
fjalvingh Nov 21, 2022
7cd4ca7
Add password generator to StringTool.
fjalvingh Nov 21, 2022
c009998
Merge branch 'skarp-master' into skarp-master-test5
millevlada Nov 23, 2022
5962e60
[typedproperties] Add debugging to annotation processor to find compi…
fjalvingh Nov 24, 2022
20d114c
Merge branch 'skarp-master' into skarp-master-test5
millevlada Nov 24, 2022
b35702f
Merge branch 'skarp-prd' of github.com:fjalvingh/domui into skarp-master
fjalvingh Nov 24, 2022
3bf5296
Merge branch 'skarp-master' into skarp-master-test5
millevlada Nov 24, 2022
87d2a77
Added util for replacing the one qualified variable with another insi…
millevlada Nov 28, 2022
4391b05
Merge pull request #419 from fjalvingh/string-qn-replacing
fjalvingh Nov 29, 2022
ca4f774
Merge pull request #415 from fjalvingh/lookup2-max-height
fjalvingh Nov 29, 2022
cec195e
added also variant without qualified name
millevlada Nov 29, 2022
caa0596
api doc
millevlada Nov 29, 2022
d531a2e
[security] Replace all vulnerable libraries as found by checkmarx
fjalvingh Nov 29, 2022
a2a6681
Merge pull request #420 from fjalvingh/string-replacing
fjalvingh Nov 29, 2022
df169c3
[ace] Enable behaviors by default.
fjalvingh Dec 5, 2022
9309881
Merge branch 'nonce' into skarp-master-nonce
millevlada Dec 7, 2022
dd7b47a
Fix warning icon that has incorrect size
fjalvingh Dec 7, 2022
1640a08
Merge branch 'skarp-prd' of github.com:fjalvingh/domui into skarp-master
fjalvingh Dec 8, 2022
c5b64eb
Bugfix: fix errors while reversing basic Postgres schema (forward ref…
fjalvingh Dec 8, 2022
cbdbda8
[reverser] Fix some messages
fjalvingh Dec 8, 2022
32002d6
Merge branch 'skarp-prd' of github.com:fjalvingh/domui into skarp-master
fjalvingh Dec 8, 2022
cce92d8
Added Html Content-Security-Policy (CSP) header support for parts of …
millevlada Dec 12, 2022
51e75a8
Merge branch 'skarp-master' into skarp-master-nonce
millevlada Dec 12, 2022
9146ed1
Fixes the way we render the Domui events in CSP compliant way.
millevlada Dec 12, 2022
cdb8140
Fixes order of flushed js, first domuiJs (js as result of CSP header …
millevlada Dec 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ecj.version>3.12.3</ecj.version>
<source.jdk.version>1.8</source.jdk.version>
<target.jdk.version>1.8</target.jdk.version>
<kotlin.version>1.5.20</kotlin.version>
<kotlin.version>1.7.20</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<jetty.version>9.4.6.v20170531</jetty.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import java.util.TreeMap;
import java.util.stream.Collectors;

@SupportedAnnotationTypes({"javax.persistence.Entity", "to.etc.annotations.GenerateProperties"})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
/**
* Generates QField classes for every Entity annotated class in the project where this processor is selected.
* Leave the default .apt_generated folder as is.
Expand All @@ -46,6 +44,8 @@
* @author <a href="mailto:jal@etc.to">Frits Jalvingh</a>
* Created on Feb 3, 2013
*/
@SupportedAnnotationTypes({"javax.persistence.Entity", "to.etc.annotations.GenerateProperties"})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class PropertyAnnotationProcessor extends AbstractProcessor {
static public final String PERSISTENCE_ANNOTATION = "javax.persistence.Entity";

Expand All @@ -61,6 +61,8 @@ public class PropertyAnnotationProcessor extends AbstractProcessor {

private SourceVersion m_sourceVersion;

private boolean m_debug = System.getenv().get("DOMUI_ANNDEBUG") != null;

static public final class Property {
private final TypeMirror m_type;

Expand Down Expand Up @@ -128,8 +130,9 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment

String pkgName = processingEnv.getElementUtils().getPackageOf(classElement).getQualifiedName().toString();
String entityName = classElement.getSimpleName().toString();
if(m_debug)
System.out.println("ANN> Processing entity " + entityName);

//String entityName = classElement.asType().toString();
try {
List<Property> properties = getProperties(classElement);

Expand Down Expand Up @@ -161,6 +164,8 @@ String getLinkClass(String entityName) {
}

private JavaFileObject createFile(String name, TypeElement ann) throws IOException {
if((m_debug))
System.out.println("ANN> createFile " + name + " source " + ann);
return processingEnv.getFiler().createSourceFile(name, ann);
}

Expand Down
2 changes: 1 addition & 1 deletion common/to.etc.alg/src/main/java/to/etc/util/FileTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ public static void delete(File file) {
try {
Files.delete(file.toPath());
} catch(Exception x) {
LOG.error("Failed to delete " + file + ": " + x, x);
LOG.debug("Failed to delete " + file + ": " + x, x);
}
}
}
11 changes: 11 additions & 0 deletions common/to.etc.alg/src/main/java/to/etc/util/SecurityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ static public String getSha256Hex(@NonNull String in, @NonNull Charset encoding)
}
}

@NonNull
static public String getSha256Base64(@NonNull String in, @NonNull Charset encoding) {
try {
MessageDigest sha = MessageDigest.getInstance("SHA-256");
byte[] hash = sha.digest(in.getBytes(encoding));
return StringTool.encodeBase64ToString(hash);
} catch(Exception ex) {
throw WrappedException.wrap(ex);
}
}

static public byte[] createSalt(int bytes) {
byte[] salt = new byte[bytes];
RANDOM.nextBytes(salt);
Expand Down
130 changes: 129 additions & 1 deletion common/to.etc.alg/src/main/java/to/etc/util/StringTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.util.StringTokenizer;
import java.util.regex.Pattern;

import static java.lang.Character.isJavaIdentifierPart;

/**
* This static utility class contains a load of string functions. And some other
* stuff I could not quickly find a place for ;-)
Expand Down Expand Up @@ -112,7 +114,7 @@ static public boolean isValidJavaIdentifier(@NonNull final String s) {
if(!Character.isJavaIdentifierStart(s.charAt(0)))
return false;
for(int i = 1; i < len; i++) {
if(!Character.isJavaIdentifierPart(s.charAt(i)))
if(!isJavaIdentifierPart(s.charAt(i)))
return false;
}
return true;
Expand Down Expand Up @@ -3099,6 +3101,71 @@ public static String stripAccents(String s) {
return s;
}

/**
* Util that locates given qualified name in expression (with ignored casing), and replaces it with new qualified name.
* It ignores other cases when old name is part of naming of other variables in expression.
* It requires that old qualified name prefix and name are named by java identifier convention.
*
* @param expression expression where we replace variables with qualified names
* @param prefixQName prefix in qualified name to replace.
* @param oldName name in qualified name to replace.
* @param newQName new qualified name that replaced old one.
* @return replaced expression.
*/
@Nullable
public static String replaceQualifiedNameInExpression(@Nullable String expression, String prefixQName, String oldName, String newQName) {
if(null == expression) {
return null;
}
String lEntityName = prefixQName.toLowerCase();
String lOldName = oldName.toLowerCase();
String literalToFind = lEntityName + "." + lOldName;
return replaceVariableNameInExpression(expression, literalToFind, newQName);
}

/**
* Util that locates given variable name in expression (with ignored casing), and replaces it with new name.
* It ignores other cases when old name is part of naming of other variables in expression.
* It requires that old and new name are named by java identifier convention.
*
* @param expression expression where we replace variable name
* @param oldName name to replace.
* @return replaced expression.
*/
@Nullable
public static String replaceVariableNameInExpression(@Nullable String expression, String oldName, String newName) {
if(null == expression) {
return null;
}
String lowerCaseExpression = expression.toLowerCase();
String literalToFind = oldName.toLowerCase();
int lastReplacedIndex = 0;
int pos = -1;
StringBuilder replaceSb = new StringBuilder();
do {
pos = lowerCaseExpression.indexOf(literalToFind, pos + 1);
if(pos > -1) {
Character nextChar = null;
if(lowerCaseExpression.length() > pos + literalToFind.length()) {
nextChar = lowerCaseExpression.charAt(pos + literalToFind.length());
}
Character prevChar = null;
if(pos > 0) {
prevChar = expression.charAt(pos - 1);
}
if((nextChar == null || !isJavaIdentifierPart(nextChar)) && (prevChar == null || !isJavaIdentifierPart(prevChar))) {
replaceSb
.append(expression.substring(lastReplacedIndex, pos))
.append(newName);
lastReplacedIndex = pos + literalToFind.length();
}
} else if(lastReplacedIndex < expression.length()) {
replaceSb.append(expression.substring(lastReplacedIndex));
}
} while(pos >= 0);
return replaceSb.toString();
}

/**
* This method checks that the name passed only contains a name,
* and nothing that looks like a SQL injection.
Expand All @@ -3121,6 +3188,67 @@ static public void sqlCheckNoQuotes(@Nullable String password) {
if(null != password && password.contains("'"))
throw new IllegalArgumentException("Invalid characters in SQL");
}

static private final char[] PUNCT = "!#_^&*.;".toCharArray();

static private final char[] DIGITS = "023456789".toCharArray();

static private final char[] LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();

/**
* Generate a reasonably secure password.
*/
static public String generatePassword(int nchar) {
return generatePassword(nchar, 2, 2);
}

/*
* Postgres' passwords should not include dollar signs nor percentage signs.
* jal 20200608 actually postgres is OK with it, it's Azure Tabular that dies with it.
*/
static public String generatePassword(int nchar, int punctuation, int digits) {
if(nchar < 6)
throw new IllegalStateException("Don't be silly.");

char[] buf = new char[nchar]; // Password buffer

//-- Randomly assign the #of punctuation chars
while(punctuation > 0) {
char c = PUNCT[m_random.nextInt(PUNCT.length)]; // Random punctuation

for(; ; ) {
int pos = m_random.nextInt(nchar); // Get a position
if(buf[pos] == 0) {
buf[pos] = c;
break;
}
}
punctuation--;
}

//-- Randomly assign digits
while(digits > 0) {
char c = DIGITS[m_random.nextInt(DIGITS.length)]; // Random punctuation

for(; ; ) {
int pos = m_random.nextInt(nchar); // Get a position
if(buf[pos] == 0) {
buf[pos] = c;
break;
}
}
digits--;
}

//-- And finally: fill the rest with random letters.
for(int i = 0; i < nchar; i++) {
if(buf[i] == 0) {
buf[i] = LETTERS[m_random.nextInt(LETTERS.length)];
}
}
return new String(buf);
}

}


21 changes: 0 additions & 21 deletions common/to.etc.alg/src/test/java/to/etc/util/StringToolTest.java

This file was deleted.

26 changes: 26 additions & 0 deletions common/to.etc.alg/src/test/java/to/etc/util/TestStringTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import java.util.Arrays;
import java.util.List;

import static junit.framework.TestCase.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

/**
Expand Down Expand Up @@ -456,4 +459,27 @@ public void testRemoveRepeatingCharacters_whenHasRepeatingDigits_dontShortenStri
res = StringTool.removeRepeatingCharacters(s);
Assert.assertEquals("abc1111111abc 123456789123456789", res);
}

@Test
public void testStripAccents() {
var examples = List.of(
new Pair<>("filë_name.xls", "file_name.xls"),
new Pair<>("ćčćč", "cccc") );
for(var example : examples) {
var rename = StringTool.stripAccents(example.get1());
assertEquals(example.get2(), rename);
}
}

@Test
public void testReplaceQualifiedNameInExpression() {
assertEquals(StringTool.replaceQualifiedNameInExpression("a.aaaa + a.aaab-a.aAa", "A", "aaa", "Aa.ccc"), "a.aaaa + a.aaab-Aa.ccc");
assertEquals(StringTool.replaceQualifiedNameInExpression("aa.aaa-A.aaa*1-a.AAa ", "A", "aaa", "Aa.ccc"), "aa.aaa-Aa.ccc*1-Aa.ccc ");
}

@Test
public void testReplaceVariableNameInExpression() {
assertEquals(StringTool.replaceVariableNameInExpression("aaaa + aaab-aAa", "aaa", "ccc"), "aaaa + aaab-ccc");
assertEquals(StringTool.replaceVariableNameInExpression("baaa-aaa*1-AAa ", "aaa", "ccc"), "baaa-ccc*1-ccc ");
}
}
4 changes: 2 additions & 2 deletions examples/skeleton/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<source.jdk.version>1.8</source.jdk.version>
<target.jdk.version>1.8</target.jdk.version>
<ecj.version>3.12.3</ecj.version>
<kotlin.version>1.5.20</kotlin.version>
<kotlin.version>1.7.20</kotlin.version>

<!-- Plugin versions -->
<maven-javadoc-plugin.version>3.3.0</maven-javadoc-plugin.version>
Expand Down Expand Up @@ -249,7 +249,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.1</version>
<version>42.5.1</version>
</dependency>

<!-- &lt;!&ndash; https://mvnrepository.com/artifact/mysql/mysql-connector-java &ndash;&gt;-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@
* Created on 12-2-18.
*/
final public class UUIDGenerator23 implements IdentifierGenerator {

@Override
public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
UUID uuid = UUID.randomUUID();
byte[] data = new byte[16];

moveBytes(data, 0, uuid.getMostSignificantBits());
moveBytes(data, 8, uuid.getLeastSignificantBits());
String str = StringTool.encodeBase64ToString(data);

return str.substring(0, 23); // Strip the ==
return createUUID();
}

static private void moveBytes(byte[] bytes, int offset, long bits) {
Expand Down
17 changes: 4 additions & 13 deletions integrations/to.etc.domui.selenium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,10 @@

</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
</dependency>


<!--&lt;!&ndash; https://mvnrepository.com/artifact/com.github.detro.ghostdriver/phantomjsdriver &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>com.github.detro.ghostdriver</groupId>-->
<!--<artifactId>phantomjsdriver</artifactId>-->
<!--<version>1.1.0</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.seleniumhq.selenium</groupId>-->
<!-- <artifactId>htmlunit-driver</artifactId>-->
<!-- </dependency>-->

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ static public WebDriverConnector get() throws Exception {

@NonNull
private static WebDriverType getDriverType(@Nullable String hubUrl) {
if(null == hubUrl || hubUrl.trim().isEmpty())
return WebDriverType.HTMLUNIT; // Used as a target because it can emulate multiple browser types
if("local".equals(hubUrl.trim()))
return WebDriverType.LOCAL;
if(hubUrl.startsWith(BROWSERSTACK)) {
return WebDriverType.BROWSERSTACK;
if(null != hubUrl) {
//if(null == hubUrl || hubUrl.trim().isEmpty())
// return WebDriverType.HTMLUNIT; // Used as a target because it can emulate multiple browser types
if("local".equals(hubUrl.trim()))
return WebDriverType.LOCAL;
if(hubUrl.startsWith(BROWSERSTACK)) {
return WebDriverType.BROWSERSTACK;
}
}
return WebDriverType.REMOTE;
}
Expand Down
Loading