Advertisement
blucas

Dummy Server

Jun 5th, 2012
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.16 KB | None | 0 0
  1. #!/bin/sh
  2. nohup java -server -Xms1024m -Xmx1024m -XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:CompileThreshold=100 -cp netty-3.5.0.Final-SNAPSHOT.jar:. Main "$@" &
  3.  
  4. public class Main
  5. {
  6.    private static final Executor SERVER_EXECUTOR;
  7.  
  8.    public static final HttpResponse RESPONSE;
  9.  
  10.    public static final ChannelGroup CHANNEL_GROUP;
  11.  
  12.    public static SSLContext SSL_CONTEXT;
  13.  
  14.    public static Collection<String> ALLOWED_CIPHERS;
  15.  
  16.    static
  17.    {
  18.       SERVER_EXECUTOR = Executors.newCachedThreadPool();
  19.       CHANNEL_GROUP = new DefaultChannelGroup();
  20.  
  21.       RESPONSE = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
  22.  
  23.       StringBuilder content =
  24.          new StringBuilder(
  25.             "<html>\n<head>\n</head>\n<body bgcolor=\"white\" text=\"black\">\n<center>Welcome!</center>\n</body>\n</html>");
  26.       RESPONSE.setContent(ChannelBuffers.copiedBuffer(content.toString(), CharsetUtil.UTF_8));
  27.       RESPONSE.setHeader(HttpHeaders.Names.CONTENT_LENGTH, RESPONSE.getContent().readableBytes());
  28.  
  29.       String ciphers = "SSL_RSA_WITH_RC4_128_SHA,TLS_ECDH_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_RC4_128_MD5,SSL_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_DSS_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA";
  30.       ALLOWED_CIPHERS = new ArrayList<String>();
  31.       Collections.addAll(ALLOWED_CIPHERS, ciphers.split(","));
  32.  
  33.       SSL_CONTEXT = SslContextFactory.getServerContext();
  34.    }
  35.  
  36.    public static void main(String[] args)
  37.    {
  38.       // Validate command line options.
  39.       if (args.length != 4)
  40.       {
  41.          System.err.println("Usage: Main <host> <port> <sslEnabled> <useAllowedCiphersOnly>");
  42.          return;
  43.       }
  44.  
  45.       String host = args[0];
  46.       int port = Integer.parseInt(args[1]);
  47.       boolean sslEnabled = Boolean.parseBoolean(args[2]);
  48.       boolean allowedCiphers = Boolean.parseBoolean(args[3]);
  49.  
  50.       System.out.println(
  51.          "Server running on " + host + ":" + port + ".  SSL Enabled: " + sslEnabled + " Use Allowed Ciphers Only: " +
  52.          allowedCiphers + " ...");
  53.  
  54.       final ServerBootstrap sb = new ServerBootstrap(new NioServerSocketChannelFactory(SERVER_EXECUTOR,
  55.                                                                                        SERVER_EXECUTOR));
  56.       sb.setOption("keepAlive", true);
  57.       sb.setOption("reuseAddress", true);
  58.       sb.setOption("backlog", 8195);
  59.  
  60.       // Set up the event pipeline factory.
  61.       ChannelPipelineFactory cf = new HttpServerPipelineFactory(sslEnabled, allowedCiphers);
  62.       sb.setPipelineFactory(cf);
  63.  
  64.       // Start up the server.
  65.       final Channel channel = sb.bind(new InetSocketAddress(host, port));
  66.       CHANNEL_GROUP.add(channel);
  67.  
  68.       Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
  69.       {
  70.          @Override
  71.          public void run()
  72.          {
  73.             CHANNEL_GROUP.close();
  74.             sb.releaseExternalResources();
  75.          }
  76.       }));
  77.    }
  78. }
  79.  
  80. public class HttpServerPipelineFactory implements ChannelPipelineFactory
  81. {
  82.    private boolean sslContextEnabled;
  83.  
  84.    private boolean allowedCiphers;
  85.  
  86.    public HttpServerPipelineFactory(boolean sslContextEnabled, boolean allowedCiphers)
  87.    {
  88.       this.sslContextEnabled = sslContextEnabled;
  89.       this.allowedCiphers = allowedCiphers;
  90.    }
  91.  
  92.    @Override
  93.    public ChannelPipeline getPipeline() throws Exception
  94.    {
  95.       List<ChannelHandler> handlers = new ArrayList<ChannelHandler>(6);
  96.  
  97.       if (sslContextEnabled)
  98.       {
  99.          // SSL Engine creation
  100.          SSLEngine engine = Main.SSL_CONTEXT.createSSLEngine();
  101.  
  102.          // SSL Engine options
  103.          engine.setUseClientMode(false);
  104.          engine.setNeedClientAuth(false);
  105.  
  106.          if (allowedCiphers)
  107.          {
  108.             engine.setEnabledCipherSuites(Main.ALLOWED_CIPHERS.toArray(new String[Main.ALLOWED_CIPHERS.size()]));
  109.          }
  110.  
  111.          SslHandler sslHandler = new SslHandler(engine);
  112.  
  113.          // The SSL Handler must be the first handler in the pipeline
  114.          handlers.add(sslHandler);
  115.       }
  116.  
  117.       handlers.add(new HttpRequestDecoder());
  118.       handlers.add(new HttpChunkAggregator(1048576));
  119.       handlers.add(new HttpResponseEncoder());
  120.  
  121.       handlers.add(new HttpRequestHandler());
  122.  
  123.       return new StaticChannelPipeline(handlers.toArray(new ChannelHandler[handlers.size()]));
  124.    }
  125. }
  126.  
  127. public final class SslContextFactory
  128. {
  129.    private static final String PROTOCOL = "TLS";
  130.  
  131.    private static final SSLContext SERVER_CONTEXT;
  132.  
  133.    static
  134.    {
  135.       String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm");
  136.       if (algorithm == null)
  137.       {
  138.          algorithm = "SunX509";
  139.       }
  140.  
  141.       SSLContext serverContext;
  142.       try
  143.       {
  144.          KeyStore ks = KeyStore.getInstance("JKS");
  145.          ks.load(SslKeyStore.asInputStream(), SslKeyStore.getKeyStorePassword());
  146.  
  147.          // Set up key manager factory to use our key store
  148.          KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
  149.          kmf.init(ks, SslKeyStore.getCertificatePassword());
  150.  
  151.          // Initialize the SSLContext to work with our key managers.
  152.          serverContext = SSLContext.getInstance(PROTOCOL);
  153.          serverContext.init(kmf.getKeyManagers(), null, null);
  154.       }
  155.       catch (Exception e)
  156.       {
  157.          throw new Error("Failed to initialize the server-side SSLContext", e);
  158.       }
  159.  
  160.       SERVER_CONTEXT = serverContext;
  161.    }
  162.  
  163.    public static SSLContext getServerContext()
  164.    {
  165.       return SERVER_CONTEXT;
  166.    }
  167.  
  168.    private SslContextFactory()
  169.    {
  170.    }
  171. }
  172.  
  173. public class SslKeyStore
  174. {
  175.    private static final short[] DATA = new short[]{
  176.       0xfe, 0xed, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x02,
  177.       0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
  178.       0x00, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c,
  179.       0x65, 0x00, 0x00, 0x01, 0x1a, 0x9f, 0x57, 0xa5,
  180.       0x27, 0x00, 0x00, 0x01, 0x9a, 0x30, 0x82, 0x01,
  181.       0x96, 0x30, 0x0e, 0x06, 0x0a, 0x2b, 0x06, 0x01,
  182.       0x04, 0x01, 0x2a, 0x02, 0x11, 0x01, 0x01, 0x05,
  183.       0x00, 0x04, 0x82, 0x01, 0x82, 0x48, 0x6d, 0xcf,
  184.       0x16, 0xb5, 0x50, 0x95, 0x36, 0xbf, 0x47, 0x27,
  185.       0x50, 0x58, 0x0d, 0xa2, 0x52, 0x7e, 0x25, 0xab,
  186.       0x14, 0x1a, 0x26, 0x5e, 0x2d, 0x8a, 0x23, 0x90,
  187.       0x60, 0x7f, 0x12, 0x20, 0x56, 0xd1, 0x43, 0xa2,
  188.       0x6b, 0x47, 0x5d, 0xed, 0x9d, 0xd4, 0xe5, 0x83,
  189.       0x28, 0x89, 0xc2, 0x16, 0x4c, 0x76, 0x06, 0xad,
  190.       0x8e, 0x8c, 0x29, 0x1a, 0x9b, 0x0f, 0xdd, 0x60,
  191.       0x4b, 0xb4, 0x62, 0x82, 0x9e, 0x4a, 0x63, 0x83,
  192.       0x2e, 0xd2, 0x43, 0x78, 0xc2, 0x32, 0x1f, 0x60,
  193.       0xa9, 0x8a, 0x7f, 0x0f, 0x7c, 0xa6, 0x1d, 0xe6,
  194.       0x92, 0x9e, 0x52, 0xc7, 0x7d, 0xbb, 0x35, 0x3b,
  195.       0xaa, 0x89, 0x73, 0x4c, 0xfb, 0x99, 0x54, 0x97,
  196.       0x99, 0x28, 0x6e, 0x66, 0x5b, 0xf7, 0x9b, 0x7e,
  197.       0x6d, 0x8a, 0x2f, 0xfa, 0xc3, 0x1e, 0x71, 0xb9,
  198.       0xbd, 0x8f, 0xc5, 0x63, 0x25, 0x31, 0x20, 0x02,
  199.       0xff, 0x02, 0xf0, 0xc9, 0x2c, 0xdd, 0x3a, 0x10,
  200.       0x30, 0xab, 0xe5, 0xad, 0x3d, 0x1a, 0x82, 0x77,
  201.       0x46, 0xed, 0x03, 0x38, 0xa4, 0x73, 0x6d, 0x36,
  202.       0x36, 0x33, 0x70, 0xb2, 0x63, 0x20, 0xca, 0x03,
  203.       0xbf, 0x5a, 0xf4, 0x7c, 0x35, 0xf0, 0x63, 0x1a,
  204.       0x12, 0x33, 0x12, 0x58, 0xd9, 0xa2, 0x63, 0x6b,
  205.       0x63, 0x82, 0x41, 0x65, 0x70, 0x37, 0x4b, 0x99,
  206.       0x04, 0x9f, 0xdd, 0x5e, 0x07, 0x01, 0x95, 0x9f,
  207.       0x36, 0xe8, 0xc3, 0x66, 0x2a, 0x21, 0x69, 0x68,
  208.       0x40, 0xe6, 0xbc, 0xbb, 0x85, 0x81, 0x21, 0x13,
  209.       0xe6, 0xa4, 0xcf, 0xd3, 0x67, 0xe3, 0xfd, 0x75,
  210.       0xf0, 0xdf, 0x83, 0xe0, 0xc5, 0x36, 0x09, 0xac,
  211.       0x1b, 0xd4, 0xf7, 0x2a, 0x23, 0x57, 0x1c, 0x5c,
  212.       0x0f, 0xf4, 0xcf, 0xa2, 0xcf, 0xf5, 0xbd, 0x9c,
  213.       0x69, 0x98, 0x78, 0x3a, 0x25, 0xe4, 0xfd, 0x85,
  214.       0x11, 0xcc, 0x7d, 0xef, 0xeb, 0x74, 0x60, 0xb1,
  215.       0xb7, 0xfb, 0x1f, 0x0e, 0x62, 0xff, 0xfe, 0x09,
  216.       0x0a, 0xc3, 0x80, 0x2f, 0x10, 0x49, 0x89, 0x78,
  217.       0xd2, 0x08, 0xfa, 0x89, 0x22, 0x45, 0x91, 0x21,
  218.       0xbc, 0x90, 0x3e, 0xad, 0xb3, 0x0a, 0xb4, 0x0e,
  219.       0x1c, 0xa1, 0x93, 0x92, 0xd8, 0x72, 0x07, 0x54,
  220.       0x60, 0xe7, 0x91, 0xfc, 0xd9, 0x3c, 0xe1, 0x6f,
  221.       0x08, 0xe4, 0x56, 0xf6, 0x0b, 0xb0, 0x3c, 0x39,
  222.       0x8a, 0x2d, 0x48, 0x44, 0x28, 0x13, 0xca, 0xe9,
  223.       0xf7, 0xa3, 0xb6, 0x8a, 0x5f, 0x31, 0xa9, 0x72,
  224.       0xf2, 0xde, 0x96, 0xf2, 0xb1, 0x53, 0xb1, 0x3e,
  225.       0x24, 0x57, 0xfd, 0x18, 0x45, 0x1f, 0xc5, 0x33,
  226.       0x1b, 0xa4, 0xe8, 0x21, 0xfa, 0x0e, 0xb2, 0xb9,
  227.       0xcb, 0xc7, 0x07, 0x41, 0xdd, 0x2f, 0xb6, 0x6a,
  228.       0x23, 0x18, 0xed, 0xc1, 0xef, 0xe2, 0x4b, 0xec,
  229.       0xc9, 0xba, 0xfb, 0x46, 0x43, 0x90, 0xd7, 0xb5,
  230.       0x68, 0x28, 0x31, 0x2b, 0x8d, 0xa8, 0x51, 0x63,
  231.       0xf7, 0x53, 0x99, 0x19, 0x68, 0x85, 0x66, 0x00,
  232.       0x00, 0x00, 0x01, 0x00, 0x05, 0x58, 0x2e, 0x35,
  233.       0x30, 0x39, 0x00, 0x00, 0x02, 0x3a, 0x30, 0x82,
  234.       0x02, 0x36, 0x30, 0x82, 0x01, 0xe0, 0xa0, 0x03,
  235.       0x02, 0x01, 0x02, 0x02, 0x04, 0x48, 0x59, 0xf1,
  236.       0x92, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
  237.       0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00,
  238.       0x30, 0x81, 0xa0, 0x31, 0x0b, 0x30, 0x09, 0x06,
  239.       0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4b, 0x52,
  240.       0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04,
  241.       0x08, 0x13, 0x0a, 0x4b, 0x79, 0x75, 0x6e, 0x67,
  242.       0x67, 0x69, 0x2d, 0x64, 0x6f, 0x31, 0x14, 0x30,
  243.       0x12, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x0b,
  244.       0x53, 0x65, 0x6f, 0x6e, 0x67, 0x6e, 0x61, 0x6d,
  245.       0x2d, 0x73, 0x69, 0x31, 0x1a, 0x30, 0x18, 0x06,
  246.       0x03, 0x55, 0x04, 0x0a, 0x13, 0x11, 0x54, 0x68,
  247.       0x65, 0x20, 0x4e, 0x65, 0x74, 0x74, 0x79, 0x20,
  248.       0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x31,
  249.       0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x0b,
  250.       0x13, 0x0f, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c,
  251.       0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
  252.       0x73, 0x31, 0x30, 0x30, 0x2e, 0x06, 0x03, 0x55,
  253.       0x04, 0x03, 0x13, 0x27, 0x73, 0x65, 0x63, 0x75,
  254.       0x72, 0x65, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x65,
  255.       0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x6e,
  256.       0x65, 0x74, 0x74, 0x79, 0x2e, 0x67, 0x6c, 0x65,
  257.       0x61, 0x6d, 0x79, 0x6e, 0x6f, 0x64, 0x65, 0x2e,
  258.       0x6e, 0x65, 0x74, 0x30, 0x20, 0x17, 0x0d, 0x30,
  259.       0x38, 0x30, 0x36, 0x31, 0x39, 0x30, 0x35, 0x34,
  260.       0x31, 0x33, 0x38, 0x5a, 0x18, 0x0f, 0x32, 0x31,
  261.       0x38, 0x37, 0x31, 0x31, 0x32, 0x34, 0x30, 0x35,
  262.       0x34, 0x31, 0x33, 0x38, 0x5a, 0x30, 0x81, 0xa0,
  263.       0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
  264.       0x06, 0x13, 0x02, 0x4b, 0x52, 0x31, 0x13, 0x30,
  265.       0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a,
  266.       0x4b, 0x79, 0x75, 0x6e, 0x67, 0x67, 0x69, 0x2d,
  267.       0x64, 0x6f, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03,
  268.       0x55, 0x04, 0x07, 0x13, 0x0b, 0x53, 0x65, 0x6f,
  269.       0x6e, 0x67, 0x6e, 0x61, 0x6d, 0x2d, 0x73, 0x69,
  270.       0x31, 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04,
  271.       0x0a, 0x13, 0x11, 0x54, 0x68, 0x65, 0x20, 0x4e,
  272.       0x65, 0x74, 0x74, 0x79, 0x20, 0x50, 0x72, 0x6f,
  273.       0x6a, 0x65, 0x63, 0x74, 0x31, 0x18, 0x30, 0x16,
  274.       0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x0f, 0x45,
  275.       0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x41,
  276.       0x75, 0x74, 0x68, 0x6f, 0x72, 0x73, 0x31, 0x30,
  277.       0x30, 0x2e, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
  278.       0x27, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x63,
  279.       0x68, 0x61, 0x74, 0x2e, 0x65, 0x78, 0x61, 0x6d,
  280.       0x70, 0x6c, 0x65, 0x2e, 0x6e, 0x65, 0x74, 0x74,
  281.       0x79, 0x2e, 0x67, 0x6c, 0x65, 0x61, 0x6d, 0x79,
  282.       0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x65, 0x74,
  283.       0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
  284.       0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
  285.       0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41,
  286.       0x00, 0xc3, 0xe3, 0x5e, 0x41, 0xa7, 0x87, 0x11,
  287.       0x00, 0x42, 0x2a, 0xb0, 0x4b, 0xed, 0xb2, 0xe0,
  288.       0x23, 0xdb, 0xb1, 0x3d, 0x58, 0x97, 0x35, 0x60,
  289.       0x0b, 0x82, 0x59, 0xd3, 0x00, 0xea, 0xd4, 0x61,
  290.       0xb8, 0x79, 0x3f, 0xb6, 0x3c, 0x12, 0x05, 0x93,
  291.       0x2e, 0x9a, 0x59, 0x68, 0x14, 0x77, 0x3a, 0xc8,
  292.       0x50, 0x25, 0x57, 0xa4, 0x49, 0x18, 0x63, 0x41,
  293.       0xf0, 0x2d, 0x28, 0xec, 0x06, 0xfb, 0xb4, 0x9f,
  294.       0xbf, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d,
  295.       0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
  296.       0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x41, 0x00,
  297.       0x65, 0x6c, 0x30, 0x01, 0xc2, 0x8e, 0x3e, 0xcb,
  298.       0xb3, 0x77, 0x48, 0xe9, 0x66, 0x61, 0x9a, 0x40,
  299.       0x86, 0xaf, 0xf6, 0x03, 0xeb, 0xba, 0x6a, 0xf2,
  300.       0xfd, 0xe2, 0xaf, 0x36, 0x5e, 0x7b, 0xaa, 0x22,
  301.       0x04, 0xdd, 0x2c, 0x20, 0xc4, 0xfc, 0xdd, 0xd0,
  302.       0x82, 0x20, 0x1c, 0x3d, 0xd7, 0x9e, 0x5e, 0x5c,
  303.       0x92, 0x5a, 0x76, 0x71, 0x28, 0xf5, 0x07, 0x7d,
  304.       0xa2, 0x81, 0xba, 0x77, 0x9f, 0x2a, 0xd9, 0x44,
  305.       0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x6d, 0x79,
  306.       0x6b, 0x65, 0x79, 0x00, 0x00, 0x01, 0x1a, 0x9f,
  307.       0x5b, 0x56, 0xa0, 0x00, 0x00, 0x01, 0x99, 0x30,
  308.       0x82, 0x01, 0x95, 0x30, 0x0e, 0x06, 0x0a, 0x2b,
  309.       0x06, 0x01, 0x04, 0x01, 0x2a, 0x02, 0x11, 0x01,
  310.       0x01, 0x05, 0x00, 0x04, 0x82, 0x01, 0x81, 0x29,
  311.       0xa8, 0xb6, 0x08, 0x0c, 0x85, 0x75, 0x3e, 0xdd,
  312.       0xb5, 0xe5, 0x1a, 0x87, 0x68, 0xd1, 0x90, 0x4b,
  313.       0x29, 0x31, 0xee, 0x90, 0xbc, 0x9d, 0x73, 0xa0,
  314.       0x3f, 0xe9, 0x0b, 0xa4, 0xef, 0x30, 0x9b, 0x36,
  315.       0x9a, 0xb2, 0x54, 0x77, 0x81, 0x07, 0x4b, 0xaa,
  316.       0xa5, 0x77, 0x98, 0xe1, 0xeb, 0xb5, 0x7c, 0x4e,
  317.       0x48, 0xd5, 0x08, 0xfc, 0x2c, 0x36, 0xe2, 0x65,
  318.       0x03, 0xac, 0xe5, 0xf3, 0x96, 0xb7, 0xd0, 0xb5,
  319.       0x3b, 0x92, 0xe4, 0x14, 0x05, 0x7a, 0x6a, 0x92,
  320.       0x56, 0xfe, 0x4e, 0xab, 0xd3, 0x0e, 0x32, 0x04,
  321.       0x22, 0x22, 0x74, 0x47, 0x7d, 0xec, 0x21, 0x99,
  322.       0x30, 0x31, 0x64, 0x46, 0x64, 0x9b, 0xc7, 0x13,
  323.       0xbf, 0xbe, 0xd0, 0x31, 0x49, 0xe7, 0x3c, 0xbf,
  324.       0xba, 0xb1, 0x20, 0xf9, 0x42, 0xf4, 0xa9, 0xa9,
  325.       0xe5, 0x13, 0x65, 0x32, 0xbf, 0x7c, 0xcc, 0x91,
  326.       0xd3, 0xfd, 0x24, 0x47, 0x0b, 0xe5, 0x53, 0xad,
  327.       0x50, 0x30, 0x56, 0xd1, 0xfa, 0x9c, 0x37, 0xa8,
  328.       0xc1, 0xce, 0xf6, 0x0b, 0x18, 0xaa, 0x7c, 0xab,
  329.       0xbd, 0x1f, 0xdf, 0xe4, 0x80, 0xb8, 0xa7, 0xe0,
  330.       0xad, 0x7d, 0x50, 0x74, 0xf1, 0x98, 0x78, 0xbc,
  331.       0x58, 0xb9, 0xc2, 0x52, 0xbe, 0xd2, 0x5b, 0x81,
  332.       0x94, 0x83, 0x8f, 0xb9, 0x4c, 0xee, 0x01, 0x2b,
  333.       0x5e, 0xc9, 0x6e, 0x9b, 0xf5, 0x63, 0x69, 0xe4,
  334.       0xd8, 0x0b, 0x47, 0xd8, 0xfd, 0xd8, 0xe0, 0xed,
  335.       0xa8, 0x27, 0x03, 0x74, 0x1e, 0x5d, 0x32, 0xe6,
  336.       0x5c, 0x63, 0xc2, 0xfb, 0x3f, 0xee, 0xb4, 0x13,
  337.       0xc6, 0x0e, 0x6e, 0x74, 0xe0, 0x22, 0xac, 0xce,
  338.       0x79, 0xf9, 0x43, 0x68, 0xc1, 0x03, 0x74, 0x2b,
  339.       0xe1, 0x18, 0xf8, 0x7f, 0x76, 0x9a, 0xea, 0x82,
  340.       0x3f, 0xc2, 0xa6, 0xa7, 0x4c, 0xfe, 0xae, 0x29,
  341.       0x3b, 0xc1, 0x10, 0x7c, 0xd5, 0x77, 0x17, 0x79,
  342.       0x5f, 0xcb, 0xad, 0x1f, 0xd8, 0xa1, 0xfd, 0x90,
  343.       0xe1, 0x6b, 0xb2, 0xef, 0xb9, 0x41, 0x26, 0xa4,
  344.       0x0b, 0x4f, 0xc6, 0x83, 0x05, 0x6f, 0xf0, 0x64,
  345.       0x40, 0xe1, 0x44, 0xc4, 0xf9, 0x40, 0x2b, 0x3b,
  346.       0x40, 0xdb, 0xaf, 0x35, 0xa4, 0x9b, 0x9f, 0xc4,
  347.       0x74, 0x07, 0xe5, 0x18, 0x60, 0xc5, 0xfe, 0x15,
  348.       0x0e, 0x3a, 0x25, 0x2a, 0x11, 0xee, 0x78, 0x2f,
  349.       0xb8, 0xd1, 0x6e, 0x4e, 0x3c, 0x0a, 0xb5, 0xb9,
  350.       0x40, 0x86, 0x27, 0x6d, 0x8f, 0x53, 0xb7, 0x77,
  351.       0x36, 0xec, 0x5d, 0xed, 0x32, 0x40, 0x43, 0x82,
  352.       0xc3, 0x52, 0x58, 0xc4, 0x26, 0x39, 0xf3, 0xb3,
  353.       0xad, 0x58, 0xab, 0xb7, 0xf7, 0x8e, 0x0e, 0xba,
  354.       0x8e, 0x78, 0x9d, 0xbf, 0x58, 0x34, 0xbd, 0x77,
  355.       0x73, 0xa6, 0x50, 0x55, 0x00, 0x60, 0x26, 0xbf,
  356.       0x6d, 0xb4, 0x98, 0x8a, 0x18, 0x83, 0x89, 0xf8,
  357.       0xcd, 0x0d, 0x49, 0x06, 0xae, 0x51, 0x6e, 0xaf,
  358.       0xbd, 0xe2, 0x07, 0x13, 0xd8, 0x64, 0xcc, 0xbf,
  359.       0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x58, 0x2e,
  360.       0x35, 0x30, 0x39, 0x00, 0x00, 0x02, 0x34, 0x30,
  361.       0x82, 0x02, 0x30, 0x30, 0x82, 0x01, 0xda, 0xa0,
  362.       0x03, 0x02, 0x01, 0x02, 0x02, 0x04, 0x48, 0x59,
  363.       0xf2, 0x84, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
  364.       0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
  365.       0x00, 0x30, 0x81, 0x9d, 0x31, 0x0b, 0x30, 0x09,
  366.       0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4b,
  367.       0x52, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
  368.       0x04, 0x08, 0x13, 0x0a, 0x4b, 0x79, 0x75, 0x6e,
  369.       0x67, 0x67, 0x69, 0x2d, 0x64, 0x6f, 0x31, 0x14,
  370.       0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13,
  371.       0x0b, 0x53, 0x65, 0x6f, 0x6e, 0x67, 0x6e, 0x61,
  372.       0x6d, 0x2d, 0x73, 0x69, 0x31, 0x1a, 0x30, 0x18,
  373.       0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x11, 0x54,
  374.       0x68, 0x65, 0x20, 0x4e, 0x65, 0x74, 0x74, 0x79,
  375.       0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
  376.       0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04,
  377.       0x0b, 0x13, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x72,
  378.       0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, 0x31,
  379.       0x30, 0x30, 0x2e, 0x06, 0x03, 0x55, 0x04, 0x03,
  380.       0x13, 0x27, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65,
  381.       0x63, 0x68, 0x61, 0x74, 0x2e, 0x65, 0x78, 0x61,
  382.       0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x6e, 0x65, 0x74,
  383.       0x74, 0x79, 0x2e, 0x67, 0x6c, 0x65, 0x61, 0x6d,
  384.       0x79, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x65,
  385.       0x74, 0x30, 0x20, 0x17, 0x0d, 0x30, 0x38, 0x30,
  386.       0x36, 0x31, 0x39, 0x30, 0x35, 0x34, 0x35, 0x34,
  387.       0x30, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x38, 0x37,
  388.       0x31, 0x31, 0x32, 0x33, 0x30, 0x35, 0x34, 0x35,
  389.       0x34, 0x30, 0x5a, 0x30, 0x81, 0x9d, 0x31, 0x0b,
  390.       0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
  391.       0x02, 0x4b, 0x52, 0x31, 0x13, 0x30, 0x11, 0x06,
  392.       0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x4b, 0x79,
  393.       0x75, 0x6e, 0x67, 0x67, 0x69, 0x2d, 0x64, 0x6f,
  394.       0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04,
  395.       0x07, 0x13, 0x0b, 0x53, 0x65, 0x6f, 0x6e, 0x67,
  396.       0x6e, 0x61, 0x6d, 0x2d, 0x73, 0x69, 0x31, 0x1a,
  397.       0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13,
  398.       0x11, 0x54, 0x68, 0x65, 0x20, 0x4e, 0x65, 0x74,
  399.       0x74, 0x79, 0x20, 0x50, 0x72, 0x6f, 0x6a, 0x65,
  400.       0x63, 0x74, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03,
  401.       0x55, 0x04, 0x0b, 0x13, 0x0c, 0x43, 0x6f, 0x6e,
  402.       0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72,
  403.       0x73, 0x31, 0x30, 0x30, 0x2e, 0x06, 0x03, 0x55,
  404.       0x04, 0x03, 0x13, 0x27, 0x73, 0x65, 0x63, 0x75,
  405.       0x72, 0x65, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x65,
  406.       0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x6e,
  407.       0x65, 0x74, 0x74, 0x79, 0x2e, 0x67, 0x6c, 0x65,
  408.       0x61, 0x6d, 0x79, 0x6e, 0x6f, 0x64, 0x65, 0x2e,
  409.       0x6e, 0x65, 0x74, 0x30, 0x5c, 0x30, 0x0d, 0x06,
  410.       0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
  411.       0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30,
  412.       0x48, 0x02, 0x41, 0x00, 0x95, 0xb3, 0x47, 0x17,
  413.       0x95, 0x0f, 0x57, 0xcf, 0x66, 0x72, 0x0a, 0x7e,
  414.       0x5b, 0x54, 0xea, 0x8c, 0x6f, 0x79, 0xde, 0x94,
  415.       0xac, 0x0b, 0x5a, 0xd4, 0xd6, 0x1b, 0x58, 0x12,
  416.       0x1a, 0x16, 0x3d, 0xfe, 0xdf, 0xa5, 0x2b, 0x86,
  417.       0xbc, 0x64, 0xd4, 0x80, 0x1e, 0x3f, 0xf9, 0xe2,
  418.       0x04, 0x03, 0x79, 0x9b, 0xc1, 0x5c, 0xf0, 0xf1,
  419.       0xf3, 0xf1, 0xe3, 0xbf, 0x3f, 0xc0, 0x1f, 0xdd,
  420.       0xdb, 0xc0, 0x5b, 0x21, 0x02, 0x03, 0x01, 0x00,
  421.       0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
  422.       0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00,
  423.       0x03, 0x41, 0x00, 0x02, 0xd7, 0xdd, 0xbd, 0x0c,
  424.       0x8e, 0x21, 0x20, 0xef, 0x9e, 0x4f, 0x1f, 0xf5,
  425.       0x49, 0xf1, 0xae, 0x58, 0x9b, 0x94, 0x3a, 0x1f,
  426.       0x70, 0x33, 0xf0, 0x9b, 0xbb, 0xe9, 0xc0, 0xf3,
  427.       0x72, 0xcb, 0xde, 0xb6, 0x56, 0x72, 0xcc, 0x1c,
  428.       0xf0, 0xd6, 0x5a, 0x2a, 0xbc, 0xa1, 0x7e, 0x23,
  429.       0x83, 0xe9, 0xe7, 0xcf, 0x9e, 0xa5, 0xf9, 0xcc,
  430.       0xc2, 0x61, 0xf4, 0xdb, 0x40, 0x93, 0x1d, 0x63,
  431.       0x8a, 0x50, 0x4c, 0x11, 0x39, 0xb1, 0x91, 0xc1,
  432.       0xe6, 0x9d, 0xd9, 0x1a, 0x62, 0x1b, 0xb8, 0xd3,
  433.       0xd6, 0x9a, 0x6d, 0xb9, 0x8e, 0x15, 0x51};
  434.  
  435.    public static InputStream asInputStream()
  436.    {
  437.       byte[] data = new byte[DATA.length];
  438.       for (int i = 0; i < data.length; i++)
  439.       {
  440.          data[i] = (byte) DATA[i];
  441.       }
  442.       return new ByteArrayInputStream(data);
  443.    }
  444.  
  445.    public static char[] getCertificatePassword()
  446.    {
  447.       return "secret".toCharArray();
  448.    }
  449.  
  450.    public static char[] getKeyStorePassword()
  451.    {
  452.       return "secret".toCharArray();
  453.    }
  454.  
  455.    private SslKeyStore()
  456.    {
  457.    }
  458. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement