You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (this.value == null || !isStartsWithRightPrefix())
42
-
returnnull;
43
-
if (this.prefix == null || this.prefix.isEmpty())
44
-
thrownewMendixRuntimeException("Prefix should not be empty");
45
-
if (this.key == null || this.key.isEmpty())
46
-
thrownewMendixRuntimeException("Key should not be empty");
47
-
if (this.key.length() != 16)
48
-
thrownewMendixRuntimeException("Key length should be 16");
49
-
50
-
StringdecryptedText = null;
51
-
52
-
if (isEncryptedWithLegacyAlgorithm(this.value)) {
53
-
decryptedText = decryptUsingLegacyAlgorithm();
54
-
} else {
55
-
decryptedText = decryptUsingGcm();
56
-
}
57
-
58
-
returndecryptedText;
41
+
if (this.value == null || !isStartsWithRightPrefix()) {
42
+
returnnull;
43
+
}
44
+
if (this.prefix == null || this.prefix.isEmpty()) {
45
+
thrownewMendixRuntimeException("Prefix should not be empty");
46
+
}
47
+
if (this.key == null || this.key.isEmpty()) {
48
+
thrownewMendixRuntimeException("Key should not be empty");
49
+
}
50
+
if (this.key.length() != getKeyLength()) {
51
+
thrownewMendixRuntimeException("Key length should be 16");
52
+
}
53
+
54
+
StringdecryptedText = null;
55
+
56
+
if (isEncryptedWithLegacyAlgorithm(this.value)) {
57
+
decryptedText = decryptUsingLegacyAlgorithm();
58
+
} else {
59
+
decryptedText = decryptUsingGcm();
60
+
}
61
+
62
+
returndecryptedText;
59
63
// END USER CODE
60
64
}
61
65
@@ -69,67 +73,81 @@ public java.lang.String toString()
69
73
}
70
74
71
75
// BEGIN EXTRA CODE
72
-
privatefinalintGCM_TAG_LENGTH = 16; // in bytes
73
-
privatefinalStringLEGACY_PREFIX = "{AES}";
74
-
privatefinalStringWRONG_KEY_ERROR_MESSAGE = "Cannot decrypt the text because it was either NOT encrypted with a key of length 16 or they key is different";
75
-
76
-
privateStringdecryptUsingGcm() throwsException {
77
-
String[] s = this.value.substring(this.prefix.length()).split(";");
78
-
79
-
if (s.length < 2) //Not an encrypted string, just return the original value.
0 commit comments