Search in sources :

Example 1 with DefaultInterceptFactory

use of com.wing.apirecord.core.intercept.DefaultInterceptFactory in project apiRecord by tobecoder2015.

the class NettyHttpProxyServer method init.

private void init() throws Exception {
    Security.addProvider(new BouncyCastleProvider());
    Method method = HttpResponseStatus.class.getDeclaredMethod("newStatus", int.class, String.class);
    method.setAccessible(true);
    SUCCESS = (HttpResponseStatus) method.invoke(null, 200, "Connection established");
    clientSslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    issuer = CertUtil.getSubject(classLoader.getResourceAsStream("ca.crt"));
    // CA私钥和公钥用于给动态生成的网站SSL证书签证
    caPriKey = CertUtil.loadPriKey(classLoader.getResourceAsStream("ca_private.pem"));
    caPubKey = CertUtil.loadPubKey(classLoader.getResourceAsStream("ca_public.der"));
    // 生产一对随机公私钥用于网站SSL证书动态创建
    KeyPair keyPair = CertUtil.genKeyPair();
    serverPriKey = keyPair.getPrivate();
    serverPubKey = keyPair.getPublic();
    proxyGroup = new NioEventLoopGroup();
    if (proxyInterceptFactory == null) {
        proxyInterceptFactory = new DefaultInterceptFactory();
    }
}
Also used : DefaultInterceptFactory(com.wing.apirecord.core.intercept.DefaultInterceptFactory) KeyPair(java.security.KeyPair) Method(java.lang.reflect.Method) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Aggregations

DefaultInterceptFactory (com.wing.apirecord.core.intercept.DefaultInterceptFactory)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 Method (java.lang.reflect.Method)1 KeyPair (java.security.KeyPair)1 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)1