private static void FetchMetadata(Logging.IInternalLogger logger, IdentityProviders identityProviders, string metadataLocation) { // Get new metadata files foreach (var identityProvider in identityProviders) { logger.DebugFormat("Attempting to fetch SAML metadata file for identity provider {0}", identityProvider.Id); var metadataEndpoint = identityProvider.Endpoints.FirstOrDefault(x => x.Type == EndpointType.Metadata); if (metadataEndpoint == null) { continue; } var metadataEndpointUrl = metadataEndpoint.Url; var metadataFile = Path.Combine(metadataLocation, identityProvider.Id + ".xml"); // Fetch new file try { var client = new WebClient(); client.DownloadFile(metadataEndpointUrl, metadataFile + ".new"); // Wipe old file if (File.Exists(metadataFile)) { File.Delete(metadataFile); } // Move new file into place File.Move(metadataFile + ".new", metadataFile); logger.DebugFormat("Successfully updated SAML metadata file for identity provider {0}", identityProvider.Id); } catch (WebException ex) { logger.Warn(string.Format("Unable to fetch SAML metadata file for identity provider {0}", identityProvider.Id), ex); } } }
// GET: /SchoolTeacher/ public ActionResult Index() { try { // TODO: DG: This controller is not used for March release. // Need to select the correct school id. SiteUser siteUser = ((SiteUser)Session["SiteUser"]); List<UserSchool> userSchool = ((SiteUser)Session["SiteUser"]).Schools.Take(1).ToList(); int schoolId = userSchool[0].Id; List<int> teacherIds = modelServices.GetSchoolTeacherIds(schoolId); //var tblschooluserroles = (from s in db.tblSchoolUserRoles.Include(t => t.tblRole).Include(t => t.tblSchool).Include(t => t.tblUser) // where (teacherIds.Contains(s.UserId)) // select s); //return View(tblschooluserroles.ToList()); return View(); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); throw; } }
private AjaxError(HttpStatusCode statusCode, string details, Logging logging, Dictionary<string, IEnumerable<string>> errors) { StatusCode = statusCode; Message = HttpWorkerRequest.GetStatusDescription((int)statusCode); Details = details; ShouldLog = logging == Logging.Log; Errors = errors; }
public void SetUp () { Console.WriteLine ("Setting up"); if (app==null) { app = new KZApplication(Constants.marketplace, Constants.application,Constants.applicationKey); app.Initialize().Wait(); app.Authenticate(Constants.user, Constants.pass, Constants.provider).Wait(); } if (logging == null) { logging = app.Logger; } logging.Write("foo", LogLevel.LogLevelVerbose).Wait(); logging.Clear().Wait(); }
// GET: /SchoolTeacher/Create public ActionResult Create() { try { ViewBag.RoleId = new SelectList(db.tblRoles, "RoleId", "RoleDesc"); ViewBag.SchoolId = new SelectList(db.tblSchools, "SchoolId", "SchoolDesc"); ViewBag.UserId = new SelectList(db.tblUsers, "UserId", "FirstName"); return View(); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); throw; } }
private void AllocServices(JObject config) { #if !NET45 Notification = new Notification(this, config.ValueUri("notification")); PubSubChannel = new PubSubChannel(this, config.ValueUri("pubsub"), config.ValueUri("ws")); #endif Marketplace = new Marketplace(this, marketPlaceUri); Queue = new Queue(this, config.ValueUri("queue")); Configuration = new Configuration(this, config.ValueUri("config")); SmsSender = new SmsSender(this, config.ValueUri("sms")); MailSender = new MailSender(this, config.ValueUri("email")); Logger = new Logging(this, config.ValueUri("logging")); Storage = new Storage(this, config.ValueUri("storage")); Files = new Files(this, config.ValueUri("files")); Authentication = new Authentication(marketPlaceUri.Host, config.Value<JObject>("authConfig"), this.Name); Service = new Service(this, config.ValueUri("service")); DataSource = new DataSource(this, config.ValueUri("datasource")); }
void Logging.IMessageLogger.LogMessageCreate(Logging.LogMessage message) { LogMessageCreated(this, new Logging.LogMessageEventArgs(message)); }
private void LogMessageCreate(Logging.LogMessage message) { if (LogMessageCreated != null) { LogMessageCreated(this, new DnsClient.Logging.LogMessageEventArgs(message)); } }
public bool isInNetEx(string ipAddress, string ipPrefix) { IPAddress address; IPAddress address2; if (ipAddress == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isResolvable()", "ipAddress" })); } throw new ArgumentNullException("ipAddress"); } if (ipPrefix == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isResolvable()", "ipPrefix" })); } throw new ArgumentNullException("ipPrefix"); } if (!IPAddress.TryParse(ipAddress, out address)) { throw new FormatException(SR.GetString("dns_bad_ip_address")); } if (ipPrefix.IndexOf("/") < 0) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } string[] strArray = ipPrefix.Split(new char[] { '/' }); if ((((strArray.Length != 2) || (strArray[0] == null)) || ((strArray[0].Length == 0) || (strArray[1] == null))) || ((strArray[1].Length == 0) || (strArray[1].Length > 2))) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } if (!IPAddress.TryParse(strArray[0], out address2)) { throw new FormatException(SR.GetString("dns_bad_ip_address")); } int result = 0; if (!int.TryParse(strArray[1], out result)) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } if (address.AddressFamily != address2.AddressFamily) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } if (((address.AddressFamily == AddressFamily.InterNetworkV6) && ((result < 1) || (result > 0x40))) || ((address.AddressFamily == AddressFamily.InterNetwork) && ((result < 1) || (result > 0x20)))) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } byte[] addressBytes = address2.GetAddressBytes(); byte index = (byte)(result / 8); byte num4 = (byte)(result % 8); byte num5 = index; if (num4 != 0) { if ((0xff & (addressBytes[index] << num4)) != 0) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } num5 = (byte)(num5 + 1); } int num6 = (address2.AddressFamily == AddressFamily.InterNetworkV6) ? 0x10 : 4; while (num5 < num6) { num5 = (byte)(num5 + 1); if (addressBytes[num5] != 0) { throw new FormatException(SR.GetString("net_bad_ip_address_prefix")); } } byte[] buffer2 = address.GetAddressBytes(); for (num5 = 0; num5 < index; num5 = (byte)(num5 + 1)) { if (buffer2[num5] != addressBytes[num5]) { return(false); } } if (num4 > 0) { byte num7 = buffer2[index]; byte num8 = addressBytes[index]; num7 = (byte)(num7 >> (8 - num4)); num7 = (byte)(num7 << (8 - num4)); if (num7 != num8) { return(false); } } return(true); }
private BaseWebProxyFinder.AutoWebProxyState DownloadAndCompile(Uri location) { BaseWebProxyFinder.AutoWebProxyState downloadFailure = BaseWebProxyFinder.AutoWebProxyState.DownloadFailure; WebResponse response = null; TimerThread.Timer timer = null; AutoWebProxyScriptWrapper scriptInstance = null; ExceptionHelper.WebPermissionUnrestricted.Assert(); try { lock (this.lockObject) { if (this.aborted) { throw new WebException(NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.RequestCanceled), WebExceptionStatus.RequestCanceled); } this.request = WebRequest.Create(location); } this.request.Timeout = -1; this.request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Default); this.request.ConnectionGroupName = "__WebProxyScript"; if (this.request.CacheProtocol != null) { this.request.CacheProtocol = new RequestCacheProtocol(this.backupCache, this.request.CacheProtocol.Validator); } HttpWebRequest request = this.request as HttpWebRequest; if (request != null) { request.Accept = "*/*"; request.UserAgent = base.GetType().FullName + "/" + Environment.Version; request.KeepAlive = false; request.Pipelined = false; request.InternalConnectionGroup = true; } else { FtpWebRequest request2 = this.request as FtpWebRequest; if (request2 != null) { request2.KeepAlive = false; } } this.request.Proxy = null; this.request.Credentials = base.Engine.Credentials; if (timerQueue == null) { timerQueue = TimerThread.GetOrCreateQueue(SettingsSectionInternal.Section.DownloadTimeout); } timer = timerQueue.CreateTimer(timerCallback, this.request); response = this.request.GetResponse(); DateTime minValue = DateTime.MinValue; HttpWebResponse response2 = response as HttpWebResponse; if (response2 != null) { minValue = response2.LastModified; } else { FtpWebResponse response3 = response as FtpWebResponse; if (response3 != null) { minValue = response3.LastModified; } } if (((this.scriptInstance != null) && (minValue != DateTime.MinValue)) && (this.scriptInstance.LastModified == minValue)) { scriptInstance = this.scriptInstance; downloadFailure = BaseWebProxyFinder.AutoWebProxyState.Completed; } else { string scriptBody = null; byte[] buffer = null; using (Stream stream = response.GetResponseStream()) { SingleItemRequestCache.ReadOnlyStream stream2 = stream as SingleItemRequestCache.ReadOnlyStream; if (stream2 != null) { buffer = stream2.Buffer; } if (((this.scriptInstance != null) && (buffer != null)) && (buffer == this.scriptInstance.Buffer)) { this.scriptInstance.LastModified = minValue; scriptInstance = this.scriptInstance; downloadFailure = BaseWebProxyFinder.AutoWebProxyState.Completed; } else { using (StreamReader reader = new StreamReader(stream)) { scriptBody = reader.ReadToEnd(); } } } WebResponse response4 = response; response = null; response4.Close(); timer.Cancel(); timer = null; if (downloadFailure != BaseWebProxyFinder.AutoWebProxyState.Completed) { if ((this.scriptInstance != null) && (scriptBody == this.scriptInstance.ScriptBody)) { this.scriptInstance.LastModified = minValue; if (buffer != null) { this.scriptInstance.Buffer = buffer; } scriptInstance = this.scriptInstance; downloadFailure = BaseWebProxyFinder.AutoWebProxyState.Completed; } else { scriptInstance = new AutoWebProxyScriptWrapper { LastModified = minValue }; if (scriptInstance.Compile(location, scriptBody, buffer)) { downloadFailure = BaseWebProxyFinder.AutoWebProxyState.Completed; } else { downloadFailure = BaseWebProxyFinder.AutoWebProxyState.CompilationFailure; } } } } } catch (Exception exception) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_script_download_compile_error", new object[] { exception })); } } finally { if (timer != null) { timer.Cancel(); } try { if (response != null) { response.Close(); } } finally { CodeAccessPermission.RevertAssert(); this.request = null; } } if ((downloadFailure == BaseWebProxyFinder.AutoWebProxyState.Completed) && (this.scriptInstance != scriptInstance)) { if (this.scriptInstance != null) { this.scriptInstance.Close(); } this.scriptInstance = scriptInstance; } return(downloadFailure); }
internal static void Dump(TraceSource traceSource, object obj, string method, byte[] buffer, int offset, int length) { if (!ValidateSettings(traceSource, TraceEventType.Verbose)) { return; } if (buffer == null) { PrintLine(traceSource, TraceEventType.Verbose, 0, "(null)"); return; } if (offset > buffer.Length) { PrintLine(traceSource, TraceEventType.Verbose, 0, "(offset out of range)"); return; } PrintLine(traceSource, TraceEventType.Verbose, 0, "Data from " + GetObjectName(obj) + "#" + Logging.HashString(obj) + "::" + method); int maxDumpSize = GetMaxDumpSizeSetting(traceSource); if (length > maxDumpSize) { PrintLine(traceSource, TraceEventType.Verbose, 0, "(printing " + maxDumpSize.ToString(NumberFormatInfo.InvariantInfo) + " out of " + length.ToString(NumberFormatInfo.InvariantInfo) + ")"); length = maxDumpSize; } if ((length < 0) || (length > buffer.Length - offset)) { length = buffer.Length - offset; } do { int n = Math.Min(length, 16); string disp = string.Format(CultureInfo.CurrentCulture, "{0:X8} : ", offset); for (int i = 0; i < n; ++i) { disp += string.Format(CultureInfo.CurrentCulture, "{0:X2}", buffer[offset + i]) + ((i == 7) ? '-' : ' '); } for (int i = n; i < 16; ++i) { disp += " "; } disp += ": "; for (int i = 0; i < n; ++i) { disp += ((buffer[offset + i] < 0x20) || (buffer[offset + i] > 0x7e)) ? '.' : (char)(buffer[offset + i]); } PrintLine(traceSource, TraceEventType.Verbose, 0, disp); offset += n; length -= n; } while (length > 0); }
internal static string GetObjectLogHash(object obj) { return(GetObjectName(obj) + "#" + Logging.HashString(obj)); }
/*++ * * Create - Create a WebRequest. * * This is the main creation routine. We take a Uri object, look * up the Uri in the prefix match table, and invoke the appropriate * handler to create the object. We also have a parameter that * tells us whether or not to use the whole Uri or just the * scheme portion of it. * * Input: * * RequestUri - Uri object for request. * UseUriBase - True if we're only to look at the scheme * portion of the Uri. * * Returns: * * Newly created WebRequest. * --*/ private static WebRequest Create(Uri requestUri, bool useUriBase) { if (Logging.On) { Logging.Enter(Logging.Web, "WebRequest", "Create", requestUri.ToString()); } string LookupUri; WebRequestPrefixElement Current = null; bool Found = false; if (!useUriBase) { LookupUri = requestUri.AbsoluteUri; } else { // // schemes are registered as <schemeName>":", so add the separator // to the string returned from the Uri object // LookupUri = requestUri.Scheme + ':'; } int LookupLength = LookupUri.Length; // Copy the prefix list so that if it is updated it will // not affect us on this thread. ArrayList prefixList = PrefixList; // Look for the longest matching prefix. // Walk down the list of prefixes. The prefixes are kept longest // first. When we find a prefix that is shorter or the same size // as this Uri, we'll do a compare to see if they match. If they // do we'll break out of the loop and call the creator. for (int i = 0; i < prefixList.Count; i++) { Current = (WebRequestPrefixElement)prefixList[i]; // // See if this prefix is short enough. // if (LookupLength >= Current.Prefix.Length) { // // It is. See if these match. // if (String.Compare(Current.Prefix, 0, LookupUri, 0, Current.Prefix.Length, StringComparison.OrdinalIgnoreCase) == 0) { // // These match. Remember that we found it and break // out. // Found = true; break; } } } WebRequest webRequest = null; if (Found) { // // We found a match, so just call the creator and return what it // does. // webRequest = Current.Creator.Create(requestUri); if (Logging.On) { Logging.Exit(Logging.Web, "WebRequest", "Create", webRequest); } return(webRequest); } if (Logging.On) { Logging.Exit(Logging.Web, "WebRequest", "Create", null); } // // Otherwise no match, throw an exception. // throw new NotSupportedException(SR.GetString(SR.net_unknown_prefix)); }