DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver((org.xml.sax.helpers.DefaultHandler)Class.forName
("com.sun.enterprise.config.serverbeans.ServerValidationHandler").newInstance());
Document document = builder.parse( xmlFile );
Element docEle = document.getDocumentElement();
// Need to obtain the element named xwss:Encrypt
NodeList encryptElements = docEle.getElementsByTagName("xwss:Encrypt");
for(int lh =0; lh < encryptElements.getLength(); lh++){
Element encryptElement = ((Element)encryptElements.item(lh));
String encryptAttr = encryptElement.getAttribute("keyEncryptionAlgorithm");
if(encryptAttr != null) {
if(encryptAttr.equals("RSA_v1dot5")) {
//Remove this attribute
encryptElement.removeAttribute("keyEncryptionAlgorithm");
}
}
}
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(new FileOutputStream(xmlFile));
transformer.transform(source, result);
}catch (Exception ex){
// Log error
logger.log(Level.SEVERE, stringManager.
getString("upgrade.configTransfers.wssServerConfig.startFailureMessage",ex.getMessage()), ex);
}