Brunet.Security.PeerSec.Symphony.SymphonySecurityOverlord.CreateSecurityAssociation C# (CSharp) Метод

CreateSecurityAssociation() защищенный Метод

protected CreateSecurityAssociation ( ISender sender, int spi, bool start ) : PeerSecAssociation
sender ISender
spi int
start bool
Результат PeerSecAssociation
    override protected PeerSecAssociation CreateSecurityAssociation(ISender sender, int spi, bool start)
    {
      PeerSecAssociation sa = null;
      lock(_sync) {
        sa = base.CreateSecurityAssociation(sender, spi, start);
        AHSender ahsender = sender as AHSender;
        if(ahsender != null) {
          Address target = ahsender.Destination;
          if(_address_to_sa.ContainsKey(target)) {
            sa = _address_to_sa[target] as PeerSecAssociation;
          } else {
            sa = base.CreateSecurityAssociation(sender, spi, start);
            _address_to_sa[target] = sa;
            _sa_to_address[sa] = target;
          }
        }
      }
      return sa;
    }

Usage Example

Пример #1
0
        protected bool GetSecureSender(Connection con, out SecurityAssociation sa)
        {
            sa = _so.CreateSecurityAssociation(con.State.Edge);
            bool ready = false;

            lock (_address_to_sender) {
                if (!_registered.ContainsKey(sa))
                {
                    _registered[sa]      = true;
                    sa.StateChangeEvent += SAStateChange;
                }

                if (sa.State == SecurityAssociation.States.Active ||
                    sa.State == SecurityAssociation.States.Updating)
                {
                    Address addr = con.Address;
                    if (_address_to_sender.ContainsKey(addr))
                    {
                        SecurityAssociation to_fixup = _address_to_sender[addr] as SecurityAssociation;
                        if (to_fixup != null && to_fixup != sa)
                        {
                            to_fixup.StateChangeEvent -= SAStateChange;
                            _registered.Remove(to_fixup);
                        }
                    }
                    AddConnection(con.Address, sa);
                    ready = true;
                }
            }
            return(ready);
        }