Exemple #1
0
        public void OnNeighborOpened(object sender, EventArgs args)
        {
            IPeerNeighbor neighbor = sender as IPeerNeighbor;
            EventHandler  handler  = this.OnNeighborAuthenticated;

            if (handler == null)
            {
                neighbor.Abort(PeerCloseReason.LeavingMesh, PeerCloseInitiator.LocalNode);
                return;
            }
            if (this.authenticationMode == PeerAuthenticationMode.Password)
            {
                if (!(neighbor.Extensions.Find <PeerChannelAuthenticatorExtension>() == null))
                {
                    throw Fx.AssertAndThrow("extension already exists!");
                }
                PeerChannelAuthenticatorExtension extension = new PeerChannelAuthenticatorExtension(this, handler, args, this.MeshId);
                neighbor.Extensions.Add(extension);
                if (neighbor.IsInitiator)
                {
                    extension.InitiateHandShake();
                }
            }
            else
            {
                neighbor.TrySetState(PeerNeighborState.Authenticated);
                handler(sender, args);
            }
        }
Exemple #2
0
        public static void OnNeighborClosed(IPeerNeighbor neighbor)
        {
            PeerChannelAuthenticatorExtension item = neighbor.Extensions.Find <PeerChannelAuthenticatorExtension>();

            if (item != null)
            {
                neighbor.Extensions.Remove(item);
            }
        }
        static public void OnNeighborClosed(IPeerNeighbor neighbor)
        {
            Fx.Assert(neighbor != null, "Neighbor must have a value");
            PeerChannelAuthenticatorExtension ext = neighbor.Extensions.Find <PeerChannelAuthenticatorExtension>();

            if (ext != null)
            {
                neighbor.Extensions.Remove(ext);
            }
        }
Exemple #4
0
        public Message ProcessRequest(IPeerNeighbor neighbor, Message request)
        {
            if (this.authenticationMode != PeerAuthenticationMode.Password || request == null)
            {
                Abort(neighbor);
                return(null);
            }
            PeerChannelAuthenticatorExtension extension = neighbor.Extensions.Find <PeerChannelAuthenticatorExtension>();
            Claim claim = FindClaim(ServiceSecurityContext.Current);

            if (!(extension != null && claim != null))
            {
                throw Fx.AssertAndThrow("No suitable claim found in the context to do security negotiation!");
            }
            return(extension.ProcessRst(request, claim));
        }