Package com.caucho.server.cluster

Examples of com.caucho.server.cluster.Server


       }
      */

      out.println("</pre></code>");

      Server server = Server.getCurrent();
      String version = null;

      if (server == null) {
      }
      else if (server.getServerHeader() != null) {
        version = server.getServerHeader();
      }
      else if (CauchoSystem.isTesting()) {
      }
      else
        version = VersionFactory.getFullVersion();

      if (version != null) {
        out.println("<p /><hr />");
        out.println("<small>");

        out.println(version);

        if (server != null)
          out.println("Server: '" + server.getServerId() + "'");

        out.println("</small>");
      }

      out.println("</body></html>");
View Full Code Here


  public boolean handleRequest()
    throws IOException
  {
    boolean isInvocation = false;

    Server server = getServer();
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    long startTime = 0;

    try {
      thread.setContextClassLoader(server.getClassLoader());

      startRequest(HttpBufferStore.allocate(server));

      if (! parseRequest()) {
         return false;
View Full Code Here

  }
 
  void authenticate(String uid, Object credentials, String ipAddress)
  {
    credentials = decryptCredentials(credentials);
    Server server = Server.getCurrent();
    Authenticator auth = getAuth();

    if (credentials instanceof SelfEncryptedCookie) {
      SelfEncryptedCookie cookie = (SelfEncryptedCookie) credentials;

      // XXX: cred timeout
      String adminCookie = server.getAdminCookie();
      if (adminCookie == null)
        adminCookie = "";
     
      if (! cookie.getCookie().equals(adminCookie)) {
        throw new NotAuthorizedException(L.l("'{0}' has invalid credentials",
                                             uid));
      }
    }
    else if (auth == null && ! _isAuthenticationRequired) {
    }
    else if (auth == null) {
      throw new NotAuthorizedException(L.l("{0} does not have a configured authenticator",
                                             this));
    }
    else if (credentials instanceof String) {
      String password = (String) credentials;
   
      Principal user = new BasicPrincipal(uid);
      PasswordCredentials pwdCred = new PasswordCredentials(password);
   
      if (auth.authenticate(user, pwdCred, null) == null) {
        throw new NotAuthorizedException(L.l("'{0}' has invalid credentials",
                                             uid));
      }
    }
    else if (server.getAdminCookie() == null && credentials == null) {
      if (! "127.0.0.1".equals(ipAddress)) {
        throw new NotAuthorizedException(L.l("'{0}' is an invalid local address for '{1}', because no password credentials are available",
                                             ipAddress, uid));
      }
    }
View Full Code Here

      SelfEncryptedCredentials encCred
      = (SelfEncryptedCredentials) credentials;

      byte []encData = encCred.getEncData();

      Server server = Server.getCurrent();

      String adminCookie = server.getAdminCookie();
     
      if (adminCookie == null)
        adminCookie = "";

      return SelfEncryptedCookie.decrypt(adminCookie, encData);
View Full Code Here

    throws IOException
  {
    _hasRequest = false;

    SocketLink conn = getConnection();
    Server server = getServer();

    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();

    try {
      thread.setContextClassLoader(server.getClassLoader());

      HttpBufferStore httpBuffer = HttpBufferStore.allocate((Server) server);

      startRequest(httpBuffer);
      startInvocation();

      ReadStream is = getRawRead();
      WriteStream os = getRawWrite();

      _filter.init(is, os);
      _writeStream.init(_filter);
      // _writeStream.setWritePrefix(3);

      try {
        _hasRequest = false;

        while (readPacket(is)) {
        }

        if (! _hasRequest) {
          if (log.isLoggable(Level.FINE))
            log.fine(dbgId() + "read timeout");

          return false;
        }

        startInvocation();

        _isSecure = conn.isSecure() || conn.getLocalPort() == 443;

        /*
        if (_protocol.length() == 0)
          _protocol.append("HTTP/0.9");

        if (log.isLoggable(Level.FINE)) {
          log.fine(dbgId() + _method + " " +
                   new String(_uri, 0, _uriLength) + " " + _protocol);
          log.fine(dbgId() + "Remote-IP: " + _conn.getRemoteHost() + ":" + _conn.getRemotePort());
        }

        parseHeaders(_rawRead);

        if (getVersion() >= HTTP_1_1 && isForce10()) {
          _protocol.clear();
          _protocol.append("HTTP/1.0");
          _version = HTTP_1_0;
        }
        */
      } catch (ClientDisconnectException e) {
        throw e;
      } catch (Throwable e) {
        log.log(Level.FINER, e.toString(), e);

        throw new BadRequestException(String.valueOf(e), e);
      }

      CharSequence host = getHost();

      String ipHost = conn.getVirtualHost();
      if (ipHost != null)
        host = ipHost;

      _invocationKey.init(_isSecure,
                          host, conn.getLocalPort(),
                          _uri, _uriLength);

      Invocation invocation = getInvocation(host);

      if (invocation == null)
        return false;

      getRequestFacade().setInvocation(invocation);

      startInvocation();

      invocation.service(getRequestFacade(), getResponseFacade());
    } catch (ClientDisconnectException e) {
      // XXX: _response.killCache();

      throw e;
    } catch (Throwable e) {
      log.log(Level.FINE, e.toString(), e);

      // XXX: _response.killCache();
      killKeepalive();

      /*
      try {
        getErrorManager().sendServletError(e, this, _response);
      } catch (ClientDisconnectException e1) {
        throw e1;
      } catch (Throwable e1) {
        log.log(Level.FINE, e1.toString(), e1);
      }
      */

      WebApp webApp = server.getDefaultWebApp();
      if (webApp != null)
        webApp.accessLog(getRequestFacade(), getResponseFacade());

      return false;
    } finally {
View Full Code Here

  }

  private Invocation getInvocation(CharSequence host)
    throws Throwable
  {
    Server server = getServer();
    Invocation invocation = server.getInvocation(_invocationKey);

    if (invocation == null) {
      invocation = server.createInvocation();
      invocation.setSecure(_isSecure);

      if (host != null) {
        String hostName = host.toString().toLowerCase();

        invocation.setHost(hostName);
        invocation.setPort(getConnection().getLocalPort());

        // Default host name if the host doesn't have a canonical
        // name
        int p = hostName.indexOf(':');
        if (p > 0)
          invocation.setHostName(hostName.substring(0, p));
        else
          invocation.setHostName(hostName);
      }

      InvocationDecoder decoder = server.getInvocationDecoder();

      decoder.splitQueryAndUnescape(invocation, _uri, _uriLength);

      /* XXX: common to AbstractHttpRequest
      if (_server.isModified()) {
        _server.logModified(log);

        _invocation = invocation;
        if (_server instanceof Server)
          _invocation.setWebApp(((Server) _server).getDefaultWebApp());

        restartServer();

        return null;
      }
      */

      invocation = server.buildInvocation(_invocationKey.clone(),
                                           invocation);
    }

    invocation = invocation.getRequestInvocation(getRequestFacade());

View Full Code Here

      setExtension(".war");
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);
    }

    Server server = Server.getCurrent();

    if (server != null) {
      setRepository(server.getRepository());

      String hostName = webAppContainer.getHostName();
      if ("".equals(hostName))
        hostName = "default";

      String stage = "default";

      if (server != null)
        stage = server.getStage();

      setRepositoryTag("wars/" + stage + "/" + hostName);

      setEntryNamePrefix("/");
    }
View Full Code Here

      getClientCertificate();

    _hasRequest = true;
    // setStartDate();

    Server server = getServer();

    if (server == null || server.isDestroyed()) {
      log.fine(dbgId() + "server is closed");

      ReadStream is = getRawRead();

      try {
View Full Code Here

    while (true) {
      _rawWrite.flush();

      code = is.read();

      Server server = getServer();
      if (server == null || server.isDestroyed()) {
        log.fine(dbgId() + " request after server close");
        killKeepalive();
        return false;
      }
View Full Code Here

  /**
   * Returns the default error manager
   */
  protected ErrorPageManager getErrorManager()
  {
    Server server = (Server) _server;

    WebApp webApp = server.getWebApp("error.resin", 80, "/");

    if (webApp != null)
      return webApp.getErrorPageManager();
    else
      return _errorManager;
View Full Code Here

TOP

Related Classes of com.caucho.server.cluster.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.