All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.qos.logback.classic.net.SimpleSSLSocketServer Maven / Gradle / Ivy

Go to download

Statistical sampling library for use in virtualdataset libraries, based on apache commons math 4

There is a newer version: 2.12.15
Show newest version
/**
 * Logback: the reliable, generic, fast and flexible logging framework.
 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
 *
 * This program and the accompanying materials are dual-licensed under
 * either the terms of the Eclipse Public License v1.0 as published by
 * the Eclipse Foundation
 *
 *   or (per the licensee's choosing)
 *
 * under the terms of the GNU Lesser General Public License version 2.1
 * as published by the Free Software Foundation.
 */
package ch.qos.logback.classic.net;

import java.security.NoSuchAlgorithmException;

import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLContext;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory;
import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;

/**
 * A {@link SimpleSocketServer} that supports SSL.
 * 
 * 
 *      <b>Usage:</b> java ch.qos.logback.classic.net.ssl.SimpleSSLSocketServer port configFile
 * 
* * where port is a port number where the server listens and * configFile is an xml configuration file fed to * {@link JoranConfigurator}. * * When running the SimpleSSLServerFactory as shown above, it is necessary to * configure JSSE system properties using {@code -Dname=value} on the * command-line when starting the server. In particular, you will probably * want/need to configure the following system properties: *
    *
  • javax.net.ssl.keyStore
  • *
  • javax.net.ssl.keyStorePassword
  • *
  • javax.net.ssl.keyStoreType
  • *
  • javax.net.ssl.trustStore
  • *
  • javax.net.ssl.trustStorePassword
  • *
  • javax.net.ssl.trustStoreType
  • *
*

* See the * Customizing the JSSE in the JSSE Reference Guide for details on how to * set these system properties. * * @author Carl Harris */ public class SimpleSSLSocketServer extends SimpleSocketServer { private final ServerSocketFactory socketFactory; public static void main(String argv[]) throws Exception { doMain(SimpleSSLSocketServer.class, argv); } /** * Creates a new server using the default SSL context. * @param lc logger context for received events * @param port port on which the server is to listen * @throws NoSuchAlgorithmException if the default SSL context cannot be * created */ public SimpleSSLSocketServer(LoggerContext lc, int port) throws NoSuchAlgorithmException { this(lc, port, SSLContext.getDefault()); } /** * Creates a new server using a custom SSL context. * @param lc logger context for received events * @param port port on which the server is to listen * @param sslContext custom SSL context */ public SimpleSSLSocketServer(LoggerContext lc, int port, SSLContext sslContext) { super(lc, port); if (sslContext == null) { throw new NullPointerException("SSL context required"); } SSLParametersConfiguration parameters = new SSLParametersConfiguration(); parameters.setContext(lc); this.socketFactory = new ConfigurableSSLServerSocketFactory(parameters, sslContext.getServerSocketFactory()); } @Override protected ServerSocketFactory getServerSocketFactory() { return socketFactory; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy