public static void Revoke(HeContext heContext, ObjectKey key, bool isPersistent, int userId, int eSpaceId)
        {
            int tenantId = heContext.Session.TenantId;

            if (userId == 0)
            {
                userId = heContext.Session.UserId;
            }

            if (userId == heContext.Session.UserId)
            {
                heContext.Session.RemoveRole(heContext.GetRoleIdFromKey(key.ToString(ObjectKey.DatabaseFormat), eSpaceId));
            }

            if (isPersistent && userId != 0)
            {
                using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetRequestTransaction()) {
                    // Check userID exists in DB
                    if (Convert.ToInt32(DBRuntimePlatform.Instance.GetNumUsersWithId(tran, userId)) != 1)
                    {
                        throw new InvalidOperationException("Invalid User Id");
                    }

                    DBRuntimePlatform.Instance.DeleteUserRole(tran, userId, eSpaceId, key, tenantId);
                }
            }
        }
        public static bool Check(HeContext heContext, ObjectKey key, int userId, int eSpaceId)
        {
            bool hasRole;

            int tenantId = heContext.Session.TenantId;

            if (userId == 0)
            {
                userId = heContext.Session.UserId;
            }

            if (userId == heContext.Session.UserId)
            {
                return(heContext.Session.CheckRole(heContext.GetRoleIdFromKey(key.ToString(ObjectKey.DatabaseFormat), eSpaceId)));
            }
            else
            {
                // Check userID exists in DB
                using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetReadOnlyTransaction()) {
                    if (Convert.ToInt32(DBRuntimePlatform.Instance.GetNumUsersWithId(tran, userId)) != 1)
                    {
                        throw new InvalidOperationException("Invalid User Id");
                    }

                    // see if user has permission
                    hasRole = DBRuntimePlatform.Instance.CheckRole(tran, userId, eSpaceId, key, tenantId);
                }
            }
            return(hasRole);
        }
예제 #3
0
        public static void StoreUpdateValues <T>(MenuCommand menuCommand)
            where T : Component
        {
            if (Application.isPlaying)
            {
                T objectComponent = menuCommand.context as T;

                Scene objectScene = objectComponent.gameObject.scene;

                if (objectScene.IsValid())
                {
                    string    scenePath       = objectScene.path;
                    string    objectName      = objectComponent.transform.GetPathInHierarchy();
                    ObjectKey storedObjectKey = GetStoredObjectKey <T>(objectName, scenePath);

                    Debug.Log("[RuntimeAssetUpdater] Storing changes on object : " + objectName);

                    GameObject obj = new GameObject(storedObjectKey.ToString());
                    obj.hideFlags = HideFlags.HideInHierarchy;
                    T componentCopy = obj.GetComponent <T>();
                    if (componentCopy == null)
                    {
                        componentCopy = obj.AddComponent <T>();
                    }

                    if (!Directory.Exists(TEMP_ASSET_PATH))
                    {
                        Directory.CreateDirectory(TEMP_ASSET_PATH);
                    }

                    string     assetPath  = AssetDatabase.GenerateUniqueAssetPath(TEMP_ASSET_PATH + typeof(T) + ".prefab");
                    GameObject copyPrefab = PrefabUtility.CreatePrefab(assetPath, componentCopy.CopyComponent(objectComponent).gameObject);

                    List <string> storedSceneObjects;
                    if (STORED_OBJECTS_BY_SCENE.TryGetValue(scenePath, out storedSceneObjects))
                    {
                        if (!storedSceneObjects.Contains(objectName))
                        {
                            storedSceneObjects.Add(objectName);
                        }
                    }
                    else
                    {
                        STORED_OBJECTS_BY_SCENE.Add(scenePath, new List <string> {
                            objectName
                        });
                    }

                    Component storedComponent;
                    if (STORED_COMPONENT_BY_OBJECT_KEY.TryGetValue(storedObjectKey, out storedComponent))
                    {
                        STORED_COMPONENT_BY_OBJECT_KEY[storedObjectKey] = copyPrefab.GetComponent <T>();
                    }
                    else
                    {
                        STORED_COMPONENT_BY_OBJECT_KEY.Add(storedObjectKey, copyPrefab.GetComponent <T>());
                    }
                }
            }
        }
예제 #4
0
 public string ToString(bool includeCompoundKey)
 {
     if (!includeCompoundKey && debuggerHashStr == null)
     {
         return(eSpaceKey.ToString() + SeparatorChar +
                (objectKey != null ? objectKey.ToString() : ""));
     }
     else
     {
         return
             ((eSpaceKey != null ? eSpaceKey.ToString() : "") + SeparatorChar +
              (objectKey != null ? objectKey.ToString() : "") + SeparatorChar +
              (includeCompoundKey && compoundKeyStr != null ? compoundKeyStr : "") + SeparatorChar +
              (debuggerHashStr != null ? debuggerHashStr : ""));
     }
 }
 public static string DatabaseValue(ObjectKey key)
 {
     if (key == null)
     {
         return(string.Empty);
     }
     else
     {
         return(key.ToString(ObjectKey.DatabaseFormat));
     }
 }
예제 #6
0
 void LogOperation(
     string operation,
     ObjectKey key,
     string contentType,
     long?objectSize,
     long?storageSize,
     Stopwatch timer,
     OperationStatus status,
     string details
     )
 {
     this.logger.Information(
         "{Operation} {Key} ({ContentType} {ObjectBytes}bytes/{StorageBytes}compressed): {ElapsedMs}ms: {Status}: {Details}",
         operation, key.ToString(), contentType, objectSize, storageSize, timer.ElapsedMilliseconds, status.ToString(), details);
 }
        public static void Grant(HeContext heContext, ObjectKey key, bool isPersistent, int userId, int eSpaceId)
        {
            int tenantId = heContext.Session.TenantId;

            if (userId == 0)
            {
                userId = heContext.Session.UserId;
            }

            if (userId == heContext.Session.UserId)
            {
                // update session state
                heContext.Session.AddRole(heContext.GetRoleIdFromKey(key.ToString(ObjectKey.DatabaseFormat), eSpaceId), null);
            }

            if (isPersistent)
            {
                int roleId;

                if (userId != 0)
                {
                    // Check userID exists in DB
                    using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetRequestTransaction()) {
                        if (Convert.ToInt32(DBRuntimePlatform.Instance.GetNumUsersWithId(tran, userId)) != 1)
                        {
                            throw new InvalidOperationException("Invalid User Id");
                        }

                        roleId = Convert.ToInt32(DBRuntimePlatform.Instance.GetRoleId(tran, eSpaceId, key));

                        // Check for a previous grant
                        int grantCount = Convert.ToInt32(DBRuntimePlatform.Instance.CheckRole(tran, userId, roleId, tenantId));

                        if (grantCount == 0)
                        {
                            DBRuntimePlatform.Instance.CreateUserRole(tran, userId, tenantId, roleId);
                        }
                    }
                }
            }
        }
예제 #8
0
 public override string ToString()
 {
     return("{0} {1} {2} ({3})".F(Status.ToString(), ElementKind, ElementName, ElementKey.ToString()));
 }
예제 #9
0
 public override string ToString()
 {
     return("{0} ({1})".F(OriginalKey.ToString(), Kind));
 }
예제 #10
0
        public Uri GetObjectUri(ObjectKey key)
        {
            string resourcePath = UrlEncode(this.bucket + "/" + key.ToString(), path: true);

            return(new Uri("https://s3-us-west-2.amazonaws.com/" + resourcePath));
        }