Skip to content

Commit d355c89

Browse files
author
Open Lowcode SAS
committed
Outsources the 2-ways encrypting key
1 parent d142aa1 commit d355c89

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

src/org/openlowcode/tools/enc/OLcEncrypter.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
import org.openlowcode.tools.encrypt.Encrypter;
2424

2525
/**
26-
* The encrypting mechanism for communication between client and server. It is
27-
* highly recommended that users change the deskey, as, else, anyone with access
28-
* to this code would be able to decode encrypted communication
26+
* The encrypting mechanism for communication between client and server.
2927
*
3028
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
3129
* SAS</a>
@@ -35,23 +33,15 @@ public class OLcEncrypter
3533
implements
3634
Encrypter {
3735
private static Logger logger = Logger.getLogger(OLcEncrypter.class.getName());
38-
private static String deskey = "HeureuxQuiCommeUlysse";
3936
private String DES_ENCRYPTION_SCHEME = "DES";
40-
private byte[] bytekey = deskey.getBytes(StandardCharsets.UTF_8);
37+
private byte[] bytekey = OLcEncrypterString.getEncryptionString().getBytes(StandardCharsets.UTF_8);
4138
private DESKeySpec myKeySpec;
4239
private SecretKeyFactory mySecretKeyFactory;
4340
private Cipher cipher;
4441
private static OLcEncrypter singleton;
4542
private SecretKey key;
4643

47-
/**
48-
* Replaces the encoding key by the new key specified
49-
*
50-
* @param deskey
51-
*/
52-
public static void overridesDeskey(String deskey) {
53-
OLcEncrypter.deskey = deskey;
54-
}
44+
5545

5646
/**
5747
* gets the singleton encrypter. Encoding and decoding is thread-safe
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/********************************************************************************
2+
* Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0 .
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
********************************************************************************/
10+
11+
package org.openlowcode.tools.enc;
12+
13+
/***
14+
* This class just holds the encoding key for 2-ways encoding. Recommendation is
15+
* for companies to override this class in their client and server build
16+
*
17+
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
18+
* SAS</a>
19+
*
20+
*/
21+
public class OLcEncrypterString {
22+
/**
23+
* gets the encryption string
24+
*
25+
* @return the encryption string
26+
*/
27+
protected static String getEncryptionString() {
28+
return "HeureuxQuiCommeUlysse";
29+
}
30+
}

0 commit comments

Comments
 (0)