Search in sources :

Example 1 with ODirectMemoryStorage

use of com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage in project orientdb by orientechnologies.

the class OServer method openDatabase.

public ODatabase<?> openDatabase(final String iDbUrl, final OToken iToken) {
    final String path = getStoragePath(iDbUrl);
    final ODatabaseInternal<?> database = new ODatabaseDocumentTx(path);
    if (database.isClosed()) {
        final OStorage storage = database.getStorage();
        if (storage instanceof ODirectMemoryStorage && !storage.exists())
            database.create();
        else
            database.open(iToken);
    }
    return database;
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODirectMemoryStorage(com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage)

Example 2 with ODirectMemoryStorage

use of com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage in project orientdb by orientechnologies.

the class OServer method openDatabase.

public ODatabaseDocumentTx openDatabase(final ODatabaseDocumentTx database, final String user, final String password, final ONetworkProtocolData data, final boolean iBypassAccess) {
    final OStorage storage = database.getStorage();
    if (database.isClosed()) {
        if (storage instanceof ODirectMemoryStorage && !storage.exists()) {
            try {
                database.create();
            } catch (OStorageException e) {
            }
        } else {
            if (iBypassAccess) {
                // BYPASS SECURITY
                openDatabaseBypassingSecurity(database, data, user);
            } else {
                // TRY WITH SERVER'S AUTHENTICATION
                OServerUserConfiguration serverUser = serverLogin(user, password, "database.passthrough");
                if (serverUser != null) {
                    // Why do we use the returned serverUser name instead of just passing-in user?
                    // Because in some security implementations the user is embedded inside a ticket of some kind
                    // that must be decrypted to retrieve the actual user identity. If serverLogin() is successful,
                    // that user identity is returned.
                    // SERVER AUTHENTICATED, BYPASS SECURITY
                    openDatabaseBypassingSecurity(database, data, serverUser.name);
                } else {
                    // TRY DATABASE AUTHENTICATION
                    database.open(user, password);
                    if (data != null) {
                        data.serverUser = false;
                        data.serverUsername = null;
                    }
                }
            }
        }
    }
    return database;
}
Also used : OStorageException(com.orientechnologies.orient.core.exception.OStorageException) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODirectMemoryStorage(com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage)

Aggregations

OStorage (com.orientechnologies.orient.core.storage.OStorage)2 ODirectMemoryStorage (com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage)2 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)1