Пример #1
0
 internal override IEnumerable<ServiceEndpoint> Discover()
 {
     List<ServiceEndpoint> endpoints = new List<ServiceEndpoint>();
     // Attempt YADIS discovery
     DiscoveryResult yadisResult = Yadis.Yadis.Discover(this, IsDiscoverySecureEndToEnd);
     if (yadisResult != null) {
         if (yadisResult.IsXrds) {
             XrdsDocument xrds = new XrdsDocument(yadisResult.ResponseText);
             var xrdsEndpoints = xrds.CreateServiceEndpoints(yadisResult.NormalizedUri);
             // Filter out insecure endpoints if high security is required.
             if (IsDiscoverySecureEndToEnd) {
                 xrdsEndpoints = Util.Where(xrdsEndpoints, se => se.IsSecure);
             }
             endpoints.AddRange(xrdsEndpoints);
         }
         // Failing YADIS discovery of an XRDS document, we try HTML discovery.
         if (endpoints.Count == 0) {
             ServiceEndpoint ep = DiscoverFromHtml(yadisResult.NormalizedUri, yadisResult.ResponseText);
             if (ep != null && (!IsDiscoverySecureEndToEnd || ep.IsSecure)) {
                 endpoints.Add(ep);
             }
         }
     }
     return endpoints;
 }
Пример #2
0
		internal override IEnumerable<ServiceEndpoint> Discover() {
			List<ServiceEndpoint> endpoints = new List<ServiceEndpoint>();
			// Attempt YADIS discovery
			DiscoveryResult yadisResult = Yadis.Yadis.Discover(this, IsDiscoverySecureEndToEnd);
			if (yadisResult != null) {
				if (yadisResult.IsXrds) {
					XrdsDocument xrds = new XrdsDocument(yadisResult.ResponseText);
					var xrdsEndpoints = xrds.CreateServiceEndpoints(yadisResult.NormalizedUri);
					// Filter out insecure endpoints if high security is required.
					if (IsDiscoverySecureEndToEnd) {
						xrdsEndpoints = Util.Where(xrdsEndpoints, se => se.IsSecure);
					}
					endpoints.AddRange(xrdsEndpoints);
				}
				// Failing YADIS discovery of an XRDS document, we try HTML discovery.
				if (endpoints.Count == 0) {
					ServiceEndpoint ep = DiscoverFromHtml(yadisResult.NormalizedUri, yadisResult.ResponseText);
					if (ep != null) {
						Logger.Debug("HTML discovery found a service endpoint.");
						Logger.Debug(ep);
						if (!IsDiscoverySecureEndToEnd || ep.IsSecure) {
							endpoints.Add(ep);
						} else {
							Logger.Info("Skipping HTML discovered endpoint because it is not secure.");
						}
					} else {
						Logger.Debug("HTML discovery failed to find any endpoints.");
					}
				} else {
					Logger.Debug("Skipping HTML discovery because XRDS contained service endpoints.");
				}
			}
			return endpoints;
		}