Search in sources :

Example 16 with OSecurityAccessException

use of com.orientechnologies.orient.core.exception.OSecurityAccessException in project wicket-orientdb by OrienteerBAP.

the class OrientDbWebSession method authenticate.

@Override
public boolean authenticate(String username, String password) {
    ODatabaseSession currentDB = getDatabaseSession();
    try {
        boolean inTransaction = currentDB.getTransaction().isActive();
        IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings();
        ODatabaseSession newDB = settings.getContext().cachedPool(settings.getDbName(), username, password).acquire();
        if (newDB != currentDB) {
            currentDB.activateOnCurrentThread();
            currentDB.commit();
            currentDB.close();
            newDB.activateOnCurrentThread();
        }
        setUser(username, password);
        userModel.setObject(newDB.getUser().getDocument());
        if (inTransaction && !newDB.getTransaction().isActive()) {
            newDB.begin();
        }
        return true;
    } catch (OSecurityAccessException e) {
        currentDB.activateOnCurrentThread();
        return false;
    }
}
Also used : OSecurityAccessException(com.orientechnologies.orient.core.exception.OSecurityAccessException) ODatabaseSession(com.orientechnologies.orient.core.db.ODatabaseSession)

Aggregations

OSecurityAccessException (com.orientechnologies.orient.core.exception.OSecurityAccessException)16 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)4 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 OLockException (com.orientechnologies.common.concur.lock.OLockException)3 IOException (java.io.IOException)3 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)2 OException (com.orientechnologies.common.exception.OException)2 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)2 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)2 OIndex (com.orientechnologies.orient.core.index.OIndex)2 OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)2 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)2 OUser (com.orientechnologies.orient.core.metadata.security.OUser)2 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)2 ODistributedOperationException (com.orientechnologies.orient.server.distributed.task.ODistributedOperationException)2 ODistributedRecordLockedException (com.orientechnologies.orient.server.distributed.task.ODistributedRecordLockedException)2 ORemoteTask (com.orientechnologies.orient.server.distributed.task.ORemoteTask)2 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 ODatabaseSession (com.orientechnologies.orient.core.db.ODatabaseSession)1