Search in sources :

Example 6 with CDatabase

use of com.google.security.zynamics.binnavi.Database.CDatabase in project binnavi by google.

the class CDatabaseFunctions method addNewDatabase.

/**
   * Adds a new database with default information to the list of known databases.
   * 
   * @param projectTree Project tree of the main window.
   */
public static void addNewDatabase(final JTree projectTree) {
    final CDatabase newDatabase = new CDatabase("New Database", CJdbcDriverNames.jdbcPostgreSQLDriverName, "localhost", "new_database", "user", "password", "identity", false, false);
    CDatabaseManager.instance().addDatabase(newDatabase);
    CNodeExpander.setSelectionPath(projectTree, newDatabase);
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase)

Example 7 with CDatabase

use of com.google.security.zynamics.binnavi.Database.CDatabase in project binnavi by google.

the class PostgreSQLNotificationProviderTest method setUp.

@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, InvalidExporterDatabaseFormatException, LoadCancelledException, CPartialLoadException, InvalidDatabaseVersionException {
    final String[] parts = CConfigLoader.loadPostgreSQL();
    databaseOne = new CDatabase("DATABASEONE", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
    databaseOne.connect();
    databaseOne.load();
    databaseOneModuleTwo = databaseOne.getContent().getModule(2);
    databaseOneModuleTwo.load();
    databaseOneFunction = databaseOneModuleTwo.getContent().getFunctionContainer().getFunction(new CAddress("7C880394", 16));
    databaseOneView = databaseOneModuleTwo.getContent().getViewContainer().getView(databaseOneFunction);
    databaseOneView.load();
    databaseTwo = new CDatabase("DATABASETWO", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
    databaseTwo.connect();
    databaseTwo.load();
    databaseTwoModuleTwo = databaseTwo.getContent().getModule(2);
    databaseTwoModuleTwo.load();
    databaseTwoFunction = databaseTwoModuleTwo.getContent().getFunctionContainer().getFunction(new CAddress("7C880394", 16));
    databaseTwoView = databaseTwoModuleTwo.getContent().getViewContainer().getView(databaseTwoFunction);
    databaseTwoView.load();
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Before(org.junit.Before)

Example 8 with CDatabase

use of com.google.security.zynamics.binnavi.Database.CDatabase in project binnavi by google.

the class PostgreSQLTypeInstanceFunctionsTests method setUp.

@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, CouldntSaveDataException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, LoadCancelledException, FileReadException {
    final String[] parts = CConfigLoader.loadPostgreSQL();
    database = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
    database.connect();
    database.load();
    try {
        final Field privateProviderField = CDatabase.class.getDeclaredField("provider");
        privateProviderField.setAccessible(true);
        provider = (SQLProvider) privateProviderField.get(database);
    } catch (final Exception exception) {
        throw new RuntimeException(exception);
    }
    provider.createDebuggerTemplate("Test Debugger", "localhost", 2222);
    final CProject project = provider.createProject("Test Project");
    provider.createAddressSpace(project, "Test Address Space");
    ConfigManager.instance().read();
    module = database.getContent().getModules().get(0);
}
Also used : Field(java.lang.reflect.Field) CProject(com.google.security.zynamics.binnavi.disassembly.CProject) CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) FileReadException(com.google.security.zynamics.binnavi.config.FileReadException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) IOException(java.io.IOException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) Before(org.junit.Before)

Example 9 with CDatabase

use of com.google.security.zynamics.binnavi.Database.CDatabase in project binnavi by google.

the class PostgreSQLConvertCalcTest method setUp.

@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, LoadCancelledException {
    final String[] parts = CConfigLoader.loadPostgreSQL();
    database = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_import", parts[1], parts[2], parts[3], false, false);
    database.connect();
    database.load();
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) Before(org.junit.Before)

Example 10 with CDatabase

use of com.google.security.zynamics.binnavi.Database.CDatabase in project binnavi by google.

the class DatabaseManager method addDatabase.

// ESCA-JAVA0138: Takes more than 5 arguments to define the whole database in one step.
// ! Adds a new database.
/**
   * Adds a new database configuration to the database manager.
   * 
   * @param description The description of the new database configuration. This is the text that is
   *        displayed in the project tree.
   * @param driver The driver that is used to connect to the database.
   * @param host Host address of the database server.
   * @param name The name of the database on the database server.
   * @param user The user that is used to connect to the database.
   * @param password The password that is used to connect to the database.
   * @param identity The identity under which the current user operates.
   * @param savePassword Flag that indicates whether the password should be saved in the
   *        configuration file.
   * @param autoConnect Flag that indicates whether this a connection to this database is
   *        established automatically when BinNavi starts.
   * @return The created database.
   * 
   * @throws IllegalArgumentException Thrown if any of the passed arguments are null.
   */
public Database addDatabase(final String description, final String driver, final String host, final String name, final String user, final String password, final String identity, final boolean savePassword, final boolean autoConnect) {
    Preconditions.checkNotNull(description, "Error: description argument can not be null");
    Preconditions.checkNotNull(driver, "Error: driver argument can not be null");
    Preconditions.checkNotNull(host, "Error: host argument can not be null");
    Preconditions.checkNotNull(name, "Error: name argument can not be null");
    final IDatabase newDatabase = m_manager.addDatabase(new CDatabase(description, driver, host, name, user, password, identity, savePassword, autoConnect));
    return ObjectFinders.getObject(newDatabase, m_databases);
}
Also used : CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)

Aggregations

CDatabase (com.google.security.zynamics.binnavi.Database.CDatabase)19 Before (org.junit.Before)13 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)2 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)2 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)2 CDatabaseManager (com.google.security.zynamics.binnavi.Database.CDatabaseManager)2 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)2 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 Tree (com.google.security.zynamics.zylib.types.trees.Tree)2 Field (java.lang.reflect.Field)2 Function (com.google.security.zynamics.binnavi.API.disassembly.Function)1 Instruction (com.google.security.zynamics.binnavi.API.disassembly.Instruction)1 View (com.google.security.zynamics.binnavi.API.disassembly.View)1 ViewContainer (com.google.security.zynamics.binnavi.API.disassembly.ViewContainer)1 MainWindow (com.google.security.zynamics.binnavi.API.gui.MainWindow)1 PluginInterface (com.google.security.zynamics.binnavi.API.plugins.PluginInterface)1