Provides a Security Wrapper for generic Edges. Basically binds a SecurityAssociation to an Edge, so that all traffic must traverse the SecurityAssociation. This clsas is thread-safe.
Inheritance: WrapperEdge, IDataHandler
コード例 #1
0
        ///<summary>When a SecurityAssociation changes amongst inactive, active,
        ///or closed this gets notified.</summary>
        protected void AnnounceSA(SecurityAssociation sa,
                                  SecurityAssociation.States state)
        {
            Edge e = sa.Sender as Edge;

            // if e is an edge, let's see if he's creating a SE
            // or maybe it isn't our edge!
            if (e == null)
            {
                return;
            }
            else if (e.TAType != this.TAType)
            {
                return;
            }

            if (state == SecurityAssociation.States.Active)
            {
                SecurityAssociation stored_sa = null;
                if (!RemoveFromDictionary(e, out stored_sa))
                {
                    // May have already been here
                    return;
                }
                else if (stored_sa != null && stored_sa != sa)
                {
                    throw new Exception("Cannot have the same edge used in multiple SAs");
                }

                SecureEdge se = new SecureEdge(e, sa);
                sa.Subscribe(se, null);
                try {
                    Finalize(se);
                } catch {
                    se.Close();
                }
            }
            else if (state == SecurityAssociation.States.Closed)
            {
                e.Close();
            }
        }
コード例 #2
0
ファイル: SecureEdgeListener.cs プロジェクト: pcbing/brunet
        ///<summary>When a SecurityAssociation changes amongst inactive, active,
        ///or closed this gets notified.</summary>
        protected void AnnounceSA(object o, EventArgs ea)
        {
            SecurityAssociation sa = o as SecurityAssociation;

            if (sa == null)
            {
                throw new Exception("Needs to be a SecurityAssociation");
            }

            Edge e = sa.Sender as Edge;

            // if e is an edge, let's see if he's creating a SE
            // or maybe it isn't our edge!
            if (e == null)
            {
                return;
            }
            else if (e.TAType != this.TAType)
            {
                return;
            }

            if (sa.Active)
            {
                SecureEdge se = new SecureEdge(e, sa);
                sa.Subscribe(se, null);
                try {
                    Finalize(se);
                } catch {
                    se.Close();
                }
            }
            else
            {
                e.Close();
            }
        }