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;
}
}
Aggregations