} catch (Throwable t) {
String message =
"Password cipher '" + passwordCipherClass +
"' not found in META-INF/org.apache.openejb.resource.jdbc.PasswordCipher.";
throw new SQLNestedException(message, t);
}
pwdCipher = impls.get(passwordCipherClass);
//
final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
final URL url = tccl.getResource("META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/" + passwordCipherClass);
if (url != null) {
try {
final String clazz = new BufferedReader(new InputStreamReader(url.openStream())).readLine().trim();
pwdCipher = tccl.loadClass(clazz).asSubclass(PasswordCipher.class);
} catch (Exception e) {
// ignored
}
}
// if not found in META-INF/org.apache.openejb.resource.jdbc.PasswordCipher
// we can try to load the class.
if (null == pwdCipher) {
try {
try {
pwdCipher = Class.forName(passwordCipherClass).asSubclass(PasswordCipher.class);
} catch (ClassNotFoundException cnfe) {
pwdCipher = tccl.loadClass(passwordCipherClass).asSubclass(PasswordCipher.class);
}
} catch (Throwable t) {
String message = "Cannot load password cipher class '" + passwordCipherClass + "'";
throw new SQLNestedException(message, t);
}
}
// Create an instance
PasswordCipher cipher = null;
try {
cipher = pwdCipher.newInstance();
} catch (Throwable t) {
String message = "Cannot create password cipher instance";
throw new SQLNestedException(message, t);
}
return cipher;
}