MCPcopy Create free account
hub / github.com/apache/thrift / secure

Method secure

tutorial/java/src/JavaServer.java:79–109  ·  view source on GitHub ↗
(Calculator.Processor processor)

Source from the content-addressed store, hash-verified

77 }
78
79 public static void secure(Calculator.Processor processor) {
80 try {
81 /*
82 * Use TSSLTransportParameters to setup the required SSL parameters. In this example
83 * we are setting the keystore and the keystore password. Other things like algorithms,
84 * cipher suites, client auth etc can be set.
85 */
86 TSSLTransportParameters params = new TSSLTransportParameters();
87 // The Keystore contains the private key
88 params.setKeyStore("../../lib/java/test/resources/.keystore", "thrift", null, null);
89
90 /*
91 * Use any of the TSSLTransportFactory to get a server transport with the appropriate
92 * SSL configuration. You can use the default settings if properties are set in the command line.
93 * Ex: -Djavax.net.ssl.keyStore=.keystore and -Djavax.net.ssl.keyStorePassword=thrift
94 *
95 * Note: You need not explicitly call open(). The underlying server socket is bound on return
96 * from the factory class.
97 */
98 TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
99 TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
100
101 // Use this for a multi threaded server
102 // TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
103
104 System.out.println("Starting the secure server...");
105 server.serve();
106 } catch (Exception e) {
107 e.printStackTrace();
108 }
109 }
110}

Callers 1

runMethod · 0.95

Calls 4

setKeyStoreMethod · 0.95
getServerSocketMethod · 0.95
serveMethod · 0.95
processorMethod · 0.45

Tested by

no test coverage detected