public static ProxyClassesDumper GetInstance(String path) { if (null == path) { return(null); } try { path = path.Trim(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.nio.file.Path dir = java.nio.file.Paths.get(path.length() == 0 ? "." : path); Path dir = Paths.Get(path.Length() == 0 ? "." : path); AccessController.DoPrivileged(new PrivilegedActionAnonymousInnerClassHelper(dir), null, new FilePermission("<<ALL FILES>>", "read, write")); return(new ProxyClassesDumper(dir)); } catch (InvalidPathException ex) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: PlatformLogger.getLogger(typeof(ProxyClassesDumper).FullName).warning("Path " + path + " is not valid - dumping disabled", ex); } catch (IllegalArgumentException iae) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: PlatformLogger.getLogger(typeof(ProxyClassesDumper).FullName).warning(iae.Message + " - dumping disabled"); } return(null); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: //ORIGINAL LINE: public void dumpClass(String className, final byte[] classBytes) public void DumpClass(String className, sbyte[] classBytes) { Path file; try { file = DumpDir.Resolve(EncodeForFilename(className) + ".class"); } catch (InvalidPathException) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: PlatformLogger.getLogger(typeof(ProxyClassesDumper).FullName).warning("Invalid path for class " + className); return; } try { Path dir = file.Parent; Files.createDirectories(dir); Files.write(file, classBytes); } catch (Exception) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: PlatformLogger.getLogger(typeof(ProxyClassesDumper).FullName).warning("Exception writing to path at " + file.ToString()); // simply don't care if this operation failed } }
private static void Info(String message, Throwable t) { PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency"); if (logger.isLoggable(PlatformLogger.Level.INFO)) { if (t != null) { logger.info(message, t); } else { logger.info(message); } } }
public static void LogMessage(Logger.LogLevel logLevel, string formattedMessage) { switch (logLevel) { case Logger.LogLevel.Error: PlatformLogger.Error(formattedMessage); break; case Logger.LogLevel.Warning: PlatformLogger.Warning(formattedMessage); break; case Logger.LogLevel.Info: PlatformLogger.Information(formattedMessage); break; case Logger.LogLevel.Verbose: PlatformLogger.Verbose(formattedMessage); break; } }
protected override bool Init() { bool result = base.Init(); (ConfigLoadResult result, ServerPlatformConfig config)configData = Configs.Impl.Config.Load <ServerPlatformConfig>("server_config.json"); if (configData.result == ConfigLoadResult.Success || configData.result == ConfigLoadResult.Upgrade) { ServerConfig = configData.config; } else { return(false); } PlatformLogger.Info(StringManager.GetString("minecore.app.start")); Protocol = new MineCraftProtocol(); NetworkManager = new ServerNetworkManager(new IPEndPoint(IPAddress.Any, ServerConfig.ServerPort), this); return(result); }
public override PlatformStartResult Start() { PlatformStartResult result = base.Start(); if (result == PlatformStartResult.Failed) { return(PlatformStartResult.Failed); } else if (result == PlatformStartResult.Started) { return(PlatformStartResult.Started); } NetworkManager.Start(); IPEndPoint endPoint = NetworkManager.ServerEndPoint; PlatformLogger.Info(StringManager.GetString("minecore.network.start", endPoint.Address.ToString(), endPoint.Port)); return(PlatformStartResult.Success); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void put(URI uri, java.util.Map<String, java.util.List<String>> responseHeaders) throws java.io.IOException public override void Put(URI uri, IDictionary <String, IList <String> > responseHeaders) { // pre-condition check if (uri == null || responseHeaders == null) { throw new IllegalArgumentException("Argument is null"); } // if there's no default CookieStore, no need to remember any cookie if (CookieJar == null) { return; } PlatformLogger logger = PlatformLogger.getLogger("java.net.CookieManager"); foreach (String headerKey in responseHeaders.Keys) { // RFC 2965 3.2.2, key must be 'Set-Cookie2' // we also accept 'Set-Cookie' here for backward compatibility if (headerKey == null || !(headerKey.EqualsIgnoreCase("Set-Cookie2") || headerKey.EqualsIgnoreCase("Set-Cookie"))) { continue; } foreach (String headerValue in responseHeaders[headerKey]) { try { IList <HttpCookie> cookies; try { cookies = HttpCookie.Parse(headerValue); } catch (IllegalArgumentException) { // Bogus header, make an empty list and log the error cookies = Collections.EmptyList(); if (logger.isLoggable(PlatformLogger.Level.SEVERE)) { logger.severe("Invalid cookie for " + uri + ": " + headerValue); } } foreach (HttpCookie cookie in cookies) { if (cookie.Path == null) { // If no path is specified, then by default // the path is the directory of the page/doc String path = uri.Path; if (!path.EndsWith("/")) { int i = path.LastIndexOf("/"); if (i > 0) { path = path.Substring(0, i + 1); } else { path = "/"; } } cookie.Path = path; } // As per RFC 2965, section 3.3.1: // Domain Defaults to the effective request-host. (Note that because // there is no dot at the beginning of effective request-host, // the default Domain can only domain-match itself.) if (cookie.Domain == null) { String host = uri.Host; if (host != null && !host.Contains(".")) { host += ".local"; } cookie.Domain = host; } String ports = cookie.Portlist; if (ports != null) { int port = uri.Port; if (port == -1) { port = "https".Equals(uri.Scheme) ? 443 : 80; } if (ports.Empty) { // Empty port list means this should be restricted // to the incoming URI port cookie.Portlist = "" + port; if (ShouldAcceptInternal(uri, cookie)) { CookieJar.Add(uri, cookie); } } else { // Only store cookies with a port list // IF the URI port is in that list, as per // RFC 2965 section 3.3.2 if (IsInPortList(ports, port) && ShouldAcceptInternal(uri, cookie)) { CookieJar.Add(uri, cookie); } } } else { if (ShouldAcceptInternal(uri, cookie)) { CookieJar.Add(uri, cookie); } } } } catch (IllegalArgumentException) { // invalid set-cookie header string // no-op } } } }
/* * Reads attributes from the specified input stream. * XXX Need to handle UTF8 values. */ //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: void read(Manifest.FastInputStream is, byte[] lbuf) throws java.io.IOException internal virtual void Read(Manifest.FastInputStream @is, sbyte[] lbuf) { String name = java.util.Map_Fields.Null, value = java.util.Map_Fields.Null; sbyte[] lastline = java.util.Map_Fields.Null; int len; while ((len = @is.ReadLine(lbuf)) != -1) { bool lineContinued = java.util.Map_Fields.False; if (lbuf[--len] != '\n') { throw new IOException("line too long"); } if (len > 0 && lbuf[len - 1] == '\r') { --len; } if (len == 0) { break; } int i = 0; if (lbuf[0] == ' ') { // continuation of previous line if (name == java.util.Map_Fields.Null) { throw new IOException("misplaced continuation line"); } lineContinued = java.util.Map_Fields.True; sbyte[] buf = new sbyte[lastline.Length + len - 1]; System.Array.Copy(lastline, 0, buf, 0, lastline.Length); System.Array.Copy(lbuf, 1, buf, lastline.Length, len - 1); if (@is.Peek() == ' ') { lastline = buf; continue; } value = StringHelperClass.NewString(buf, 0, buf.Length, "UTF8"); lastline = java.util.Map_Fields.Null; } else { while (lbuf[i++] != ':') { if (i >= len) { throw new IOException("invalid header field"); } } if (lbuf[i++] != ' ') { throw new IOException("invalid header field"); } name = StringHelperClass.NewString(lbuf, 0, 0, i - 2); if (@is.Peek() == ' ') { lastline = new sbyte[len - i]; System.Array.Copy(lbuf, i, lastline, 0, len - i); continue; } value = StringHelperClass.NewString(lbuf, i, len - i, "UTF8"); } try { if ((PutValue(name, value) != java.util.Map_Fields.Null) && (!lineContinued)) { PlatformLogger.getLogger("java.util.jar").warning("Duplicate name in Manifest: " + name + ".\n" + "Ensure that the manifest does not " + "have duplicate entries, and\n" + "that blank lines separate " + "individual sections in both your\n" + "manifest and in the META-INF/MANIFEST.MF " + "entry in the jar file."); } } catch (IllegalArgumentException) { throw new IOException("invalid header field name: " + name); } } }