Пример #1
0
        // gives this identity a trust chain to use
        public void AddTrustChain(byte[] trustChain)
        {
            TrustChainNode[] nodes        = TrustChainUtil.SegmentChain(trustChain);
            bool             isValid      = TrustChainUtil.ValidateTrustChain(nodes);
            bool             endsWithThis = nodes[nodes.Length - 1].ThisId.SequenceEqual(PublicIdentity);

            if (isValid && endsWithThis)
            {
                TrustChain           = nodes;
                PermissionsHeld      = nodes[nodes.Length - 1].HeldPermissions;
                PermissionsGrantable = nodes[nodes.Length - 1].GrantablePermissions;

                identityManager.AddIdentities(nodes);
            }
            else
            {
                throw new BadTrustChainException("Could not validate trust chain ending with this");
            }
        }
Пример #2
0
        public bool ValidateAndAdd(TrustChainNode[] trustChainNodes)
        {
            bool validChain = TrustChainUtil.ValidateTrustChain(trustChainNodes);

            if (!validChain)
            {
                return(false);
            }

            bool sameRoot = TrustChain[0].ParentId.SequenceEqual(trustChainNodes[0].ParentId);

            if (!sameRoot)
            {
                return(false);
            }

            for (int i = 0; i < trustChainNodes.Length; i++)
            {
                identityManager.AddIdentity(trustChainNodes[i], Name);
            }

            return(true);
        }