FileDocCategorySizeDatePackage
WssServerConfigXMLTransfer.javaAPI DocGlassfish v2 API5478Fri May 04 22:35:08 BST 2007com.sun.enterprise.tools.upgrade.miscconfig

WssServerConfigXMLTransfer

public class WssServerConfigXMLTransfer extends Object

Fields Summary
private com.sun.enterprise.util.i18n.StringManager
stringManager
private Logger
logger
Constructors Summary
public WssServerConfigXMLTransfer()
Creates a new instance of WssServerConfigXMLTransfer


           
      
Methods Summary
private voidmodifyContent(java.io.File xmlFile)

        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);
        }
    
public voidtransform(java.lang.String targetFileName)

        logger.log(Level.INFO, stringManager.
            getString("upgrade.configTransfers.wssServerConfig.startMessage"));
        File targetFile = new File(targetFileName);
        this.modifyContent(targetFile);