Exemplo n.º 1
0
        public void OrganizationsTest()
        {
            const string organizationListJson = @"{
  ""organization_list"": [
    {
      ""display_name"": {
        ""nl"": ""SURFnet bv"",
        ""en"": ""SURFnet bv""
      },
      ""org_id"": ""https://idp.surfnet.nl"",
      ""secure_internet_home"": ""https://nl.eduvpn.org/"",
      ""keyword_list"": {
        ""en"": ""SURFnet bv SURF konijn surf surfnet powered by"",
        ""nl"": ""SURFnet bv SURF konijn powered by""
      }
    }
  ]
}";
            var          dict = new OrganizationDictionary();

            dict.LoadJSON(organizationListJson);

            var org = dict["https://idp.surfnet.nl"];

            Assert.AreEqual(new Uri("https://nl.eduvpn.org/"), org.SecureInternetBase, "Secure internet base incorrect");
        }
Exemplo n.º 2
0
        public void OrganizationsNetworkTest()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""https://disco.eduvpn.org/v2/organization_list.json"">
						<MinisignPublicKeyDictionary Key=""PublicKeys"">
							<PublicKey>RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF</PublicKey>
							<PublicKey>RWQKqtqvd0R7rUDp0rWzbtYPA3towPWcLDCl7eY9pBMMI/ohCmrS0WiM</PublicKey>
						</MinisignPublicKeyDictionary>
					</ResourceRef>"                    )));

            while (xmlReader.ReadState == ReadState.Initial)
            {
                xmlReader.Read();
            }
            var source = new ResourceRef();

            source.ReadXml(xmlReader);

            // Load list of organizations.
            var organizationListJson = Response.Get(source);
            var dict = new OrganizationDictionary();

            dict.LoadJSON(organizationListJson.Value);

            // Re-load list of organizations.
            Response.Get(
                res: source,
                previous: organizationListJson);
        }
Exemplo n.º 3
0
        public void OrganizationsNetworkTest()
        {
            // .NET 3.5 allows Schannel to use SSL 3 and TLS 1.0 by default. Instead of hacking user computer's registry, extend it in runtime.
            // System.Net.SecurityProtocolType lacks appropriate constants prior to .NET 4.5.
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x0C00 | (SecurityProtocolType)0x3000;

            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""https://disco.eduvpn.org/v2/organization_list.json"">
						<MinisignPublicKeyDictionary Key=""PublicKeys"">
							<PublicKey>RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF</PublicKey>
							<PublicKey>RWQ68Y5/b8DED0TJ41B1LE7yAvkmavZWjDwCBUuC+Z2pP9HaSawzpEDA</PublicKey>
							<PublicKey>RWQKqtqvd0R7rUDp0rWzbtYPA3towPWcLDCl7eY9pBMMI/ohCmrS0WiM</PublicKey>
						</MinisignPublicKeyDictionary>
					</ResourceRef>"                    )));

            while (xmlReader.ReadState == ReadState.Initial)
            {
                xmlReader.Read();
            }
            var source = new ResourceRef();

            source.ReadXml(xmlReader);

            // Load list of organizations.
            var organizationListJson = Xml.Response.Get(source);
            var dict = new OrganizationDictionary();

            dict.LoadJSON(organizationListJson.Value);

            // Re-load list of organizations.
            Xml.Response.Get(
                res: source,
                previous: organizationListJson);
        }
Exemplo n.º 4
0
        public static bool Recognition(LinkedList <Vertex> pWordSegResult, WordNet wordNetOptimum, WordNet wordNetAll)
        {
            LinkedList <EnumItem <Corpus.Tag.NT> > roleTagList = roleTag(pWordSegResult, wordNetAll);

            if (HanLP.Config.DEBUG)
            {
                StringBuilder sbLog = new StringBuilder();
                //Iterator<Vertex> iterator = pWordSegResult.iterator();
                foreach (EnumItem <Corpus.Tag.NT> NTEnumItem in roleTagList)
                {
                    sbLog.Append('[');
                    //sbLog.Append(iterator.next().realWord);
                    sbLog.Append(' ');
                    sbLog.Append(NTEnumItem);
                    sbLog.Append(']');
                }
                Console.WriteLine("机构名角色观察:%s\n", sbLog.ToString());
            }
            LinkedList <Corpus.Tag.NT> NTList = viterbiExCompute(roleTagList);

            if (HanLP.Config.DEBUG)
            {
                StringBuilder sbLog = new StringBuilder();
                //Iterator<Vertex> iterator = pWordSegResult.iterator();
                sbLog.Append('[');
                foreach (Corpus.Tag.NT NT in NTList)
                {
                    //sbLog.Append(iterator.next().realWord);
                    sbLog.Append('/');
                    sbLog.Append(NT);
                    sbLog.Append(" ,");
                }
                if (sbLog.Length > 1)
                {
                    sbLog.Remove(sbLog.Length - 2, sbLog.Length);
                }
                sbLog.Append(']');
                Console.WriteLine("机构名角色标注:%s\n", sbLog.ToString());
            }

            OrganizationDictionary.parsePattern(NTList, pWordSegResult, wordNetOptimum, wordNetAll);
            return(true);
        }