MondrianCatalogHelper implements IAclAwareMondrianCatalogService { @VisibleForTesting org.w3c.dom.Document getMondrianXmlDocument( InputStream is ) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory factory = XMLParserFactoryProducer.createSecureDocBuilderFactory(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse( is ); } @VisibleForTesting @Deprecated  MondrianCatalogHelper( IAclNodeHelper aclHelper );  MondrianCatalogHelper();  MondrianCatalogHelper( boolean useLegacyDbName ); @Deprecated static MondrianCatalogHelper getInstance(); @Override synchronized void reInit( final IPentahoSession pentahoSession ); String generateInMemoryDatasourcesXml( IUnifiedRepository unifiedRepository ); synchronized String getDataSourcesConfig(); synchronized void setDataSourcesConfig( final String dataSourcesConfig ); @Override List<MondrianCatalog> listCatalogs( final IPentahoSession pentahoSession, final boolean jndiOnly ); @Override synchronized void addCatalog( final MondrianCatalog catalog, final boolean overwrite,
                                       final IPentahoSession pentahoSession ); @Override void addCatalog( InputStream inputStream, MondrianCatalog catalog, boolean overwriteInRepossitory,
                          IPentahoSession session ); @Override synchronized void addCatalog( InputStream schemaInputStream, final MondrianCatalog catalog,
                                       final boolean overwrite, RepositoryFileAcl acl,
                                       final IPentahoSession pentahoSession ); synchronized void setAclHelper( IAclNodeHelper helper ); @Override void setAclFor( String catalogName, RepositoryFileAcl acl ); @Override RepositoryFileAcl getAclFor( String catalogName ); void importSchema( File mondrianFile, String databaseConnection, String parameters ); @Override MondrianCatalog getCatalog( final String context, final IPentahoSession pentahoSession ); MondrianCatalogComplementInfo getCatalogComplementInfoMap( String name ); @Override MondrianSchema loadMondrianSchema( final String solutionLocation, final IPentahoSession pentahoSession ); boolean isUseSchemaNameAsCatalogName(); void setUseSchemaNameAsCatalogName( final boolean useSchemaNameAsCatalogName ); static int addToCatalog( String baseUrl, boolean enableXmla, String schemaSolutionPath,
                                  IPentahoSession session, String jndiName, boolean overwrite ); @Override void removeCatalog( final String catalogName, final IPentahoSession pentahoSession ); static final String MONDRIAN_DATASOURCE_FOLDER; static String MONDRIAN_CATALOG_CACHE_REGION; }
@Test( timeout = 2000, expected = SAXException.class ) public void shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven() throws IOException, ParserConfigurationException, SAXException { mch.getMondrianXmlDocument( new StringBufferInputStream( XmlTestConstants.MALICIOUS_XML ) ); fail(); }
@Test public void shouldNotFailAndReturnNotNullWhenLegalXmlIsGiven() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<slave_config>" + "</slave_config>"; assertNotNull( mch.getMondrianXmlDocument( new StringBufferInputStream( xml ) ) ); }