String className =
sce.getServletContext().getInitParameter(
INIT_PARAM_INITIALIZER_CLASS_NAME);
if (StringUtils.isEmpty(className)) {
throw new EncryptionInitializationException(
INIT_PARAM_INITIALIZER_CLASS_NAME + " context " +
"initialization parameter not set in web.xml");
}
Class initializerClass = null;
try {
initializerClass =
Thread.currentThread().getContextClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
throw new EncryptionInitializationException(e);
}
if (!WebPBEInitializer.class.isAssignableFrom(initializerClass)) {
throw new EncryptionInitializationException("Class " +
className + " does not implement interface " +
WebPBEInitializer.class.getName());
}
WebPBEInitializer initializer = null;
try {
initializer =
(WebPBEInitializer) initializerClass.newInstance();
} catch (InstantiationException e) {
throw new EncryptionInitializationException(e);
} catch (IllegalAccessException e) {
throw new EncryptionInitializationException(e);
}
// Let the user initialize his/her encryptors and WebPBEConfig objects.
initializer.initializeWebPBEConfigs();