示例#1
0
        /// <summary>This is SecureData that needs to get to an SA.</summary>
        protected void HandleData(MemBlock b, ISender return_path)
        {
            SecurityDataMessage sdm = new SecurityDataMessage(b);
            Dictionary <ISender, PeerSecAssociation> sender_to_sa = null;
            PeerSecAssociation sa = null;

            try {
                sender_to_sa = _spi[sdm.SPI];
                sa           = sender_to_sa[return_path];
                sa.HandleData(b, return_path, null);
            } catch {
                if (sender_to_sa == null && !SecurityPolicy.Supports(sdm.SPI))
                {
                    throw new Exception("Invalid SPI: " + sdm.SPI);
                }
                else if (sa == null)
                {
                    NoSuchSA(sdm.SPI, return_path);
                    throw new Exception("No SA for: " + return_path);
                }
                else if (sa.Closed)
                {
                    throw new Exception("SA has been closed.");
                }
                else
                {
                    throw;
                }
            }
        }
示例#2
0
        /// <summary>This is SecureData that needs to get to an SA.</summary>
        protected void HandleData(MemBlock b, ISender return_path)
        {
            SecurityDataMessage sdm = new SecurityDataMessage(b);
            Dictionary <ISender, PeerSecAssociation> sender_to_sa = null;
            PeerSecAssociation sa = null;

            try {
                sender_to_sa = _spi[sdm.SPI];
                sa           = sender_to_sa[return_path];
                sa.HandleData(b, return_path, null);
            } catch (Exception e) {
                if (sender_to_sa == null && !SecurityPolicy.Supports(sdm.SPI))
                {
                    ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, String.Format(
                                            "Unsupported SPI, from {0}, message: {1}", return_path, sdm));
                }
                else
                {
                    if (sa == null)
                    {
                        ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, String.Format(
                                                "No SA, from {0}, message: {1}", return_path, sdm));
                    }
                    else if (sa.Closed)
                    {
                        ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, String.Format(
                                                "SA, {0}, has been closed, from {1}, message: {2}.", sa,
                                                return_path, sdm));
                    }
                    else
                    {
                        ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, String.Format(
                                                "SA, {0}, from {1}, message: {2}, causes unhandled exception : {3}",
                                                sa, return_path, sdm, e));
                    }
                    NoSuchSA(sdm.SPI, return_path);
                }
            }
        }