コード例 #1
0
ファイル: TldVerify.cs プロジェクト: tompipe/uniaccept-cs
        /*
         * Updates the copy of the fixed database of valid top-level
         * domains.
         * Downloads the official list of valid TLDs from the IANA website,
         * and performs consistency checking to ensure it was downloaded
         * correctly. The parameter is the filename to store the cache in.
         *
         * @param cacheStoreFileName The full path to the file to store the cache in.
         * @throws TLDVerifyException
         */
        public void refreshTldDB(string cacheStoreFileName)
        {
            try
            {
                string    outputCacheName = TLD_CACHE_FILE;
                string    tempFile        = "temp_md5 " + DateTime.Now.Ticks;
                FileInfo  tFile           = new FileInfo(tempFile);
                WebClient toFile          = new WebClient();
                toFile.DownloadFile(TLDS_BY_DOMAIN_TXT, tempFile);

                string digest  = getDigestInfo(MD5_URL);
                string digest1 = new FileBasedMD5Generator().createDigest(tempFile);

                if (!digest.Equals(digest1))
                {
                    throw new TLDVerifyException("Could not download TLD data from IANA web site");
                }

                readTld(tFile);
                tFile.Delete();

                if (cacheStoreFileName != null)
                {
                    outputCacheName = cacheStoreFileName;
                }

                writeTlds(outputCacheName);
            }
            catch (Exception e)
            {
                throw new TLDVerifyException(e.Message, e);
            }
        }
コード例 #2
0
ファイル: TldVerify.cs プロジェクト: icann/uniaccept-cs
        /*
         * Updates the copy of the fixed database of valid top-level
         * domains.
         * Downloads the official list of valid TLDs from the IANA website,
         * and performs consistency checking to ensure it was downloaded
         * correctly. The parameter is the filename to store the cache in.
         *
         * @param cacheStoreFileName The full path to the file to store the cache in.
         * @throws TLDVerifyException
         */
        public void refreshTldDB(string cacheStoreFileName)
        {
            try
            {
                string outputCacheName = TLD_CACHE_FILE;
                string tempFile = "temp_md5 " + DateTime.Now.Ticks;
                FileInfo tFile = new FileInfo(tempFile);
                WebClient toFile = new WebClient();
                toFile.DownloadFile(TLDS_BY_DOMAIN_TXT, tempFile);

                string digest = getDigestInfo(MD5_URL);
                string digest1 = new FileBasedMD5Generator().createDigest(tempFile);

                if (!digest.Equals(digest1)) {
                    throw new TLDVerifyException("Could not download TLD data from IANA web site");
                }

                readTld(tFile);
                tFile.Delete();

                if (cacheStoreFileName != null) {
                    outputCacheName = cacheStoreFileName;
                }

                writeTlds(outputCacheName);
            }
            catch (Exception e)
            {
                throw new TLDVerifyException(e.Message, e);
            }
        }