Example #1
0
        public IList <ResourceHandle> GetAuthorizedResources(string principalId, string operationId)
        {
            if (string.IsNullOrEmpty(principalId))
            {
                throw new ArgumentNullException("principalId");
            }

            if (string.IsNullOrEmpty(operationId))
            {
                throw new ArgumentNullException("operationId");
            }

            return
                ((IList <ResourceHandle>)
                 ExecuteMethodWithCacheLookUp("GetAuthorizedResources",
                                              delegate(string[] parameters) {
                DataSet ds = DBHelper.ExecuteDataSet("GetAuthorizedResources", parameters);
                if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    return new string[0];
                }

                DataTable tb = ds.Tables[0];
                List <ResourceHandle> res = new List <ResourceHandle>(tb.Rows.Count);
                for (int ii = 0; ii < tb.Rows.Count; ii++)
                {
                    DataRow row = tb.Rows[ii];
                    res.Add(ResourceHandle.GetResourceHandle(( string )row[0]));
                }
                return res;
            },
                                              principalId,
                                              operationId));
        }
Example #2
0
        public IList <ResourceAccessPredicate> GetAuthorizationDigest(string principalId)
        {
            if (string.IsNullOrEmpty(principalId))
            {
                throw new ArgumentNullException("principalId");
            }

            return
                ((IList <ResourceAccessPredicate>)
                 ExecuteMethodWithCacheLookUp("GetAuthorizationDigest",
                                              delegate(string[] parameters) {
                DataSet ds = DBHelper.ExecuteDataSet("GetAuthorizationDigest", parameters);
                if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    return new ResourceAccessPredicate[0];
                }
                DataTable tb = ds.Tables[0];
                List <ResourceAccessPredicate> res =
                    new List <ResourceAccessPredicate>(tb.Rows.Count);
                for (int ii = 0; ii < tb.Rows.Count; ii++)
                {
                    DataRow row = tb.Rows[ii];
                    res.Add(new ResourceAccessPredicate(parameters[0],
                                                        ( string )row[0],
                                                        ResourceHandle.GetResourceHandle(
                                                            ( string )row[1]),
                                                        ( ResourceAccessPredicateType )
                                                        (( int )row[2])));
                }
                return res;
            },
                                              principalId));
        }