derbynet

16:35:16.900 INFO  jd.cli.Main - Decompiling derbynet.jar
package org.apache.derby.drda;

import java.net.InetAddress;

class NetServlet$1
  implements Runnable
{
  private final NetServlet this$0;
  
  NetServlet$1(NetServlet paramNetServlet) {}
  
  public void run()
  {
    try
    {
      NetworkServerControl localNetworkServerControl = new NetworkServerControl(InetAddress.getByName(NetServlet.access$000(this$0)), NetServlet.access$100(this$0));
      localNetworkServerControl.start(null);
    }
    catch (Exception localException)
    {
      throw new RuntimeException(localException.getMessage());
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.derby.drda.NetServlet.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.derby.drda;

import java.security.PrivilegedExceptionAction;

class NetServlet$2
  implements PrivilegedExceptionAction
{
  private final NetServlet this$0;
  
  NetServlet$2(NetServlet paramNetServlet) {}
  
  public Object run()
    throws Exception
  {
    return new Thread(NetServlet.access$200(this$0));
  }
}

/* Location:
 * Qualified Name:     org.apache.derby.drda.NetServlet.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.derby.drda;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.util.Locale;
import java.util.Properties;
import java.util.StringTokenizer;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.derby.iapi.tools.i18n.LocalizedResource;

public class NetServlet
  extends HttpServlet
{
  private static final int MAX_CONNECT_TRYS = 20;
  private static final String SERVLET_PROP_MESSAGES = "org.apache.derby.loc.drda.servlet";
  private static final String SERVLET_ADDRESS = "derbynet";
  private String formHeader = null;
  private String host = "localhost";
  private int portNumber = 1527;
  private String tracingDirectory;
  private boolean logStatus = false;
  private boolean traceStatus = false;
  private String[] knownLang = { "cs", "en", "es", "de_DE", "fr", "hu", "it", "ja_JP", "ko_KR", "pl", "pt_BR", "ru", "zh_CN", "zh_TW" };
  private String locale;
  private static final int NOT_GIVEN = -2;
  private static final int INVALID = -3;
  private NetworkServerControl server;
  private PrintWriter out;
  private Runnable service;
  
  public void init(ServletConfig paramServletConfig)
    throws ServletException
  {
    String str1 = paramServletConfig.getInitParameter("portNumber");
    if (str1 != null)
    {
      int i = Integer.parseInt(str1);
      if (i > 0) {
        portNumber = i;
      }
    }
    String str2 = paramServletConfig.getInitParameter("host");
    if (str2 != null) {
      host = str2;
    }
    tracingDirectory = paramServletConfig.getInitParameter("tracingDirectory");
    if (tracingDirectory == null) {
      tracingDirectory = "";
    }
    String str3 = paramServletConfig.getInitParameter("startNetworkServerOnInit");
    try
    {
      if (server == null)
      {
        server = new NetworkServerControl(InetAddress.getByName(host), portNumber);
        if (!tracingDirectory.trim().equals("")) {
          server.setTraceDirectory(tracingDirectory);
        }
      }
      if (isServerStarted(server, 1)) {
        return;
      }
    }
    catch (Exception localException) {}
    if (str3 != null)
    {
      boolean bool = Boolean.valueOf(str3).booleanValue();
      if (bool)
      {
        LocalizedResource localLocalizedResource = new LocalizedResource(null, null, "org.apache.derby.loc.drda.servlet");
        runServer(localLocalizedResource, null, null);
        return;
      }
    }
  }
  
  public void doGet(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
    throws ServletException, IOException
  {
    LocalizedResource localLocalizedResource = getCurrentAppUI(paramHttpServletRequest);
    paramHttpServletResponse.setContentType("text/html; charset=UTF-8");
    paramHttpServletResponse.setHeader("Cache-Control", "no-cache,no-store");
    formHeader = ("<form enctype='multipart/form-data; charset=UTF-8' action='" + paramHttpServletRequest.getRequestURI() + " '>");
    out = new PrintWriter(new OutputStreamWriter(paramHttpServletResponse.getOutputStream(), "UTF8"), true);
    String str1 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_LogOn"));
    String str2 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_LogOff"));
    String str3 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_TraceOn"));
    String str4 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_TraceOff"));
    String str6 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_Start"));
    String str7 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_Stop"));
    String str9 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_TraceSessButton"));
    String str5 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_TraceOnOff"));
    String str8 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_Return"));
    String str10 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_TraceDir"));
    String str11 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_Continue"));
    String str12 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_SetParam"));
    String str13 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_SetParam2"));
    String str14 = escapeSingleQuotes(localLocalizedResource.getTextMessage("SRV_NetParam"));
    printBanner(localLocalizedResource);
    if (server == null) {
      try
      {
        server = new NetworkServerControl();
      }
      catch (Exception localException1)
      {
        printErrorForm(localLocalizedResource, paramHttpServletRequest, localException1, str8);
        return;
      }
    }
    server.setClientLocale(locale);
    Object localObject1 = getForm(paramHttpServletRequest);
    String str15 = getDoAction(paramHttpServletRequest);
    if (str15 != null) {
      if (str15.equals(str5)) {
        localObject1 = str9;
      } else {
        localObject1 = str15;
      }
    }
    boolean bool1 = getServerStatus();
    if (localObject1 == null)
    {
      if (bool1) {
        localObject1 = str6;
      } else {
        localObject1 = str7;
      }
    }
    else if (((String)localObject1).equals(str6))
    {
      if (!bool1) {
        runServer(localLocalizedResource, paramHttpServletRequest, str8);
      }
    }
    else if (((String)localObject1).equals(str7))
    {
      if (bool1) {
        shutdownServer(localLocalizedResource, paramHttpServletRequest, str8);
      }
      setDefaults();
    }
    else if ((((String)localObject1).equals(str8)) || (((String)localObject1).equals(str8)))
    {
      if (bool1) {
        localObject1 = str6;
      } else {
        localObject1 = str7;
      }
    }
    out.println(formHeader);
    localObject1 = escapeSingleQuotes((String)localObject1);
    str15 = escapeSingleQuotes(str15);
    String str16;
    String str17;
    if (((String)localObject1).equals(str6))
    {
      str16 = getLogging(paramHttpServletRequest);
      str17 = getTrace(paramHttpServletRequest);
      if ((str16 != null) && (str16.equals(str1)) && (logging(localLocalizedResource, true, paramHttpServletRequest, str8))) {
        logStatus = true;
      }
      if ((str16 != null) && (str16.equals(str2)) && (logging(localLocalizedResource, false, paramHttpServletRequest, str8))) {
        logStatus = false;
      }
      if ((str17 != null) && (str17.equals(str3)) && (traceAll(localLocalizedResource, true, paramHttpServletRequest, str8))) {
        traceStatus = true;
      }
      if ((str17 != null) && (str17.equals(str4)) && (traceAll(localLocalizedResource, false, paramHttpServletRequest, str8))) {
        traceStatus = false;
      }
      displayCurrentStatus(paramHttpServletRequest, localLocalizedResource, str8);
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_StopButton") + "</h4>");
      out.println("<INPUT type=submit name=form value='" + str7 + "'>");
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_LogButton2") + "</h4>");
      if (logStatus) {
        out.println("<INPUT type=submit name=logform value='" + str2 + "'>");
      } else {
        out.println("<INPUT type=submit name=logform value='" + str1 + "'>");
      }
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_TraceButton2") + "</h4>");
      if (traceStatus) {
        out.println("<INPUT type=submit name=traceform value='" + str4 + "'>");
      } else {
        out.println("<INPUT type=submit name=traceform value='" + str3 + "'>");
      }
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_TraceSession") + "</h4>");
      out.println("<INPUT type=submit name=form value='" + str9 + "'>");
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_TraceDirButton") + "</h4>");
      out.println("<INPUT type=submit name=form value='" + str10 + "'>");
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_ThreadButton") + "</h4>");
      out.println("<INPUT type=submit name=form value='" + str14 + "'>");
    }
    else if (((String)localObject1).equals(str7))
    {
      printAsContentHeader(localLocalizedResource.getTextMessage("SRV_NotStarted"));
      str16 = getLogging(paramHttpServletRequest);
      str17 = getTrace(paramHttpServletRequest);
      if ((str16 != null) && (str16.equals(str1))) {
        logStatus = true;
      }
      if ((str16 != null) && (str16.equals(str2))) {
        logStatus = false;
      }
      if ((str17 != null) && (str17.equals(str3))) {
        traceStatus = true;
      }
      if ((str17 != null) && (str17.equals(str4))) {
        traceStatus = false;
      }
      if (logStatus)
      {
        out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_LogOffButton") + "</h4>");
        out.println("<INPUT type=submit name=logform value='" + str2 + "'>");
      }
      else
      {
        out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_LogOnButton") + "</h4>");
        out.println("<INPUT type=submit name=logform value='" + str1 + "'>");
      }
      if (traceStatus)
      {
        out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_TraceOffButton") + "</h4>");
        out.println("<INPUT type=submit name=traceform value='" + str4 + "'>");
      }
      else
      {
        out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_TraceOnButton") + "</h4>");
        out.println("<INPUT type=submit name=traceform value='" + str3 + "'>");
      }
      out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_StartButton") + "</h4>");
      out.println("<INPUT type=submit name=form value='" + str6 + "'>");
    }
    else
    {
      Object localObject2;
      if (((String)localObject1).equals(str9))
      {
        if ((str15 != null) && (str15.equals(str5)))
        {
          str16 = paramHttpServletRequest.getParameter("sessionid");
          int j = 0;
          try
          {
            j = new Integer(str16).intValue();
          }
          catch (Exception localException2)
          {
            printErrorForm(localLocalizedResource, paramHttpServletRequest, localLocalizedResource.getTextMessage("SRV_InvalidVal", str16, localLocalizedResource.getTextMessage("SRV_SessionID")), str8);
            return;
          }
          localObject2 = null;
          try
          {
            localObject2 = server.getCurrentProperties();
          }
          catch (Exception localException3)
          {
            printErrorForm(localLocalizedResource, paramHttpServletRequest, localException3, str8);
            return;
          }
          boolean bool2;
          if (((Properties)localObject2).getProperty("derby.drda.trace" + str16) != null) {
            bool2 = false;
          } else {
            bool2 = true;
          }
          if (traceSession(localLocalizedResource, bool2, j, paramHttpServletRequest, str8))
          {
            if (bool2) {
              out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_StatusTraceNoOn", str16) + "</h4>");
            } else {
              out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_StatusTraceNoOff", str16) + "</h4>");
            }
          }
          else {
            return;
          }
        }
        printAsContentHeader(localLocalizedResource.getTextMessage("SRV_TraceSessButton"));
        out.println("<h4>" + getHtmlLabelledMessageInstance(localLocalizedResource, "SRV_SessionID", "sessionId") + "</h4>");
        out.println("<INPUT type=text name=sessionid size=10 maxlength=10 id='sessionId' value=''>");
        out.println("<h4> </h4>");
        out.println("<INPUT type=submit name=doaction value='" + str5 + "'>");
        out.println("<INPUT type=submit name=form value='" + str8 + "'>");
      }
      else
      {
        int i;
        if (((String)localObject1).equals(str10))
        {
          i = 0;
          String str18 = null;
          printAsContentHeader(str10);
          if ((str15 != null) && (str15.equals(str10)))
          {
            str18 = getParam(paramHttpServletRequest, "tracedirectory");
            if (traceDirectory(localLocalizedResource, str18, paramHttpServletRequest, str8)) {
              i = 1;
            } else {
              return;
            }
          }
          if (i != 0)
          {
            out.println("<h2>" + localLocalizedResource.getTextMessage("SRV_TraceDirDone", str18) + "</h2>");
            out.println("<INPUT type=submit name=form value='" + str8 + "'>");
          }
          else
          {
            out.println("<h4>" + getHtmlLabelledMessageInstance(localLocalizedResource, "SRV_TraceDir", "tracedir") + "</h4>");
            out.println("<INPUT type=text name=tracedirectory size=60 maxlength=256 id='tracedir' value='" + tracingDirectory + "'>");
            out.println("<h4> </h4>");
            out.println("<INPUT type=submit name=doaction value='" + str10 + "'>");
            out.println("<INPUT type=submit name=form value='" + str8 + "'>");
          }
        }
        else if (((String)localObject1).equals(str14))
        {
          i = 0;
          int k = 0;
          localObject2 = localLocalizedResource.getTextMessage("SRV_NewMaxThreads");
          String str19 = localLocalizedResource.getTextMessage("SRV_NewTimeSlice");
          try
          {
            Properties localProperties = server.getCurrentProperties();
            String str20 = localProperties.getProperty("derby.drda.maxThreads");
            i = new Integer(str20).intValue();
            str20 = localProperties.getProperty("derby.drda.timeSlice");
            k = new Integer(str20).intValue();
          }
          catch (Exception localException4)
          {
            printErrorForm(localLocalizedResource, paramHttpServletRequest, localException4, str8);
            return;
          }
          if ((str15 != null) && (str15.equals(str14)))
          {
            int m = getIntParameter(paramHttpServletRequest, "newmaxthreads", "SRV_NewMaxThreads", localLocalizedResource, str8);
            int n = m == -3 ? -2 : getIntParameter(paramHttpServletRequest, "newtimeslice", "SRV_NewTimeSlice", localLocalizedResource, str8);
            if ((m == -3) || (n == -3)) {
              return;
            }
            if ((m != -2) || (n != -2))
            {
              if (m != -2) {
                i = m;
              }
              if (n != -2) {
                k = n;
              }
              if (!setNetParam(localLocalizedResource, i, k, paramHttpServletRequest, str8)) {
                return;
              }
            }
          }
          out.println(formHeader);
          printAsContentHeader(str14);
          out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_MaxThreads", new Integer(i).toString()) + "</h4>");
          out.println("<h4>" + localLocalizedResource.getTextMessage("SRV_TimeSlice", new Integer(k).toString()) + "</h4>");
          out.println("<h4> </h4>");
          out.println("<h4> <label for='newmaxthreads'>" + (String)localObject2 + "</label> </h4>");
          out.println("<INPUT type=text name=newmaxthreads size=10 maxlength=10 id='newmaxthreads' value=''>");
          out.println("<h4> <label for='newslice'>" + str19 + "</label> </h4>");
          out.println("<INPUT type=text name=newtimeslice size=10 maxlength=10 id='newslice' value=''>");
          out.println("<h4> </h4>");
          out.println("<INPUT type=submit name=doaction value='" + str14 + "'>");
          out.println("<INPUT type=submit name=form value='" + str8 + "'>");
        }
        else
        {
          System.out.println("Internal Error: Unknown form, " + (String)localObject1);
          out.println("Internal Error: Unknown form, " + (String)localObject1);
        }
      }
    }
    out.println("</html>");
    out.println("</body>");
  }
  
  public void doPost(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
    throws ServletException, IOException
  {
    doGet(paramHttpServletRequest, paramHttpServletResponse);
  }
  
  private String getForm(HttpServletRequest paramHttpServletRequest)
    throws IOException
  {
    return getParam(paramHttpServletRequest, "form");
  }
  
  private String getDoAction(HttpServletRequest paramHttpServletRequest)
    throws IOException
  {
    return getParam(paramHttpServletRequest, "doaction");
  }
  
  private String getLogging(HttpServletRequest paramHttpServletRequest)
    throws IOException
  {
    return getParam(paramHttpServletRequest, "logform");
  }
  
  private String getTrace(HttpServletRequest paramHttpServletRequest)
    throws IOException
  {
    return getParam(paramHttpServletRequest, "traceform");
  }
  
  private String getParam(HttpServletRequest paramHttpServletRequest, String paramString)
    throws IOException
  {
    String str1 = null;
    String str2 = paramHttpServletRequest.getParameter(paramString);
    if (str2 == null) {
      return str2;
    }
    str1 = new String(str2.getBytes("ISO-8859-1"), "UTF8");
    return str1;
  }
  
  private void runServer(LocalizedResource paramLocalizedResource, HttpServletRequest paramHttpServletRequest, String paramString)
    throws ServletException
  {
    service = new Runnable()
    {
      public void run()
      {
        try
        {
          NetworkServerControl localNetworkServerControl = new NetworkServerControl(InetAddress.getByName(host), portNumber);
          localNetworkServerControl.start(null);
        }
        catch (Exception localException)
        {
          throw new RuntimeException(localException.getMessage());
        }
      }
    };
    Thread localThread = null;
    try
    {
      localThread = (Thread)AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        public Object run()
          throws Exception
        {
          return new Thread(service);
        }
      });
    }
    catch (Exception localException1)
    {
      throw new RuntimeException(localException1.getMessage());
    }
    localThread.start();
    try
    {
      int i = 0;
      int j = 0;
      do
      {
        j++;
        try
        {
          Thread.sleep(100L);
        }
        catch (InterruptedException localInterruptedException)
        {
          throw new ServletException(paramLocalizedResource.getTextMessage("SRV_Interupt"));
        }
        try
        {
          if (isServerStarted(server, 1)) {
            i = 1;
          }
        }
        catch (Exception localException3) {}
      } while ((i == 0) && (j < 20));
      if (j >= 20) {
        throw new Exception(paramLocalizedResource.getTextMessage("SRV_MaxTrys", new Integer(20).toString()));
      }
      if (logStatus) {
        server.logConnections(true);
      }
      if (traceStatus) {
        server.trace(true);
      }
    }
    catch (Exception localException2)
    {
      if (out != null) {
        printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException2, paramString);
      } else {
        throw new ServletException(localException2.getMessage());
      }
    }
  }
  
  private void printErrorForm(LocalizedResource paramLocalizedResource, HttpServletRequest paramHttpServletRequest, Exception paramException, String paramString)
  {
    printAsContentHeader(paramLocalizedResource.getTextMessage("SRV_NetworkServerError"));
    out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_Message", paramException.getMessage()) + "</h4>");
    out.println("<INPUT type=submit name=form value='" + paramString + "'>");
    out.println("</html>");
    out.println("</body>");
  }
  
  private void printErrorForm(LocalizedResource paramLocalizedResource, HttpServletRequest paramHttpServletRequest, String paramString1, String paramString2)
  {
    printAsContentHeader(paramLocalizedResource.getTextMessage("SRV_NetworkServerError"));
    out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_Message", paramString1) + "</h4>");
    out.println("<INPUT type=submit name=form value='" + paramString2 + "'>");
    out.println("</html>");
    out.println("</body>");
  }
  
  private void displayCurrentStatus(HttpServletRequest paramHttpServletRequest, LocalizedResource paramLocalizedResource, String paramString)
  {
    try
    {
      printAsContentHeader(paramLocalizedResource.getTextMessage("SRV_Started"));
      Properties localProperties = server.getCurrentProperties();
      String str = localProperties.getProperty("derby.drda.logConnections");
      if (str.equals("true")) {
        logStatus = true;
      } else {
        logStatus = false;
      }
      if (logStatus) {
        out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_StatusLogOn") + "</h4>");
      } else {
        out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_StatusLogOff") + "</h4>");
      }
      str = localProperties.getProperty("derby.drda.traceAll");
      if (str.equals("true")) {
        traceStatus = true;
      } else {
        traceStatus = false;
      }
      if (traceStatus) {
        out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_StatusTraceOn") + "</h4>");
      } else {
        out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_StatusTraceOff") + "</h4>");
      }
      str = localProperties.getProperty("derby.drda.portNumber");
      out.println("<h4>" + paramLocalizedResource.getTextMessage("SRV_PortNumber", str) + "</h4>");
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString);
    }
  }
  
  private boolean getServerStatus()
  {
    try
    {
      if (isServerStarted(server, 1)) {
        return true;
      }
    }
    catch (Exception localException) {}
    return false;
  }
  
  private boolean shutdownServer(LocalizedResource paramLocalizedResource, HttpServletRequest paramHttpServletRequest, String paramString)
  {
    boolean bool = false;
    try
    {
      server.shutdown();
      bool = true;
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString);
    }
    return bool;
  }
  
  private boolean logging(LocalizedResource paramLocalizedResource, boolean paramBoolean, HttpServletRequest paramHttpServletRequest, String paramString)
  {
    boolean bool = false;
    try
    {
      server.logConnections(paramBoolean);
      bool = true;
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString);
    }
    return bool;
  }
  
  private boolean traceAll(LocalizedResource paramLocalizedResource, boolean paramBoolean, HttpServletRequest paramHttpServletRequest, String paramString)
  {
    boolean bool = false;
    try
    {
      server.trace(paramBoolean);
      bool = true;
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString);
    }
    return bool;
  }
  
  private boolean traceSession(LocalizedResource paramLocalizedResource, boolean paramBoolean, int paramInt, HttpServletRequest paramHttpServletRequest, String paramString)
  {
    boolean bool = false;
    try
    {
      server.trace(paramInt, paramBoolean);
      bool = true;
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString);
    }
    return bool;
  }
  
  private boolean traceDirectory(LocalizedResource paramLocalizedResource, String paramString1, HttpServletRequest paramHttpServletRequest, String paramString2)
  {
    boolean bool = false;
    if ((paramString1 == null) || (paramString1.equals("")))
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, paramLocalizedResource.getTextMessage("SRV_MissingParam", paramLocalizedResource.getTextMessage("SRV_TraceDir")), paramString2);
      return bool;
    }
    try
    {
      tracingDirectory = paramString1;
      server.setTraceDirectory(paramString1);
      bool = true;
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString2);
    }
    return bool;
  }
  
  private boolean setNetParam(LocalizedResource paramLocalizedResource, int paramInt1, int paramInt2, HttpServletRequest paramHttpServletRequest, String paramString)
  {
    boolean bool = false;
    try
    {
      server.setMaxThreads(paramInt1);
      server.setTimeSlice(paramInt2);
      bool = true;
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, localException, paramString);
    }
    return bool;
  }
  
  private void setDefaults()
  {
    logStatus = false;
    traceStatus = false;
  }
  
  private int getIntParameter(HttpServletRequest paramHttpServletRequest, String paramString1, String paramString2, LocalizedResource paramLocalizedResource, String paramString3)
  {
    String str = paramHttpServletRequest.getParameter(paramString1);
    if ((str == null) || (str.equals(""))) {
      return -2;
    }
    int i;
    try
    {
      i = new Integer(str).intValue();
    }
    catch (Exception localException)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, paramLocalizedResource.getTextMessage("SRV_InvalidVal", str, paramLocalizedResource.getTextMessage(paramString2)), paramString3);
      return -3;
    }
    if (i < 0)
    {
      printErrorForm(paramLocalizedResource, paramHttpServletRequest, paramLocalizedResource.getTextMessage("SRV_InvalidVal", str, paramLocalizedResource.getTextMessage(paramString2)), paramString3);
      return -3;
    }
    return i;
  }
  
  private void printBanner(LocalizedResource paramLocalizedResource)
  {
    out.println("<a href=\"#navskip\">[ " + paramLocalizedResource.getTextMessage("SRV_SkipToContent") + " ]</a>");
    out.println("  -  <a href=\"derbynet\">[ " + paramLocalizedResource.getTextMessage("SRV_BackToMain") + " ]</a>");
    out.println("<html>");
    out.println("<title>" + paramLocalizedResource.getTextMessage("SRV_Banner") + "</title>");
    out.println("<body>");
    out.println("<hr>");
    out.println("<h1>" + paramLocalizedResource.getTextMessage("SRV_Banner") + "</h1>");
    out.println("<hr>");
  }
  
  private LocalizedResource getCurrentAppUI(HttpServletRequest paramHttpServletRequest)
  {
    String str1 = paramHttpServletRequest.getHeader("Accept-Language");
    LocalizedResource localLocalizedResource = new LocalizedResource(null, null, "org.apache.derby.loc.drda.servlet");
    locale = null;
    if (str1 == null) {
      return localLocalizedResource;
    }
    StringTokenizer localStringTokenizer = new StringTokenizer(str1, ",");
    while (localStringTokenizer.hasMoreTokens())
    {
      String str2 = localStringTokenizer.nextToken();
      str2 = getLocStringFromLanguage(str2);
      int i = translationAvailable(str2);
      if (i != -1)
      {
        localLocalizedResource.init(null, str2, "org.apache.derby.loc.drda.servlet");
        locale = str2;
        return localLocalizedResource;
      }
    }
    return localLocalizedResource;
  }
  
  private String getLocStringFromLanguage(String paramString)
  {
    int i;
    if ((i = paramString.indexOf(';')) != -1) {
      paramString = paramString.substring(0, i);
    }
    paramString = fixLanguageCode(paramString.trim());
    return paramString;
  }
  
  private int translationAvailable(String paramString)
  {
    for (int i = 0; i < knownLang.length; i++) {
      if (knownLang[i].equals(paramString)) {
        return i;
      }
    }
    return -1;
  }
  
  private String fixLanguageCode(String paramString)
  {
    int i = paramString.indexOf('-');
    if (i != -1) {
      return fixLanguageCode(paramString, i);
    }
    i = paramString.indexOf('_');
    if (i != -1) {
      return fixLanguageCode(paramString, i);
    }
    return paramString;
  }
  
  private String fixLanguageCode(String paramString, int paramInt)
  {
    return paramString.substring(0, paramInt) + "_" + paramString.substring(paramInt + 1).toUpperCase(Locale.ENGLISH);
  }
  
  public String getHtmlLabelledMessageInstance(LocalizedResource paramLocalizedResource, String paramString1, String paramString2)
  {
    if (paramString2 == null) {
      paramString2 = "";
    }
    return "<label for='" + paramString2 + "'>" + paramLocalizedResource.getTextMessage(paramString1) + "</label>";
  }
  
  private void printAsContentHeader(String paramString)
  {
    out.println("<a name=\"navskip\"></a><h2>" + paramString + "</h2>");
  }
  
  private String escapeSingleQuotes(String paramString)
  {
    if ((paramString == null) || (paramString.indexOf("'") < 0)) {
      return paramString;
    }
    char[] arrayOfChar1 = paramString.toCharArray();
    char[] arrayOfChar2 = new char[4 * arrayOfChar1.length];
    int i = 0;
    for (int j = 0; j < arrayOfChar1.length; j++) {
      if (arrayOfChar1[j] == '\'')
      {
        arrayOfChar2[(i++)] = '&';
        arrayOfChar2[(i++)] = '#';
        arrayOfChar2[(i++)] = '3';
        arrayOfChar2[(i++)] = '9';
      }
      else
      {
        arrayOfChar2[(i++)] = arrayOfChar1[j];
      }
    }
    return new String(arrayOfChar2, 0, i);
  }
  
  private static boolean isServerStarted(NetworkServerControl paramNetworkServerControl, int paramInt)
  {
    int i = 1;
    while (i <= paramInt) {
      try
      {
        Thread.sleep(500L);
        paramNetworkServerControl.ping();
        return true;
      }
      catch (Exception localException)
      {
        if (i == paramInt) {
          return false;
        }
        i++;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.derby.drda.NetServlet
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.derby.drda;

import java.io.PrintWriter;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.Properties;
import org.apache.derby.iapi.services.property.PropertyUtil;
import org.apache.derby.impl.drda.NetworkServerControlImpl;

public class NetworkServerControl
{
  public static final int DEFAULT_PORTNUMBER = 1527;
  private static final String DERBYNET_JAR = "derbynet.jar";
  private static final String POLICY_FILENAME = "server.policy";
  private static final String POLICY_FILE_PROPERTY = "java.security.policy";
  private static final String DERBY_HOSTNAME_WILDCARD = "0.0.0.0";
  private static final String IPV6_HOSTNAME_WILDCARD = "::";
  private static final String SOCKET_PERMISSION_HOSTNAME_WILDCARD = "*";
  private NetworkServerControlImpl serverImpl;
  
  public NetworkServerControl(InetAddress paramInetAddress, int paramInt, String paramString1, String paramString2)
    throws Exception
  {
    serverImpl = new NetworkServerControlImpl(paramInetAddress, paramInt, paramString1, paramString2);
  }
  
  public NetworkServerControl(String paramString1, String paramString2)
    throws Exception
  {
    serverImpl = new NetworkServerControlImpl(paramString1, paramString2);
  }
  
  public NetworkServerControl(InetAddress paramInetAddress, int paramInt)
    throws Exception
  {
    serverImpl = new NetworkServerControlImpl(paramInetAddress, paramInt);
  }
  
  public NetworkServerControl()
    throws Exception
  {
    serverImpl = new NetworkServerControlImpl();
  }
  
  public static void main(String[] paramArrayOfString)
  {
    NetworkServerControlImpl localNetworkServerControlImpl = null;
    int i = 1;
    try
    {
      localNetworkServerControlImpl = new NetworkServerControlImpl();
      int j = localNetworkServerControlImpl.parseArgs(paramArrayOfString);
      if (needsSecurityManager(localNetworkServerControlImpl, j))
      {
        verifySecurityState(localNetworkServerControlImpl);
        installSecurityManager(localNetworkServerControlImpl);
      }
      i = 0;
      localNetworkServerControlImpl.executeWork(j);
    }
    catch (Exception localException)
    {
      if ((localException.getMessage() == null) || (!localException.getMessage().equals("Unexpected exception")) || (i != 0)) {
        if (localNetworkServerControlImpl != null) {
          localNetworkServerControlImpl.consoleExceptionPrint(localException);
        } else {
          localException.printStackTrace();
        }
      }
      System.exit(1);
    }
    System.exit(0);
  }
  
  public void start(PrintWriter paramPrintWriter)
    throws Exception
  {
    serverImpl.start(paramPrintWriter);
  }
  
  public void shutdown()
    throws Exception
  {
    serverImpl.shutdown();
  }
  
  public void ping()
    throws Exception
  {
    serverImpl.ping();
  }
  
  public void trace(boolean paramBoolean)
    throws Exception
  {
    serverImpl.trace(paramBoolean);
  }
  
  public void trace(int paramInt, boolean paramBoolean)
    throws Exception
  {
    serverImpl.trace(paramInt, paramBoolean);
  }
  
  public void logConnections(boolean paramBoolean)
    throws Exception
  {
    serverImpl.logConnections(paramBoolean);
  }
  
  public void setTraceDirectory(String paramString)
    throws Exception
  {
    serverImpl.sendSetTraceDirectory(paramString);
  }
  
  public String getSysinfo()
    throws Exception
  {
    return serverImpl.sysinfo();
  }
  
  public String getRuntimeInfo()
    throws Exception
  {
    return serverImpl.runtimeInfo();
  }
  
  public void setMaxThreads(int paramInt)
    throws Exception
  {
    serverImpl.netSetMaxThreads(paramInt);
  }
  
  public int getMaxThreads()
    throws Exception
  {
    String str = serverImpl.getCurrentProperties().getProperty("derby.drda.maxThreads");
    return Integer.parseInt(str);
  }
  
  public void setTimeSlice(int paramInt)
    throws Exception
  {
    serverImpl.netSetTimeSlice(paramInt);
  }
  
  public int getTimeSlice()
    throws Exception
  {
    String str = serverImpl.getCurrentProperties().getProperty("derby.drda.timeSlice");
    return Integer.parseInt(str);
  }
  
  public Properties getCurrentProperties()
    throws Exception
  {
    return serverImpl.getCurrentProperties();
  }
  
  protected void setClientLocale(String paramString)
  {
    serverImpl.clientLocale = paramString;
  }
  
  private static boolean needsSecurityManager(NetworkServerControlImpl paramNetworkServerControlImpl, int paramInt)
    throws Exception
  {
    return (System.getSecurityManager() == null) && (paramInt == 0) && (!paramNetworkServerControlImpl.runningUnsecure());
  }
  
  private static void verifySecurityState(NetworkServerControlImpl paramNetworkServerControlImpl)
    throws Exception
  {}
  
  private static void installSecurityManager(NetworkServerControlImpl paramNetworkServerControlImpl)
    throws Exception
  {
    if (PropertyUtil.getSystemProperty("derby.system.home") == null) {
      System.setProperty("derby.system.home", PropertyUtil.getSystemProperty("user.dir"));
    }
    if (PropertyUtil.getSystemProperty("derby.drda.traceDirectory") == null) {
      System.setProperty("derby.drda.traceDirectory", PropertyUtil.getSystemProperty("derby.system.home"));
    }
    System.setProperty("derby.security.host", getHostNameForSocketPermission(paramNetworkServerControlImpl));
    String str1 = getCodeSourcePrefix(paramNetworkServerControlImpl);
    System.setProperty("derby.install.url", str1);
    String str2 = getPolicyFileURL();
    System.setProperty("java.security.policy", str2);
    SecurityManager localSecurityManager = new SecurityManager();
    System.setSecurityManager(localSecurityManager);
    String str3 = paramNetworkServerControlImpl.localizeMessage("DRDA_SecurityInstalled.I", null);
    paramNetworkServerControlImpl.consoleMessage(str3, true);
  }
  
  private static String getHostNameForSocketPermission(NetworkServerControlImpl paramNetworkServerControlImpl)
    throws Exception
  {
    String str = paramNetworkServerControlImpl.getHost();
    if ((hostnamesEqual("0.0.0.0", str)) || ("::".equals(str))) {
      str = "*";
    } else if (isIPV6Address(str)) {
      str = '[' + str + "]:0-";
    }
    return str;
  }
  
  private static boolean hostnamesEqual(String paramString1, String paramString2)
  {
    try
    {
      InetAddress localInetAddress1 = InetAddress.getByName(paramString1);
      InetAddress localInetAddress2 = InetAddress.getByName(paramString2);
      return localInetAddress1.equals(localInetAddress2);
    }
    catch (Exception localException) {}
    return false;
  }
  
  private static boolean isIPV6Address(String paramString)
  {
    if (paramString == null) {
      return false;
    }
    int i = paramString.length();
    for (int j = 0; j < i; j++)
    {
      char c = paramString.charAt(j);
      if ((c != ':') && (Character.digit(c, 16) < 0)) {
        return false;
      }
    }
    try
    {
      InetAddress localInetAddress = InetAddress.getByName(paramString);
      return localInetAddress instanceof Inet6Address;
    }
    catch (Exception localException) {}
    return false;
  }
  
  private static String getCodeSourcePrefix(NetworkServerControlImpl paramNetworkServerControlImpl)
    throws Exception
  {
    String str1 = NetworkServerControl.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm();
    int i = str1.indexOf("derbynet.jar");
    if (i < 0)
    {
      str2 = paramNetworkServerControlImpl.localizeMessage("DRDA_MissingNetworkJar.S", null);
      paramNetworkServerControlImpl.consoleError(str2);
    }
    String str2 = str1.substring(0, i);
    return str2;
  }
  
  private static String getPolicyFileURL()
    throws Exception
  {
    String str1 = NetworkServerControl.class.getPackage().getName().replace('.', '/') + '/' + "server.policy";
    URL localURL = NetworkServerControl.class.getClassLoader().getResource(str1);
    String str2 = localURL.toExternalForm();
    return str2;
  }
}

/* Location:
 * Qualified Name:     org.apache.derby.drda.NetworkServerControl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.derby.impl.drda;

class AppRequester
{
  protected static final int MGR_LEVEL_UNKNOWN = -1;
  protected static final int UNKNOWN_CLIENT = 0;
  protected static final int JCC_CLIENT = 1;
  protect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd