Add security check on cached sequences
@@ -23,6 +23,8 @@ import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.exception.ODatabaseException;
import com.orientechnologies.orient.core.metadata.schema.OType;
+import com.orientechnologies.orient.core.metadata.security.ORole;
+import com.orientechnologies.orient.core.metadata.security.ORule;
import com.orientechnologies.orient.core.record.impl.ODocument;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -156,6 +158,7 @@ public class OSequenceCached extends OSequence {
@Override
public long next() throws OSequenceLimitReachedException, ODatabaseException {
+ checkSecurity();
boolean shouldGoOverDistributted = shouldGoOverDistrtibute();
if (shouldGoOverDistributted) {
return nextWithNewCurrentValue(cacheStart, true);
@@ -163,6 +166,14 @@ public class OSequenceCached extends OSequence {
return nextWork();
}
+ private void checkSecurity() {
+ getDatabase()
+ .checkSecurity(
+ ORule.ResourceGeneric.CLASS,
+ ORole.PERMISSION_UPDATE,
+ this.getDocument().getClassName());
+ }
+
@Override
public long nextWork() throws OSequenceLimitReachedException {
ODatabaseDocumentInternal mainDb = getDatabase();
