We are upgrading our application from Weblogic 10.3.6.0 to Weblogic 12cR2. I see decryption is taking unusually long time in Linux than windows.
In Windows the same code takes less than 3 milliseconds but in Linux it is taking over 2 minutes to decrypt. I have tried different ways to resolve this issue but not able to find any solution. Due to this server startup is taking too long. Please guide me if there is a way to resolve this issue or any other encryption/decryption mechanism can help. This issue appears when I use Weblogic 12cR2 jars. If I use Weblogic 10.3.6.0, it is much faster like windows.
FYI, Encryption also takes longer time.
pom.xml dependencies
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>12.2.1.2.0</version>
<type>jar</type>
</dependency> -->
<dependency>
<groupId>com.oracle.webservices.wls</groupId>
<artifactId>jaxws-wlswss-client</artifactId>
<version>12.2.1.2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>cryptoj</artifactId>
<version>12.2.1.2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<type>jar</type>
</dependency>
</dependencies>
Program:
package net.retail.security;
import java.io.File;
import java.io.FileNotFoundException;
import weblogic.security.internal.SerializedSystemIni;
import weblogic.security.internal.encryption.ClearOrEncryptedService;
import weblogic.security.internal.encryption.EncryptionService;
public class WLDecrypt
{
private EncryptionService encryptionService ;
private ClearOrEncryptedService ces;
public WLDecrypt() {
}
/**
* Constructor supplying domain directory is for stand alone program use.
* @param domainDir
* @throws FileNotFoundException
*/
public WLDecrypt(String domainDir) throws FileNotFoundException {
File dDir = new File(domainDir);
File serializedSystemIni = new File(dDir, "security/SerializedSystemIni.dat");
if (!serializedSystemIni.exists() || !serializedSystemIni.isFile()) {
throw new FileNotFoundException("Unable to locate " + serializedSystemIni.getAbsolutePath());
}
encryptionService = SerializedSystemIni.getEncryptionService(dDir.getAbsolutePath());
ces = new ClearOrEncryptedService(encryptionService);
}
public String decrypt(String encrypted) {
String returnText = encrypted;
if (encryptionService == null){
encryptionService = SerializedSystemIni.getEncryptionService();
ces = new ClearOrEncryptedService(encryptionService);
}
if(encrypted != null) {
if (encrypted.startsWith("{AES}")) {
returnText = ces.decrypt(encrypted);
} else if (encrypted.startsWith("{3DES}")) {
returnText = ces.decrypt(encrypted);
}
}
return returnText;
}
/**
* @param args
*/
public static void main(String[] args)
{
// System.out.println("Classpath: "+ System.getProperty("java.class.path"));
if (args.length == 2) {
try
{
String domainDir = args[0];
String encString = args[1];
WLDecrypt wld;
wld = new WLDecrypt(domainDir);
String clearText = wld.decrypt(encString);
System.out.println(clearText);
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Execute the program
java -classpath ".:$WL_HOME/modules/clients/com.oracle.webservices.wls.jaxws-wlswss-client.jar:$WL_HOME/../oracle_common/modules/oracle.rsa/cryptoj.jar" net.retail.security.WLDecrypt /home/jp295m/codebase/wl12cr2/opus_wl12cr2/insys/bea/opus-insys-domain/ {AES}pBy+VqJvF3ms849Y5kOKxF8iZI+mqIlhFsiAkCqZxA4jjdV9RJSfSv8H2cK6KXif