ConfigCollectorpublic class ConfigCollector extends Object implements CollectorResponsible for capturing domain.xml, sun-acc.xml, server.policy, login.conf |
Fields Summary |
---|
private static final String | PASSWORD_REPLACEMENT | private static final String | PASSWORD | private String | repositoryDir | private String | reportDir | private static Logger | logger |
Constructors Summary |
---|
public ConfigCollector(String repositoryDir, String reportDir)
this.repositoryDir = repositoryDir;
this.reportDir = reportDir;
|
Methods Summary |
---|
public com.sun.enterprise.diagnostics.Data | capture()Capture config information
WritableDataImpl dataImpl = new WritableDataImpl(DataType.CONFIG_DETAILS);
dataImpl.addChild(captureXMLFile(Constants.DOMAIN_XML));
dataImpl.addChild(captureFile(Constants.SERVER_POLICY));
dataImpl.addChild(captureFile(Constants.LOGIN_CONF));
dataImpl.addChild(captureFile(Constants.SUN_ACC));
return dataImpl;
| public com.sun.enterprise.diagnostics.Data | captureFile(java.lang.String fileName)Copies file
try {
FileUtils.copyFile(repositoryDir + fileName,
reportDir +fileName);
return new FileData(reportDir + fileName, DataType.CONFIG_DETAILS);
} catch(IOException ioe) {
logger.log(Level.WARNING,ioe.getMessage());
}
return null;
| public com.sun.enterprise.diagnostics.Data | captureXMLFile(java.lang.String fileName)Masks confidential information with **** and copies it to destination
try {
String xmlFileToModify = repositoryDir + fileName;
String destFile = reportDir + fileName;
String domainXMLDTD =
DiagnosticServiceHelper.getInstallationRoot() +
Constants.DOMAIN_XML_DTD;
Document serverXml = XmlUtils.loadXML(xmlFileToModify,
domainXMLDTD);
XmlUtils.attrSearchReplace(serverXml.getDocumentElement(),
PASSWORD, PASSWORD_REPLACEMENT);
XmlUtils.copyXMLFile(serverXml, destFile);
return new FileData(destFile, DataType.CONFIG_DETAILS);
} catch (SAXException se) {
logger.log(Level.WARNING, se.getMessage());
} catch (IOException ie) {
logger.log(Level.WARNING, ie.getMessage());
} catch (TransformerConfigurationException tce) {
logger.log(Level.WARNING, tce.getMessage());
} catch (TransformerException te) {
logger.log(Level.WARNING,te.getMessage());
} catch (ParserConfigurationException pce) {
logger.log(Level.WARNING,pce.getMessage());
}
return null;
|
|