protected AbstractMDXDataFactory createDataFactory() {
    final JdbcConnectionDefinition connectionDefinition =
        (JdbcConnectionDefinition) getDialogModel().getConnections().getSelectedItem();

    if (connectionDefinition instanceof JndiConnectionDefinition) {
      final JndiConnectionDefinition jcd = (JndiConnectionDefinition) connectionDefinition;
      final JndiConnectionProvider provider = new JndiConnectionProvider();
      provider.setConnectionPath(jcd.getJndiName());
      provider.setUsername(jcd.getUsername());
      provider.setPassword(jcd.getPassword());
      return new SimpleBandedMDXDataFactory(provider);
    } else if (connectionDefinition instanceof DriverConnectionDefinition) {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      final DriverConnectionProvider provider = new DriverConnectionProvider();
      provider.setDriver(dcd.getDriverClass());
      provider.setUrl(dcd.getConnectionString());

      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements()) {
        final String key = (String) keys.nextElement();
        provider.setProperty(key, properties.getProperty(key));
      }
      return new SimpleBandedMDXDataFactory(provider);
    } else {
      return null;
    }
  }
  public String writeReport(
      final XmlWriter xmlWriter, final OlapConnectionProvider connectionProvider)
      throws IOException, BundleWriterException {
    if (xmlWriter == null) {
      throw new NullPointerException();
    }
    if (connectionProvider == null) {
      throw new NullPointerException();
    }

    final DriverConnectionProvider driverProvider = (DriverConnectionProvider) connectionProvider;
    xmlWriter.writeTag(Olap4JDataFactoryModule.NAMESPACE, "connection", XmlWriterSupport.OPEN);

    xmlWriter.writeTag(Olap4JDataFactoryModule.NAMESPACE, "driver", XmlWriterSupport.OPEN);
    xmlWriter.writeTextNormalized(driverProvider.getDriver(), false);
    xmlWriter.writeCloseTag();

    xmlWriter.writeTag(Olap4JDataFactoryModule.NAMESPACE, "url", XmlWriterSupport.OPEN);
    xmlWriter.writeTextNormalized(driverProvider.getUrl(), false);
    xmlWriter.writeCloseTag();

    xmlWriter.writeTag(Olap4JDataFactoryModule.NAMESPACE, "properties", XmlWriterSupport.OPEN);
    final String[] propertyNames = driverProvider.getPropertyNames();
    for (int i = 0; i < propertyNames.length; i++) {
      final String name = propertyNames[i];
      final String value = driverProvider.getProperty(name);
      xmlWriter.writeTag(
          Olap4JDataFactoryModule.NAMESPACE, "property", "name", name, XmlWriterSupport.OPEN);
      if (name.toLowerCase().contains("password")) {
        xmlWriter.writeTextNormalized(
            PasswordEncryptionService.getInstance().encrypt(value), false);
      } else {
        xmlWriter.writeTextNormalized(value, false);
      }
      xmlWriter.writeCloseTag();
    }
    xmlWriter.writeCloseTag();

    xmlWriter.writeCloseTag();
    return null;
  }