예제 #1
0
        public static PrincipalHandle TransferPrincipal(PrincipalHandle oldH,
                                                        int processId,
                                                        ref DelegationState delegationState)
        {
            Process p = Process.GetProcessByID(processId);

            if (p == null)
            {
                throw new ApplicationException("Delegate endpoint process is null");
            }

            DelegationState newstate;
            Principal       pr;

            switch (delegationState)
            {
            case DelegationState.ByMediation:
                pr = PrincipalImpl.NewDelegation(
                    PrincipalImpl.MakePrincipal(oldH.val), p.Principal);
                newstate = DelegationState.Mediated;
                break;

            case DelegationState.ByCapability:
                pr = PrincipalImpl.NewDelegation(
                    PrincipalImpl.MakePrincipal(oldH.val), p.Principal);
                newstate = DelegationState.None;
                break;

            case DelegationState.Mediated:
                pr       = p.Principal;
                newstate = DelegationState.None;
                break;

            case DelegationState.None:
            default:
                pr       = p.Principal;
                newstate = DelegationState.None;
                break;
            }

            delegationState = newstate;
            return(new PrincipalHandle(pr.Val));
        }
예제 #2
0
        ////////////////////////////////////////////////////////////////////
        // Class Methods
        //

        internal DeliveryImpl(Allocation * /*EndpointCore* opt(ExHeap)!*/ ep)
        {
            this.endpointAlloc = ep;
            this.endpoint      = ((EndpointCore *)Allocation.GetData(ep));

            // set default values (shadow cached values in EndpointCore if necessary)
            setMessageEvent(new AutoResetEventHandle(
                                Process.kernelProcess.AllocateHandle(new AutoResetEvent(false))));
            endpoint->CollectionEvent = new AutoResetEventHandle();

            endpoint->SetCachedPeer(null);    // set as null by default

            ProcessId = Thread.CurrentProcess.ProcessId;
            ChannelId = 0;                    // zero initially, corrected in connect
            Marshall  = false;                // false by default
            Closed    = true;                 // opened in connect

            principalHandle = new PrincipalHandle(Thread.CurrentProcess.Principal.Val);
            delegationState = DelegationState.None;
            receiveCount    = 0;
        }