use of com.orientechnologies.orient.core.metadata.security.OUser in project orientdb by orientechnologies.
the class OServerCommandAuthenticatedDbAbstract method getProfiledDatabaseInstanceBasic.
protected ODatabaseDocumentInternal getProfiledDatabaseInstanceBasic(final OHttpRequest iRequest) throws InterruptedException {
final OHttpSession session = OHttpSessionManager.getInstance().getSession(iRequest.sessionId);
if (session == null)
throw new OSecurityAccessException(iRequest.databaseName, "No session active");
// after authentication, if current login user is different compare with current DB user, reset DB user to login user
ODatabaseDocumentInternal localDatabase = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
if (localDatabase == null) {
localDatabase = (ODatabaseDocumentTx) server.openDatabase(iRequest.databaseName, session.getUserName(), session.getUserPassword());
} else {
String currentUserId = iRequest.data.currentUserId;
if (currentUserId != null && currentUserId.length() > 0 && localDatabase != null && localDatabase.getUser() != null) {
if (!currentUserId.equals(localDatabase.getUser().getIdentity().toString())) {
ODocument userDoc = localDatabase.load(new ORecordId(currentUserId));
localDatabase.setUser(new OUser(userDoc));
}
}
}
iRequest.data.lastDatabase = localDatabase.getName();
iRequest.data.lastUser = localDatabase.getUser() != null ? localDatabase.getUser().getName() : null;
return (ODatabaseDocumentTx) localDatabase.getDatabaseOwner();
}
Aggregations