@Override public OSecurityUser getUser() { if (internal != null) return internal.getUser(); return null; }
public OSecurityUser getUser() { return database.getUser(); }
public OSecurityUser getEffectiveUser() { OSecurityUser ret = getUser(); return ret!=null?ret:getDatabase().getUser(); }
public OSecurityUser getEffectiveUser() { OSecurityUser ret = getUser(); return ret!=null?ret:getDatabase().getUser(); }
protected void checkForSystemClusters(final ODatabaseDocumentInternal iDatabase, final int[] iClusterIds) { for (int clId : iClusterIds) { final OCluster cl = iDatabase.getStorage().getClusterById(clId); if (cl != null && cl.isSystemCluster()) { final OSecurityUser dbUser = iDatabase.getUser(); if (dbUser == null || dbUser.allow(ORule.ResourceGeneric.SYSTEM_CLUSTERS, null, ORole.PERMISSION_READ) != null) // AUTHORIZED break; } } }
public OrientBaseGraph(final OPartitionedDatabasePool pool, final Settings iConfiguration) { this.pool = pool; database = pool.acquire(); makeActive(); putInInitializationStack(); this.username = getDatabase().getUser() != null ? getDatabase().getUser().getName() : null; readDatabaseConfiguration(); configure(iConfiguration); }
final OSecurityUser currentUser = ODatabaseRecordThreadLocal.instance().get().getUser(); if (currentUser != null) {
final boolean userChanged = checkSpecificUserConditions(user.getName()); final ODatabaseDocumentInternal db = (ODatabaseDocumentInternal) connectionProvider.get(); final OSecurityUser original = db.getUser(); if (userChanged) {
protected void addSuperClassInternal(ODatabaseDocumentInternal database, final OClass superClass) { acquireSchemaWriteLock(); try { final OClassImpl cls; if (superClass instanceof OClassAbstractDelegate) cls = (OClassImpl) ((OClassAbstractDelegate) superClass).delegate; else cls = (OClassImpl) superClass; if (cls != null) { // CHECK THE USER HAS UPDATE PRIVILEGE AGAINST EXTENDING CLASS final OSecurityUser user = database.getUser(); if (user != null) user.allow(ORule.ResourceGeneric.CLASS, cls.getName(), ORole.PERMISSION_UPDATE); if (superClasses.contains(superClass)) { throw new OSchemaException( "Class: '" + this.getName() + "' already has the class '" + superClass.getName() + "' as superclass"); } cls.addBaseClass(this); superClasses.add(cls); } } finally { releaseSchemaWriteLock(); } }
private boolean isUsingRestrictedClasses() { boolean restrictedClasses = false; final OSecurityUser user = getDatabase().getUser(); if (parsedTarget.getTargetClasses() != null && user != null && user.checkIfAllowed(ORule.ResourceGeneric.BYPASS_RESTRICTED, null, ORole.PERMISSION_READ) == null) { for (String className : parsedTarget.getTargetClasses().keySet()) { final OClass cls = getDatabase().getMetadata().getImmutableSchemaSnapshot().getClass(className); if (cls.isSubClassOf(OSecurityShared.RESTRICTED_CLASSNAME)) { restrictedClasses = true; break; } } } return restrictedClasses; }
private void logProfiling() { if (executionPlan.getStatement() != null && Orient.instance().getProfiler().isRecording()) { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) { final OSecurityUser user = db.getUser(); final String userString = user != null ? user.toString() : null; Orient.instance().getProfiler() .stopChrono("db." + ODatabaseRecordThreadLocal.instance().get().getName() + ".command.sql." + executionPlan.getStatement(), "Command executed against the database", System.currentTimeMillis() - totalExecutionTime, "db.*.command.*", null, userString); } } }
@Override public boolean authenticate(String username, String password) { boolean ret = super.authenticate(username, password); OrienteerWebApplication app = OrienteerWebApplication.get(); UserOnlineModule onlineModule = app.getServiceInstance(UserOnlineModule.class); if(ret) { perspective=null; String locale = getDatabase().getUser().getDocument().field(OrienteerLocalizationModule.OPROPERTY_LOCALE); onlineModule.updateOnlineUser(getUser(), true); if (!Strings.isNullOrEmpty(locale)) { Locale localeForLanguage = Locale.forLanguageTag(locale); if (localeForLanguage != null) { OrienteerWebSession.get().setLocale(localeForLanguage); } } onlineModule.updateSessionUser(getUser(), getId()); } return ret; }
@Override public void start(RequestCycle cycle) { OrientDbWebSession session = OrientDbWebSession.get(); ODatabaseDocumentInternal db = session.getDatabase(); //It's required to have ability to check security rights locally OSecurityUser oUser = session.getUser(); OSecurityUser dbUser = db.getUser(); if(oUser!=null && oUser.getDocument()!=null && oUser.getDocument().getIdentity()!=null && (!oUser.getDocument().getIdentity().isValid() || dbUser==null || !Objects.equal(dbUser.getName(), oUser.getName()))) { db.setUser(db.getMetadata().getSecurity().getUser(oUser.getName())); } db.begin(); }
@Override public void start(RequestCycle cycle) { OrientDbWebSession session = OrientDbWebSession.get(); ODatabaseDocumentInternal db = session.getDatabase(); //It's required to have ability to check security rights locally OSecurityUser oUser = session.getUser(); OSecurityUser dbUser = db.getUser(); if(oUser!=null && oUser.getDocument()!=null && oUser.getDocument().getIdentity()!=null && (!oUser.getDocument().getIdentity().isValid() || dbUser==null || !Objects.equal(dbUser.getName(), oUser.getName()))) { db.setUser(db.getMetadata().getSecurity().getUser(oUser.getName())); } db.begin(); }
@Override public boolean authenticate(String username, String password) { ODatabaseDocumentInternal currentDB = getDatabase(); try { boolean inTransaction = currentDB.getTransaction().isActive(); IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings(); ODatabaseDocumentInternal newDB = settings.getDatabasePoolFactory().get(settings.getDBUrl(), username, password).acquire(); if(newDB!=currentDB) { currentDB.activateOnCurrentThread(); currentDB.commit(); currentDB.close(); newDB.activateOnCurrentThread(); } setUser(username, password); userModel.setObject(newDB.getUser().getDocument()); // user = newDB.getMetadata().getSecurity().getUser(username); // newDB.setUser(user); if(inTransaction && !newDB.getTransaction().isActive()) newDB.begin(); return true; } catch (OSecurityAccessException e) { currentDB.activateOnCurrentThread(); return false; } }
@Override public boolean authenticate(String username, String password) { ODatabaseDocumentInternal currentDB = getDatabase(); try { boolean inTransaction = currentDB.getTransaction().isActive(); IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings(); ODatabaseDocumentInternal newDB = settings.getDatabasePoolFactory().get(settings.getDBUrl(), username, password).acquire(); if(newDB!=currentDB) { currentDB.activateOnCurrentThread(); currentDB.commit(); currentDB.close(); newDB.activateOnCurrentThread(); } setUser(username, password); userModel.setObject(newDB.getUser().getDocument()); // user = newDB.getMetadata().getSecurity().getUser(username); // newDB.setUser(user); if(inTransaction && !newDB.getTransaction().isActive()) newDB.begin(); return true; } catch (OSecurityAccessException e) { currentDB.activateOnCurrentThread(); return false; } }