Пример #1
0
        /// <summary>
        /// Saml2 serialization
        /// </summary>
        public virtual string Serialize(
            ISerializableMessage entity,
            MessageSerializationParameters parameters)
        {
            byte[] serializedBytes;

            // serialize to byte[]
            using (var writer = new StringWriter())
            {
                var xmlWriterSettings = new XmlWriterSettings();
                xmlWriterSettings.Encoding           = this.Encoding;
                xmlWriterSettings.OmitXmlDeclaration = true;

                using (var xmlWriter = XmlWriter.Create(writer, xmlWriterSettings))
                {
                    var xmlSerializer = new XmlSerializer(entity.GetType());
                    xmlSerializer.Serialize(xmlWriter, entity, Namespaces.SerializerNamespaces);
                }

                var rawEntity = writer.ToString();

                // log
                new LoggerFactory().For(this).Debug(Event.RawAuthnRequest, rawEntity);

                serializedBytes = this.Encoding.GetBytes(rawEntity);
            }

            // convert the byte[] according to parameters
            if (parameters.ShouldDeflate)
            {
                serializedBytes = this.Deflate(serializedBytes);
            }
            if (parameters.ShouldBase64Encode)
            {
                serializedBytes = this.Encoding.GetBytes(Convert.ToBase64String(serializedBytes));
            }

            return(this.Encoding.GetString(serializedBytes));
        }
Пример #2
0
 private void _typedConnection_NewMessage(ITypedConnection <ISerializableMessage> arg1, ISerializableMessage arg2, ushort sequenceId)
 {
     if (arg2 is TestControl)
     {
         _trace.Info("Got Stop signal");
         RemoteServer.StopEvent.Set();
     }
     RemoteServer.TestOutputFile.WriteLine(_connectionId + ":" + arg2.ToString());
 }