final boolean REJECTINVALID= configuration.getBoolean("widget.deployment.rejectinvalidsignatures");
final boolean REJECTUNTRUSTED= configuration.getBoolean("widget.deployment.rejectuntrustedsignatures");
final String PASSWORD = configuration.getString("widget.deployment.trustedkeystore.password");
final String KEYSTORE = configuration.getString("widget.deployment.trustedkeystore");//$NON-NLS-1$
W3CWidgetFactory fac = new W3CWidgetFactory();
fac.setLocales(locales);
fac.setLocalPath(contextPath+localWidgetFolderPath);
fac.setOutputDirectory(WIDGETFOLDER);
fac.setFeatures(Features.getFeatureNames());
fac.setStartPageProcessor(new StartPageProcessor());
if (VERIFYSIGNATURE) {
KeyStore keyStore = KeyStore.getInstance("JKS");
String digSigSchema = context
.getRealPath("/WEB-INF/classes/org/apache/wookie/util/digitalsignature/xmldsig-core-schema.xsd");
InputStream stream = context.getResourceAsStream("/WEB-INF/classes/" + KEYSTORE);
if (stream == null) {
stream = context.getResourceAsStream("/WEB-INF/classes/" + "generated-" + KEYSTORE);
}
if (stream == null) {
FileOutputStream fos = new FileOutputStream(context
.getRealPath("/WEB-INF/classes") + File.separatorChar + "generated-" + KEYSTORE);
keyStore.load(null, PASSWORD.toCharArray());
keyStore.store(fos, PASSWORD.toCharArray());
fos.close();
fac.setDigitalSignatureParser(new DigitalSignatureProcessor(keyStore,
digSigSchema, REJECTINVALID, REJECTUNTRUSTED));
logger.info(localizedMessages.getString("WidgetHotDeploy.4"));
} else {
keyStore.load(stream, PASSWORD.toCharArray());
stream.close();
fac.setDigitalSignatureParser(new DigitalSignatureProcessor(keyStore,
digSigSchema, REJECTINVALID, REJECTUNTRUSTED));
}
}
return fac;
}