|
16 | 16 | import com.qualisystems.pythonDriverPlugin.updaters.IUpdater; |
17 | 17 | import com.qualisystems.pythonDriverPlugin.updaters.UpdaterFactory; |
18 | 18 | import org.jetbrains.annotations.NotNull; |
| 19 | +import org.xml.sax.*; |
19 | 20 |
|
20 | 21 | import javax.xml.bind.JAXBContext; |
21 | 22 | import javax.xml.bind.JAXBElement; |
22 | 23 | import javax.xml.bind.JAXBException; |
23 | 24 | import javax.xml.bind.Unmarshaller; |
| 25 | +import javax.xml.parsers.ParserConfigurationException; |
| 26 | +import javax.xml.parsers.SAXParserFactory; |
| 27 | +import javax.xml.transform.sax.SAXSource; |
24 | 28 | import java.io.File; |
| 29 | +import java.io.FileReader; |
25 | 30 | import java.io.IOException; |
26 | 31 | import java.io.InputStream; |
27 | 32 | import java.net.UnknownHostException; |
@@ -132,15 +137,34 @@ private DriverPublisherSettings getDeploymentSettingsFromFile(File deploymentSet |
132 | 137 | try { |
133 | 138 | InputStream inputStream = Files.newInputStream(deploymentSettingsFile.toPath()); |
134 | 139 | jaxbContext = JAXBContext.newInstance(ObjectFactory.class); |
| 140 | + |
| 141 | + SAXParserFactory spf = SAXParserFactory.newInstance(); |
| 142 | + spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); |
| 143 | + spf.setFeature("http://xml.org/sax/features/validation", false); |
| 144 | + |
| 145 | + XMLReader xmlReader = spf.newSAXParser().getXMLReader(); |
| 146 | + InputSource inputSource = new InputSource(inputStream); |
| 147 | + SAXSource source = new SAXSource(xmlReader, inputSource); |
| 148 | + |
135 | 149 | Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); |
136 | | - JAXBElement<PropertiesType> unmarshalledObject = (JAXBElement<PropertiesType>)unmarshaller.unmarshal(inputStream); |
| 150 | + |
| 151 | + JAXBElement<PropertiesType> unmarshalledObject = (JAXBElement<PropertiesType>)unmarshaller.unmarshal(source); |
137 | 152 |
|
138 | 153 | PropertiesType properties = unmarshalledObject.getValue(); |
139 | 154 | DriverPublisherSettings settings = DriverPublisherSettings.fromProperties(properties); |
140 | 155 | return settings; |
141 | 156 |
|
142 | 157 | } catch (JAXBException e) { |
143 | 158 | throw new IOException(e); |
| 159 | + } catch (SAXNotSupportedException e) { |
| 160 | + e.printStackTrace(); |
| 161 | + } catch (SAXNotRecognizedException e) { |
| 162 | + e.printStackTrace(); |
| 163 | + } catch (SAXException e) { |
| 164 | + e.printStackTrace(); |
| 165 | + } catch (ParserConfigurationException e) { |
| 166 | + e.printStackTrace(); |
144 | 167 | } |
| 168 | + return null; |
145 | 169 | } |
146 | 170 | } |
0 commit comments