use of org.xml.sax.SAXException in project zm-mailbox by Zimbra.
the class W3cDomUtil method getDom4jSAXParserWhichUsesSecureProcessing.
public static SAXParser getDom4jSAXParserWhichUsesSecureProcessing() throws XmlParseException {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setXIncludeAware(false);
factory.setValidating(false);
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (SAXNotRecognizedException | SAXNotSupportedException | ParserConfigurationException ex) {
ZimbraLog.misc.error("Problem setting up SAXParser which supports secure XML processing", ex);
throw XmlParseException.PARSE_ERROR();
}
try {
return factory.newSAXParser();
} catch (ParserConfigurationException | SAXException e) {
ZimbraLog.misc.error("Problem setting up SAXParser", e);
throw XmlParseException.PARSE_ERROR();
}
}
use of org.xml.sax.SAXException in project robo4j by Robo4J.
the class XmlConfigurationFactory method fromXml.
public static Configuration fromXml(String xml) throws ConfigurationFactoryException {
DefaultConfiguration config = new DefaultConfiguration();
SAXParser saxParser;
try {
saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(new ByteArrayInputStream(xml.getBytes(Constants.DEFAULT_ENCODING)), new ConfigurationHandler(config));
} catch (ParserConfigurationException | SAXException | IOException e) {
throw new ConfigurationFactoryException("Could not parse the configuration", e);
}
return config;
}
use of org.xml.sax.SAXException in project android_frameworks_base by ResurrectionRemix.
the class SafeSaxTest method testMissingRequiredChild.
@SmallTest
public void testMissingRequiredChild() throws Exception {
String xml = "<feed></feed>";
RootElement root = new RootElement("feed");
root.requireChild("entry");
try {
Xml.parse(xml, root.getContentHandler());
fail("expected exception not thrown");
} catch (SAXException e) {
// Expected.
}
}
use of org.xml.sax.SAXException in project android_frameworks_base by ResurrectionRemix.
the class WifiNetworkAdapter method loadAllSps.
private void loadAllSps() {
Log.d(OSUManager.TAG, "Loading all SPs");
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
for (WifiConfiguration config : wifiManager.getPrivilegedConfiguredNetworks()) {
String moTree = config.getMoTree();
if (moTree != null) {
try {
mPasspointConfigs.put(config.FQDN, new PasspointConfig(config));
} catch (IOException | SAXException e) {
Log.w(OSUManager.TAG, "Failed to parse MO: " + e);
}
}
}
}
use of org.xml.sax.SAXException in project android_frameworks_base by ResurrectionRemix.
the class DefaultDataHandler method startElement.
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
if (ROW.equals(localName)) {
if (mValues != null) {
// case 2, <Col> before <Row> insert last uri
if (mUris.empty()) {
throw new SAXException("uri is empty");
}
Uri nextUri = insertRow();
if (nextUri == null) {
throw new SAXException("insert to uri " + mUris.lastElement().toString() + " failure");
} else {
// make sure the stack lastElement save uri for more than one row
mUris.pop();
mUris.push(nextUri);
parseRow(atts);
}
} else {
int attrLen = atts.getLength();
if (attrLen == 0) {
// case 3, share same uri as last level
mUris.push(mUris.lastElement());
} else {
parseRow(atts);
}
}
} else if (COL.equals(localName)) {
int attrLen = atts.getLength();
if (attrLen != 2) {
throw new SAXException("illegal attributes number " + attrLen);
}
String key = atts.getValue(0);
String value = atts.getValue(1);
if (key != null && key.length() > 0 && value != null && value.length() > 0) {
if (mValues == null) {
mValues = new ContentValues();
}
mValues.put(key, value);
} else {
throw new SAXException("illegal attributes value");
}
} else if (DEL.equals(localName)) {
Uri u = Uri.parse(atts.getValue(URI_STR));
if (u == null) {
throw new SAXException("attribute " + atts.getValue(URI_STR) + " parsing failure");
}
int attrLen = atts.getLength() - 2;
if (attrLen > 0) {
String[] selectionArgs = new String[attrLen];
for (int i = 0; i < attrLen; i++) {
selectionArgs[i] = atts.getValue(i + 2);
}
mContentResolver.delete(u, atts.getValue(1), selectionArgs);
} else if (attrLen == 0) {
mContentResolver.delete(u, atts.getValue(1), null);
} else {
mContentResolver.delete(u, null, null);
}
} else {
throw new SAXException("unknown element: " + localName);
}
}
Aggregations