コード例 #1
0
 internal KiiACLEntry(KiiACL <T, U> parent, KiiSubject subject)
 {
     if (parent == null)
     {
         throw new ArgumentException("parent is null");
     }
     if (subject == null)
     {
         throw new ArgumentException("subject can not be null");
     }
     mParent  = parent;
     mSubject = subject;
 }
コード例 #2
0
        private IList <KiiACLEntry <T, U> > ParseListResponse(JsonObject json)
        {
            List <KiiACLEntry <T, U> > entries = new List <KiiACLEntry <T, U> >();

            string[] actionNames = ActionNames;
            foreach (string name in actionNames)
            {
                JsonArray whiteList = json.OptJsonArray(name);
                if (whiteList == null)
                {
                    continue;
                }
                for (int i = 0; i < whiteList.Length(); ++i)
                {
                    U action;
                    try
                    {
                        action = ToAction(name);
                    }
                    catch (Exception)
                    {
                        // Just ignore and continue if failed to parse action.
                        // Could be the action newly introduced.
                        continue;
                    }

                    KiiACL <T, U> acl = CreateFromAction(mParent, action);

                    JsonObject         entry = whiteList.GetJsonObject(i);
                    KiiACLEntry <T, U> kae   = null;
                    if (entry.Has("groupID"))
                    {
                        string gid = entry.GetString("groupID");
                        kae = acl.Subject(KiiGroup.GroupWithID(gid));
                        entries.Add(kae);
                    }
                    else if (entry.Has("userID"))
                    {
                        string     uid = entry.GetString("userID");
                        KiiSubject sbj = GetSubjetFromUserID(uid);
                        kae = acl.Subject(sbj);
                        entries.Add(kae);
                    }
                }
            }
            return(entries);
        }
コード例 #3
0
 private string ToSubjectString(KiiSubject subject)
 {
     if (subject is KiiGroup)
     {
         return("GROUP:" + ((KiiGroup)subject).ID);
     }
     else if (subject is KiiUser)
     {
         return("USER:"******"ANONYMOUS_USER");
     }
     else if (subject is KiiAnyAuthenticatedUser)
     {
         return("ANY_AUTHENTICATED_USER");
     }
     else
     {
         throw new SystemException("Unexpected error." + subject.GetType().ToString());
     }
 }
コード例 #4
0
 /// <summary>
 /// Create a new Entry with specified subject
 /// </summary>
 /// <remarks>
 /// To add an ACL entry to KiiCloud, please call entry.Save(ACLOperation) API.
 /// </remarks>
 /// <returns>
 /// KiiACLEntry instance.
 /// </returns>
 /// <param name='subject'>
 /// Subject.
 /// </param>
 /// <exception cref="ArgumentException">
 /// Is thrown when subject is null.
 /// </exception>
 public KiiACLEntry <T, U> Subject(KiiSubject subject)
 {
     return(new KiiACLEntry <T, U>(this, subject));
 }