static XmlDictionaryReaderQuotas ()
		{
			max = new XmlDictionaryReaderQuotas (true);
		}
 public TextMessageEncoderFactory(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
 {
     messageEncoder = new TextMessageEncoder(version, writeEncoding, maxReadPoolSize, maxWritePoolSize, quotas);
 }
Exemple #3
0
 public static XmlDictionaryReader CreateJsonReader(Stream stream, XmlDictionaryReaderQuotas quotas)
 {
     return(JsonReaderWriterFactory.CreateJsonReader(stream, (Encoding)null, quotas, (OnXmlDictionaryReaderClose)null));
 }
 public static XmlDictionaryReader CreateJsonReader(byte [] source, int offset, int length, XmlDictionaryReaderQuotas quotas)
 {
     return(CreateJsonReader(source, offset, length, null, quotas, null));
 }
 public static XmlDictionaryReader CreateJsonReader(Stream source, XmlDictionaryReaderQuotas quotas)
 {
     return(CreateJsonReader(source, null, quotas, null));
 }
 public static XmlDictionaryReader CreateTextReader(byte[] buffer, XmlDictionaryReaderQuotas quotas);
 public static XmlDictionaryReader CreateJsonReader(byte[] buffer, int offset, int count, XmlDictionaryReaderQuotas quotas)
 {
     return(CreateJsonReader(buffer, offset, count, null, quotas, null));
 }
Exemple #8
0
 public CustomTextMessageBindingElement(DifiGatewaySettings difiGatewaySettings)
 {
     DifiGatewaySettings = difiGatewaySettings;
     _readerQuotas       = new XmlDictionaryReaderQuotas();
 }
Exemple #9
0
        public static PeerSecurityManager Create(PeerSecuritySettings security, BindingContext context, XmlDictionaryReaderQuotas readerQuotas)
        {
            PeerAuthenticationMode none = PeerAuthenticationMode.None;
            bool signing = false;

            Convert(security, out none, out signing);
            return(Create(none, signing, context, readerQuotas));
        }
Exemple #10
0
        override public void download()
        {
            string[] URLs;
            string[] thumbs;
            string   strThumbs = "";
            string   website   = "";
            string   str;

            if (General.loadHTML)                                                       // if HTML download activated get HTML, thumbnails, do some magic
            {
                try {
                    website = new WebClient().DownloadString(this.getURL());

                    string JURL = this.getURL().Replace(".html", ".json");

                    string Content = new WebClient().DownloadString(JURL);

                    byte[] bytes = Encoding.ASCII.GetBytes(Content);
                    using (var stream = new MemoryStream(bytes)) {
                        var quotas     = new XmlDictionaryReaderQuotas();
                        var jsonReader = JsonReaderWriterFactory.CreateJsonReader(stream, quotas);
                        var xml        = XDocument.Load(jsonReader);
                        str = xml.ToString();
                    }

                    // get single images
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(str);
                    XmlNodeList xmlTim = doc.DocumentElement.SelectNodes("/root/posts/item/tim");
                    XmlNodeList xmlExt = doc.DocumentElement.SelectNodes("/root/posts/item/ext");
                    for (int i = 0; i < xmlExt.Count; i++)
                    {
                        string ext = xmlExt[i].InnerText;
//                        if(ext == ".webm")
//                            ext = ".jpg";
                        strThumbs = strThumbs + "https://8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext + "\n";

                        website = website.Replace("https://8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("=\"/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "=\"thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("=\"/" + getURL().Split('/')[3] + "/src/" + xmlTim[i].InnerText + ext, "=\"" + xmlTim[i].InnerText + ext);
                        website = website.Replace("https://8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("https://media.8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("https://media.8ch.net/" + getURL().Split('/')[3] + "/src/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                        website = website.Replace("https://8ch.net/" + getURL().Split('/')[3] + "/src/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                    }

                    // get images of posts with multiple images
                    xmlTim = doc.DocumentElement.SelectNodes("/root/posts/item/extra_files/item/tim");
                    xmlExt = doc.DocumentElement.SelectNodes("/root/posts/item/extra_files/item/ext");
                    for (int i = 0; i < xmlExt.Count; i++)
                    {
                        string ext = xmlExt[i].InnerText;
//                        if(ext == ".webm")
//                            ext = ".jpg";
                        strThumbs = strThumbs + "https://8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext + "\n";

                        website = website.Replace("https://8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("=\"/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "=\"thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("=\"/" + getURL().Split('/')[3] + "/src/" + xmlTim[i].InnerText + ext, "=\"" + xmlTim[i].InnerText + ext);

                        website = website.Replace("https://8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("https://media.8ch.net/" + getURL().Split('/')[3] + "/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                        website = website.Replace("https://media.8ch.net/" + getURL().Split('/')[3] + "/src/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                        website = website.Replace("https://8ch.net/" + getURL().Split('/')[3] + "/src/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                    }

                    website = website.Replace("=\"/", "=\"https://8ch.net/");


                    if (!Directory.Exists(this.SaveTo))
                    {
                        Directory.CreateDirectory(this.SaveTo);
                    }

                    thumbs = strThumbs.Split('\n');

                    for (int i = 0; i < thumbs.Length - 1; i++)
                    {
                        General.dlTo(thumbs[i], this.SaveTo + "\\thumb");
                    }
                } catch (WebException webEx) {
                    // I think I should handle this
                }
                if (website != "")
                {
                    if (!Directory.Exists(this.SaveTo))
                    {
                        Directory.CreateDirectory(this.SaveTo);
                    }
                    File.WriteAllText(this.SaveTo + "\\Thread.html", website); // save thread
                }
            }

            try {
                URLs = Regex.Split(getLinks(), "\n");
            } catch (WebException webEx) {
                if (((int)webEx.Status) == 7)
                {
                    this.Gone = true;
                }
                return;
            }

            for (int y = 0; y < URLs.Length - 1; y++)
            {
                General.dlTo(URLs[y], this.SaveTo);                         // download images
            }
        }
Exemple #11
0
        private void downloadHTMLPage()
        {
            List <string> thumbs   = new List <string>();
            string        htmlPage = "";
            string        str;

            try
            {
                htmlPage = new WebClient().DownloadString(this.getURL());

                string JURL = this.getURL().Replace(".html", ".json");

                string Content = new WebClient().DownloadString(JURL);

                byte[] bytes = Encoding.ASCII.GetBytes(Content);
                using (var stream = new MemoryStream(bytes))
                {
                    var quotas     = new XmlDictionaryReaderQuotas();
                    var jsonReader = JsonReaderWriterFactory.CreateJsonReader(stream, quotas);
                    var xml        = XDocument.Load(jsonReader);
                    str = xml.ToString();
                }

                // get single images
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(str);
                XmlNodeList xmlTim = doc.DocumentElement.SelectNodes("/root/posts/item/tim");
                XmlNodeList xmlExt = doc.DocumentElement.SelectNodes("/root/posts/item/ext");
                for (int i = 0; i < xmlExt.Count; i++)
                {
                    string ext = xmlExt[i].InnerText;
                    //                        if(ext == ".webm")
                    //                            ext = ".jpg";
                    thumbs.Add("https://8ch.net/file_store/thumb/" + xmlTim[i].InnerText + ext);

                    htmlPage = htmlPage.Replace("https://8ch.net/file_store/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("=\"/file_store/thumb/" + xmlTim[i].InnerText + ext, "=\"thumb/" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("=\"/file_store/" + xmlTim[i].InnerText + ext, "=\"" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("https://media.8ch.net/file_store/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("https://media.8ch.net/file_store/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("https://8ch.net/file_store/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                }

                // get images of posts with multiple images
                xmlTim = doc.DocumentElement.SelectNodes("/root/posts/item/extra_files/item/tim");
                xmlExt = doc.DocumentElement.SelectNodes("/root/posts/item/extra_files/item/ext");
                for (int i = 0; i < xmlExt.Count; i++)
                {
                    string ext = xmlExt[i].InnerText;
                    //                        if(ext == ".webm")
                    //                            ext = ".jpg";
                    thumbs.Add("https://8ch.net/file_store/thumb/" + xmlTim[i].InnerText + ext);

                    htmlPage = htmlPage.Replace("https://8ch.net/file_store/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("=\"/file_store/thumb/" + xmlTim[i].InnerText + ext, "=\"thumb/" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("=\"/file_store/" + xmlTim[i].InnerText + ext, "=\"" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("https://media.8ch.net/file_store/thumb/" + xmlTim[i].InnerText + ext, "thumb/" + xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("https://media.8ch.net/file_store/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                    htmlPage = htmlPage.Replace("https://8ch.net/file_store/" + xmlTim[i].InnerText + ext, xmlTim[i].InnerText + ext);
                }

                htmlPage = htmlPage.Replace("=\"/", "=\"https://8ch.net/");

                for (int i = 0; i < thumbs.Count; i++)
                {
                    General.DownloadToDir(new FileInformation(thumbs[i]), this.SaveTo + "\\thumb");
                }

                if (!String.IsNullOrWhiteSpace(htmlPage))
                {
                    File.WriteAllText(this.SaveTo + "\\Thread.html", htmlPage); // save thread
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #12
0
 public MtomMessageEncoder(MtomMessageEncoderFactory owner)
 {
     version  = owner.MessageVersion;
     encoding = owner.Owner.WriteEncoding;
     quotas   = owner.Owner.ReaderQuotas;
 }
Exemple #13
0
 public XmlSerializer(XmlDictionaryReaderQuotas quotas)
 {
     this.quotas = quotas;
 }
        public static XmlDictionaryReader CreateJsonReader(byte[] buffer, int offset, int count, Encoding?encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose?onClose)
        {
            XmlJsonReader reader = new XmlJsonReader();

            reader.SetInput(buffer, offset, count, encoding, quotas, onClose);
            return(reader);
        }
 public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session);
Exemple #16
0
        public static PeerSecurityManager Create(PeerAuthenticationMode authenticationMode, bool signMessages, BindingContext context, XmlDictionaryReaderQuotas readerQuotas)
        {
            if ((authenticationMode == PeerAuthenticationMode.None) && !signMessages)
            {
                return(CreateDummy());
            }
            if (authenticationMode == PeerAuthenticationMode.Password)
            {
                try
                {
                    using (new HMACSHA256())
                    {
                        using (new SHA256Managed())
                        {
                        }
                    }
                }
                catch (InvalidOperationException exception)
                {
                    DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
                    PeerExceptionHelper.ThrowInvalidOperation_InsufficientCryptoSupport(exception);
                }
            }
            ChannelProtectionRequirements  reqs    = context.BindingParameters.Find <ChannelProtectionRequirements>();
            PeerSecurityCredentialsManager credman = GetCredentialsManager(authenticationMode, signMessages, context);

            if (credman.Credential != null)
            {
                ValidateCredentialSettings(authenticationMode, signMessages, credman.Credential);
            }
            PeerSecurityManager manager2 = Create(authenticationMode, signMessages, credman, reqs, readerQuotas);

            credman.Parent = manager2;
            manager2.ApplyAuditBehaviorSettings(context);
            return(manager2);
        }
 public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session);
Exemple #18
0
        public static PeerSecurityManager Create(PeerAuthenticationMode authenticationMode, bool messageAuthentication, PeerSecurityCredentialsManager credman, ChannelProtectionRequirements reqs, XmlDictionaryReaderQuotas readerQuotas)
        {
            PeerSecurityManager      manager    = null;
            X509CertificateValidator none       = null;
            X509CertificateValidator validator2 = null;
            PeerCredential           credential = credman.Credential;

            if ((credential == null) && (credman == null))
            {
                if ((authenticationMode != PeerAuthenticationMode.None) || messageAuthentication)
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Credentials);
                }
                return(CreateDummy());
            }
            manager = new PeerSecurityManager(authenticationMode, messageAuthentication)
            {
                credManager  = credman,
                password     = credman.Password,
                readerQuotas = readerQuotas
            };
            if (reqs != null)
            {
                manager.protection = new ChannelProtectionRequirements(reqs);
            }
            manager.tokenManager = credman.CreateSecurityTokenManager();
            if (credential != null)
            {
                switch (authenticationMode)
                {
                case PeerAuthenticationMode.Password:
                    manager.password = credential.MeshPassword;
                    if (string.IsNullOrEmpty(manager.credManager.Password))
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Password);
                    }
                    none = X509CertificateValidator.None;
                    break;

                case PeerAuthenticationMode.MutualCertificate:
                    if (manager.credManager.Certificate == null)
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Certificate);
                    }
                    if (!credential.PeerAuthentication.TryGetCertificateValidator(out none))
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.PeerAuthentication);
                    }
                    break;
                }
                if (messageAuthentication)
                {
                    if (credential.MessageSenderAuthentication != null)
                    {
                        if (!credential.MessageSenderAuthentication.TryGetCertificateValidator(out validator2))
                        {
                            PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                        }
                        return(manager);
                    }
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                }
            }
            return(manager);
        }
 public static XmlDictionaryReader CreateTextReader(Stream stream, XmlDictionaryReaderQuotas quotas);
Exemple #20
0
 public RawMessageEncoderFactory(XmlDictionaryReaderQuotas quotas)
 {
     this.encoder = new RawMessageEncoder(quotas);
 }
 public DataContractDeserializer(XmlDictionaryReaderQuotas quotas = null)
 {
     this.quotas = quotas;
 }
Exemple #22
0
        public SecurityContextSecurityToken CreateSecurityContextFromCookie(byte[] encodedCookie, UniqueId contextId, UniqueId generation, string id, XmlDictionaryReaderQuotas quotas)
        {
            byte[] cookie = null;

            try
            {
                cookie = _securityStateEncoder.DecodeSecurityState(encodedCookie);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                OnInvalidCookieFailure(SR.Format(SR.SctCookieBlobDecodeFailure), e);
            }
            SecurityContextSecurityToken sct = DeserializeContext(cookie, encodedCookie, id, quotas);

            if (sct.ContextId != contextId)
            {
                OnInvalidCookieFailure(SR.Format(SR.SctCookieValueMissingOrIncorrect, nameof(contextId)));
            }
            if (sct.KeyGeneration != generation)
            {
                OnInvalidCookieFailure(SR.Format(SR.SctCookieValueMissingOrIncorrect, nameof(sct.KeyGeneration)));
            }

            return(sct);
        }
 public static XmlDictionaryReader CreateJsonReader(byte [] source, int offset, int length, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose readerClose)
 {
     return(new JsonReader(source, offset, length, encoding, quotas, readerClose));
 }
Exemple #24
0
        private SecurityContextSecurityToken DeserializeContext(byte[] serializedContext, byte[] cookieBlob, string id, XmlDictionaryReaderQuotas quotas)
        {
            SctClaimDictionary  dictionary = SctClaimDictionary.Instance;
            XmlDictionaryReader reader     = XmlDictionaryReader.CreateBinaryReader(serializedContext, 0, serializedContext.Length, dictionary, quotas, null, null);
            int      cookieVersion         = -1;
            UniqueId cookieContextId       = null;
            DateTime effectiveTime         = SecurityUtils.MinUtcDateTime;
            DateTime expiryTime            = SecurityUtils.MaxUtcDateTime;

            byte[]            key               = null;
            string            localId           = null;
            UniqueId          keyGeneration     = null;
            DateTime          keyEffectiveTime  = SecurityUtils.MinUtcDateTime;
            DateTime          keyExpirationTime = SecurityUtils.MaxUtcDateTime;
            List <ClaimSet>   claimSets         = null;
            IList <IIdentity> identities        = null;
            bool isCookie = true;

            reader.ReadFullStartElement(dictionary.SecurityContextSecurityToken, dictionary.EmptyString);

            while (reader.IsStartElement())
            {
                if (reader.IsStartElement(dictionary.Version, dictionary.EmptyString))
                {
                    cookieVersion = reader.ReadElementContentAsInt();
                }
                else if (reader.IsStartElement(dictionary.ContextId, dictionary.EmptyString))
                {
                    cookieContextId = reader.ReadElementContentAsUniqueId();
                }
                else if (reader.IsStartElement(dictionary.Id, dictionary.EmptyString))
                {
                    localId = reader.ReadElementContentAsString();
                }
                else if (reader.IsStartElement(dictionary.EffectiveTime, dictionary.EmptyString))
                {
                    effectiveTime = new DateTime(XmlHelper.ReadElementContentAsInt64(reader), DateTimeKind.Utc);
                }
                else if (reader.IsStartElement(dictionary.ExpiryTime, dictionary.EmptyString))
                {
                    expiryTime = new DateTime(XmlHelper.ReadElementContentAsInt64(reader), DateTimeKind.Utc);
                }
                else if (reader.IsStartElement(dictionary.Key, dictionary.EmptyString))
                {
                    key = reader.ReadElementContentAsBase64();
                }
                else if (reader.IsStartElement(dictionary.KeyGeneration, dictionary.EmptyString))
                {
                    keyGeneration = reader.ReadElementContentAsUniqueId();
                }
                else if (reader.IsStartElement(dictionary.KeyEffectiveTime, dictionary.EmptyString))
                {
                    keyEffectiveTime = new DateTime(XmlHelper.ReadElementContentAsInt64(reader), DateTimeKind.Utc);
                }
                else if (reader.IsStartElement(dictionary.KeyExpiryTime, dictionary.EmptyString))
                {
                    keyExpirationTime = new DateTime(XmlHelper.ReadElementContentAsInt64(reader), DateTimeKind.Utc);
                }
                else if (reader.IsStartElement(dictionary.Identities, dictionary.EmptyString))
                {
                    identities = SctClaimSerializer.DeserializeIdentities(reader, dictionary, DataContractSerializerDefaults.CreateSerializer(typeof(IIdentity), _knownTypes, int.MaxValue));
                }
                else if (reader.IsStartElement(dictionary.ClaimSets, dictionary.EmptyString))
                {
                    reader.ReadStartElement();

                    DataContractSerializer claimSetSerializer = DataContractSerializerDefaults.CreateSerializer(typeof(ClaimSet), _knownTypes, int.MaxValue);
                    DataContractSerializer claimSerializer    = DataContractSerializerDefaults.CreateSerializer(typeof(Claim), _knownTypes, int.MaxValue);
                    claimSets = new List <ClaimSet>(1);
                    while (reader.IsStartElement())
                    {
                        claimSets.Add(SctClaimSerializer.DeserializeClaimSet(reader, dictionary, claimSetSerializer, claimSerializer));
                    }

                    reader.ReadEndElement();
                }
                else if (reader.IsStartElement(dictionary.IsCookieMode, dictionary.EmptyString))
                {
                    isCookie = reader.ReadElementString() == "1" ? true : false;
                }
                else
                {
                    OnInvalidCookieFailure(SR.Format(SR.SctCookieXmlParseError));
                }
            }
            reader.ReadEndElement();
            if (cookieVersion != SupportedPersistanceVersion)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SerializedTokenVersionUnsupported, cookieVersion)));
            }
            if (cookieContextId == null)
            {
                OnInvalidCookieFailure(SR.Format(SR.SctCookieValueMissingOrIncorrect, nameof(cookieContextId)));
            }
            if (key == null || key.Length == 0)
            {
                OnInvalidCookieFailure(SR.Format(SR.SctCookieValueMissingOrIncorrect, nameof(key)));
            }
            if (localId != id)
            {
                OnInvalidCookieFailure(SR.Format(SR.SctCookieValueMissingOrIncorrect, nameof(id)));
            }
            List <IAuthorizationPolicy> authorizationPolicies;

            if (claimSets != null)
            {
                authorizationPolicies = new List <IAuthorizationPolicy>(1)
                {
                    new SctUnconditionalPolicy(identities, claimSets, expiryTime)
                };
            }
            else
            {
                authorizationPolicies = null;
            }
            return(new SecurityContextSecurityToken(cookieContextId, localId, key, effectiveTime, expiryTime,
                                                    authorizationPolicies?.AsReadOnly(), isCookie, cookieBlob, keyGeneration, keyEffectiveTime, keyExpirationTime));
        }
 public static XmlDictionaryReader CreateJsonReader(Stream source, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose readerClose)
 {
     return(new JsonReader(source, encoding, quotas, readerClose));
 }
 public XmlSerializer(XmlDictionaryReaderQuotas quotas = null, bool omitXmlDeclaration = false)
 {
     this.quotas                  = quotas;
     XSettings.Encoding           = new UTF8Encoding(false);
     XSettings.OmitXmlDeclaration = omitXmlDeclaration;
 }
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (version == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
                }
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                this.writeEncoding   = writeEncoding;
                optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                thisLock = new object();

                this.version          = version;
                this.maxReadPoolSize  = maxReadPoolSize;
                this.maxWritePoolSize = maxWritePoolSize;

                this.readerQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(this.readerQuotas);

                this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas);

                this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);

                this.mediaType   = TextMessageEncoderFactory.GetMediaType(version);
                this.contentType = TextMessageEncoderFactory.GetContentType(mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    contentEncodingMap = TextMessageEncoderFactory.SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.GetString(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }
Exemple #28
0
 internal virtual void SetReaderQuotas(XmlDictionaryReaderQuotas readerQuotas)
 {
 }
Exemple #29
0
        public static XmlDictionaryReader CreateJsonReader(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
        {
            XmlJsonReader xmlJsonReader = new XmlJsonReader();

            xmlJsonReader.SetInput(stream, encoding, quotas, onClose);
            return((XmlDictionaryReader)xmlJsonReader);
        }
 static XmlDictionaryReaderQuotas()
 {
     max = new XmlDictionaryReaderQuotas(true);
 }
		public void CopyTo (XmlDictionaryReaderQuotas quota)
		{
			quota.array_len = array_len;
			quota.bytes = bytes;
			quota.depth = depth;
			quota.nt_chars = nt_chars;
			quota.text_len = text_len;
		}
Exemple #32
0
        // from http://blogs.msdn.com/drnick/archive/2006/07/19/670789.aspx
        static void WSDualHttpMain()
        {
            // <Snippet1>
            WSDualHttpBinding binding = new WSDualHttpBinding();
            // </Snippet1>


            // <Snippet2>
            string            configName    = "string";
            WSDualHttpBinding bindingString = new WSDualHttpBinding(configName);
            // </Snippet2>

            // <Snippet3>
            WSDualHttpBinding bindingSecurityMode =
                new WSDualHttpBinding(WSDualHttpSecurityMode.Message);
            // </Snippet3>


            /*            String clientBaseAddress = "http://localhost:8080/Discovery/" + Guid.NewGuid().ToString();
             *          Uri clientBaseAddressUri = new Uri(clientBaseAddress);
             *          WSDualHttpBinding bindingClientBaseAddress =
             *              new WSDualHttpBinding(clientBaseAddressUri);
             */
            // <Snippet8>
            WSDualHttpBinding dualBinding = new WSDualHttpBinding();
            EndpointAddress   endptadr    = new EndpointAddress("http://localhost:12000/DuplexTestUsingCode/Server");

            dualBinding.ClientBaseAddress = new Uri("http://localhost:8000/DuplexTestUsingCode/Client/");

            // </Snippet8>

            // <Snippet9>
            // Set to StrongWildCard
            binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            // </Snippet9>

            // <Snippet10>
            binding.MaxBufferPoolSize = 900000;
            // </Snippet10>

            // <Snippet11>
            binding.MessageEncoding = WSMessageEncoding.Mtom;
            // </Snippet11>

            // <Snippet12>
            string proxyAddressString  = "http://localhost:5049";
            Uri    proxyBaseAddressUri = new Uri(proxyAddressString);

            binding.ProxyAddress = proxyBaseAddressUri;
            // </Snippet12>

            // <Snippet13>
            XmlDictionaryReaderQuotas readerQuotas =
                binding.ReaderQuotas;
            // </Snippet13>

            // <Snippet14>
            ReliableSession reliableSession =
                binding.ReliableSession;
            // </Snippet14>

            // <Snippet15>
            string scheme = binding.Scheme;
            // </Snippet15>

            // <Snippet16>
            WSDualHttpSecurity security = binding.Security;
            // </Snippet16>

            // <Snippet17>
            Encoding bindingEncoding = binding.TextEncoding;

            // </Snippet17>

            // <Snippet18>
            binding.TransactionFlow = true;
            // </Snippet18>

            // <Snippet19>
            binding.UseDefaultWebProxy = true;
            // </Snippet19>

            // <Snippet20>
            BindingElementCollection bec = binding.CreateBindingElements();
            // </Snippet20>

            // <Snippet21>
            EnvelopeVersion envelopeversion = binding.EnvelopeVersion;
            // </Snippet21>

            // <Snippet22>
            long maxReceivedMessageSize = binding.MaxReceivedMessageSize;

            // </Snippet22>



            binding.Security.Mode = WSDualHttpSecurityMode.None;

            WSDualHttpBinding binding3 = new WSDualHttpBinding();

            binding3.Security.Mode   = WSDualHttpSecurityMode.None;
            binding3.MessageEncoding = WSMessageEncoding.Mtom;

            // <Snippet6>
            WSDualHttpBinding BypassProxyOnLocalBinding =
                new WSDualHttpBinding();

            BypassProxyOnLocalBinding.BypassProxyOnLocal = true;
            // </Snippet6>

            //AnalyzeBindings(binding1, binding2, binding3);
        }
 public static XmlDictionaryReader CreateBinaryReader(Stream stream, IXmlDictionary dictionary, XmlDictionaryReaderQuotas quotas);
Exemple #34
0
 private CustomTextMessageBindingElement(CustomTextMessageBindingElement binding)
     : this(binding.Encoding, binding.MediaType, binding.MessageVersion)
 {
     _readerQuotas = new XmlDictionaryReaderQuotas();
     binding.ReaderQuotas.CopyTo(_readerQuotas);
 }
 public static XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, XmlDictionaryReaderQuotas quotas);
Exemple #36
0
 public static bool IsDefaultReaderQuotas(XmlDictionaryReaderQuotas quotas)
 {
     return(quotas.ModifiedQuotas == 0x00);
 }
 public static XmlDictionaryReader CreateTextReader(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose);
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (version == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
                }
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                _writeEncoding        = writeEncoding;
                _optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                _thisLock = new object();

                _version          = version;
                _maxReadPoolSize  = maxReadPoolSize;
                _maxWritePoolSize = maxWritePoolSize;

                _readerQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(_readerQuotas);
                _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(_readerQuotas);

                _mediaType   = TextMessageEncoderFactory.GetMediaType(version);
                _contentType = TextMessageEncoderFactory.GetContentType(_mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    _contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    // public profile does not allow SOAP1.1/WSA1.0. However, the EnvelopeVersion 1.1 is supported. Need to know what the implications are here
                    // but I think that it's not necessary to have here since we're a sender in N only.
                    _contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    _contentEncodingMap = TextMessageEncoderFactory.SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.Format(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }
 public void CopyTo(XmlDictionaryReaderQuotas quotas);
Exemple #40
0
        private void downloadHTMLPage()
        {
            List <string> thumbs   = new List <string>();
            string        htmlPage = "";
            string        str      = "";
            string        baseURL  = "//i.4cdn.org/" + getURL().Split('/')[3] + "/";
            string        JURL     = "http://a.4cdn.org/" + getURL().Split('/')[3] + "/thread/" + getURL().Split('/')[5] + ".json";

            try
            {
                //Add a UserAgent to prevent 403
                WebClient web = new WebClient();
                web.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0";

                htmlPage = web.DownloadString(getURL());

                //Prevent the html from being destroyed by the anti adblock script
                htmlPage = htmlPage.Replace("f=\"to\"", "f=\"penis\"");

                string json  = web.DownloadString(JURL);
                byte[] bytes = Encoding.ASCII.GetBytes(json);
                using (var stream = new MemoryStream(bytes))
                {
                    var quotas     = new XmlDictionaryReaderQuotas();
                    var jsonReader = JsonReaderWriterFactory.CreateJsonReader(stream, quotas);
                    var xml        = XDocument.Load(jsonReader);
                    str = xml.ToString();
                }

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(str);
                XmlNodeList xmlTim = doc.DocumentElement.SelectNodes("/root/posts/item/tim");
                XmlNodeList xmlExt = doc.DocumentElement.SelectNodes("/root/posts/item/ext");

                for (int i = 0; i < xmlExt.Count; i++)
                {
                    string old = baseURL + xmlTim[i].InnerText + xmlExt[i].InnerText;
                    string rep = xmlTim[i].InnerText + xmlExt[i].InnerText;
                    htmlPage = htmlPage.Replace(old, rep);

                    //Save thumbs for files that need it
                    if (rep.Split('.')[1] == "webm" /*|| rep.Split('.')[1] == ""*/)
                    {
                        old = "//t.4cdn.org/" + getURL().Split('/')[3] + "/" + xmlTim[i].InnerText + "s.jpg";
                        thumbs.Add("http:" + old);

                        htmlPage = htmlPage.Replace("//i.4cdn.org/" + getURL().Split('/')[3] + "/" + xmlTim[i].InnerText, "thumb/" + xmlTim[i].InnerText);
                    }
                    else
                    {
                        string thumbName = rep.Split('.')[0] + "s";
                        htmlPage = htmlPage.Replace(thumbName + ".jpg", rep.Split('.')[0] + "." + rep.Split('.')[1]);
                        htmlPage = htmlPage.Replace("/" + thumbName, thumbName);

                        htmlPage = htmlPage.Replace("//i.4cdn.org/" + getURL().Split('/')[3] + "/" + xmlTim[i].InnerText, xmlTim[i].InnerText);
                    }

                    htmlPage = htmlPage.Replace("//is2.4chan.org/" + getURL().Split('/')[3] + "/" + xmlTim[i].InnerText, xmlTim[i].InnerText);
                    htmlPage = htmlPage.Replace("/" + rep, rep);
                }

                htmlPage = htmlPage.Replace("=\"//", "=\"http://");

                //Save thumbs for files that need it
                for (int i = 0; i < thumbs.Count; i++)
                {
                    General.DownloadToDir(thumbs[i], SaveTo + "\\thumb");
                }

                if (!string.IsNullOrWhiteSpace(htmlPage))
                {
                    File.WriteAllText(SaveTo + "\\Thread.html", htmlPage);
                }
            }
            catch
            {
                throw;
            }
        }