Package org.mortbay.jetty.security

Examples of org.mortbay.jetty.security.SslSocketConnector


    protected void newServer()
    {
        _server = new Server();
        //SslSelectChannelConnector connector = new SslSelectChannelConnector();
        SslSocketConnector connector = new SslSocketConnector();

        String keystore = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator
                + "keystore";

        connector.setPort(0);
        connector.setKeystore(keystore);
        connector.setPassword("storepwd");
        connector.setKeyPassword("keypwd");

        _server.setConnectors(new Connector[]
        { connector });
        _connector=connector;
    }
View Full Code Here


    protected void startServer() throws Exception
    {
        _server = new Server();
        //SslSelectChannelConnector connector = new SslSelectChannelConnector();
        SslSocketConnector connector = new SslSocketConnector();

        String keystore = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator
                + "keystore";

        connector.setPort(0);
        connector.setKeystore(keystore);
        connector.setPassword("storepwd");
        connector.setKeyPassword("keypwd");

        _server.setConnectors(new Connector[]
        { connector });

        UserRealm userRealm = new HashUserRealm("MyRealm","src/test/resources/realm.properties");

        Constraint constraint = new Constraint();
        constraint.setName("Need User or Admin");
        constraint.setRoles(new String[]
        { "user", "admin" });
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/*");

        SecurityHandler sh = new SecurityHandler();
        _server.setHandler(sh);
        sh.setUserRealm(userRealm);
        sh.setConstraintMappings(new ConstraintMapping[]
        { cm });
        sh.setAuthenticator(new BasicAuthenticator());

        Handler testHandler = new AbstractHandler()
        {

            public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
            {
                System.err.println("passed authentication!\n"+((Request)request).getConnection().getRequestFields());
               
                Request base_request = (request instanceof Request)?(Request)request:HttpConnection.getCurrentConnection().getRequest();
                base_request.setHandled(true);
                response.setStatus(200);
                response.setContentType("text/plain");
                if (request.getServerName().equals("jetty.mortbay.org"))
                {
                    response.getOutputStream().println("Proxy request: " + request.getRequestURL());
                }
                else if (request.getMethod().equalsIgnoreCase("GET"))
                {
                    response.getOutputStream().println("<hello>");
                    for (int i = 0; i < 100; i++)
                    {
                        response.getOutputStream().println("  <world>" + i + "</world>");
                        if (i % 20 == 0)
                            response.getOutputStream().flush();
                    }
                    response.getOutputStream().println("</hello>");
                }
                else
                {
                    copyStream(request.getInputStream(),response.getOutputStream());
                }
            }
        };

        sh.setHandler(testHandler);

        _server.start();
        _port = connector.getLocalPort();
    }
View Full Code Here

        ssl_connector.setKeyPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
        ssl_connector.setTruststore(jetty_home+"/etc/keystore");
        ssl_connector.setTrustPassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
        server.addConnector(ssl_connector)
       
        SslSocketConnector ssl_b_connector=new SslSocketConnector();
        ssl_b_connector.setPort(8444);
        ssl_b_connector.setKeystore(jetty_home+"/etc/keystore");
        ssl_b_connector.setPassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
        ssl_b_connector.setKeyPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
        ssl_b_connector.setTruststore(jetty_home+"/etc/keystore");
        ssl_b_connector.setTrustPassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
        server.addConnector(ssl_b_connector)
       
        HandlerCollection handlers = new HandlerCollection();
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        RequestLogHandler requestLogHandler = new RequestLogHandler();
View Full Code Here

        || EMPTY.equals(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE))
        || EMPTY.equals(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS))) {
      sock = new SocketConnector();
      usingSsl = false;
    } else {
      sock = new SslSocketConnector();
      ((SslSocketConnector) sock).setKeystore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE));
      ((SslSocketConnector) sock).setKeyPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS));
      ((SslSocketConnector) sock).setTruststore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE));
      ((SslSocketConnector) sock).setTrustPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS));
      usingSsl = true;
View Full Code Here

    protected void addConnectors( Server server )
    {
        System.setProperty( "javax.net.ssl.trustStore",
                            getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );

        SslSocketConnector connector = new SslSocketConnector();
        connector.setPort( server.getConnectors()[0].getPort() );
        connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
        connector.setPassword( "wagonhttp" );
        connector.setKeyPassword( "wagonhttp" );
        connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
        connector.setTrustPassword( "wagonhttp" );
        server.setConnectors( new Connector[] { connector } );
    }
View Full Code Here

  public void addSslListener(InetSocketAddress addr, String keystore,
      String storPass, String keyPass) throws IOException {
    if (webServer.isStarted()) {
      throw new IOException("Failed to add ssl listener");
    }
    SslSocketConnector sslListener = new SslSocketConnector();
    sslListener.setHost(addr.getHostName());
    sslListener.setPort(addr.getPort());
    sslListener.setKeystore(keystore);
    sslListener.setPassword(storPass);
    sslListener.setKeyPassword(keyPass);
    webServer.addConnector(sslListener);
  }
View Full Code Here

      System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
          "ssl.server.truststore.password", ""));
      System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
          "ssl.server.truststore.type", "jks"));
    }
    SslSocketConnector sslListener = new SslSocketConnector();
    sslListener.setHost(addr.getHostName());
    sslListener.setPort(addr.getPort());
    sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
    sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
    sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword", ""));
    sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
    sslListener.setNeedClientAuth(needClientAuth);
    webServer.addConnector(sslListener);
  }
View Full Code Here

        super(port, path);
    }

    protected Connector getConnector(int port) {
        Properties properties = StartupProperties.get();
        SslSocketConnector connector = new SslSocketConnector();
        connector.setPort(port);
        connector.setHost("0.0.0.0");
        connector.setKeystore(properties.getProperty("keystore.file",
                System.getProperty("keystore.file", "conf/prism.keystore")));
        connector.setKeyPassword(properties.getProperty("keystore.password",
                System.getProperty("keystore.password", "falcon-prism-passwd")));
        connector.setTruststore(properties.getProperty("truststore.file",
                System.getProperty("truststore.file", "conf/prism.keystore")));
        connector.setTrustPassword(properties.getProperty("truststore.password",
                System.getProperty("truststore.password", "falcon-prism-passwd")));
        connector.setPassword(properties.getProperty("password",
                System.getProperty("password", "falcon-prism-passwd")));
        connector.setWantClientAuth(true);
        return connector;
    }
View Full Code Here

        Connector listener = null;
        String scheme = ep.getScheme();
        if ("http".equals(scheme)) {
          listener = HttpServer2.createDefaultChannelConnector();
        } else if ("https".equals(scheme)) {
          SslSocketConnector c = new SslSocketConnector();
          c.setNeedClientAuth(needsClientAuth);
          c.setKeyPassword(keyPassword);

          if (keyStore != null) {
            c.setKeystore(keyStore);
            c.setKeystoreType(keyStoreType);
            c.setPassword(keyStorePassword);
          }

          if (trustStore != null) {
            c.setTruststore(trustStore);
            c.setTruststoreType(trustStoreType);
            c.setTrustPassword(trustStorePassword);
          }
          listener = c;

        } else {
          throw new HadoopIllegalArgumentException(
View Full Code Here

        try {
          sslFactory.init();
        } catch (GeneralSecurityException ex) {
          throw new IOException(ex);
        }
        SslSocketConnector sslListener = new SslSocketConnector() {
          @Override
          protected SSLServerSocketFactory createFactory() throws Exception {
            return sslFactory.createSSLServerSocketFactory();
          }
        };
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.security.SslSocketConnector

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.