コード例 #1
0
  public void testSessionTimeout() throws Exception {
    SSLContextParameters scp = new SSLContextParameters();
    scp.setSessionTimeout("60");

    SSLContext context = scp.createSSLContext();

    assertEquals(60, context.getClientSessionContext().getSessionTimeout());
    assertEquals(60, context.getServerSessionContext().getSessionTimeout());

    scp.setSessionTimeout("0");

    context = scp.createSSLContext();

    assertEquals(0, context.getClientSessionContext().getSessionTimeout());
    assertEquals(0, context.getServerSessionContext().getSessionTimeout());
  }
コード例 #2
0
  public void testPropertyPlaceholders() throws Exception {

    CamelContext camelContext = this.createPropertiesPlaceholderAwareContext();

    KeyStoreParameters ksp = new KeyStoreParameters();
    ksp.setCamelContext(camelContext);

    ksp.setType("{{keyStoreParameters.type}}");
    ksp.setProvider("{{keyStoreParameters.provider}}");
    ksp.setResource("{{keyStoreParameters.resource}}");
    ksp.setPassword("{{keyStoreParamerers.password}}");

    KeyManagersParameters kmp = new KeyManagersParameters();
    kmp.setCamelContext(camelContext);
    kmp.setKeyStore(ksp);

    kmp.setKeyPassword("{{keyManagersParameters.keyPassword}}");
    kmp.setAlgorithm("{{keyManagersParameters.algorithm}}");
    kmp.setProvider("{{keyManagersParameters.provider}}");

    TrustManagersParameters tmp = new TrustManagersParameters();
    tmp.setCamelContext(camelContext);
    tmp.setKeyStore(ksp);

    tmp.setAlgorithm("{{trustManagersParameters.algorithm}}");
    tmp.setProvider("{{trustManagersParameters.provider}}");

    CipherSuitesParameters csp = new CipherSuitesParameters();
    csp.getCipherSuite().add("{{cipherSuite.0}}");

    SecureSocketProtocolsParameters sspp = new SecureSocketProtocolsParameters();
    sspp.getSecureSocketProtocol().add("{{secureSocketProtocol.0}}");

    SSLContextServerParameters scsp = new SSLContextServerParameters();
    scsp.setCamelContext(camelContext);
    scsp.setClientAuthentication("{{sslContextServerParameters.clientAuthentication}}");

    SSLContextParameters scp = new SSLContextParameters();
    scp.setCamelContext(camelContext);
    scp.setKeyManagers(kmp);
    scp.setTrustManagers(tmp);
    scp.setServerParameters(scsp);

    scp.setProvider("{{sslContextParameters.provider}}");
    scp.setSecureSocketProtocol("{{sslContextParameters.protocol}}");
    scp.setSessionTimeout("{{sslContextParameters.sessionTimeout}}");

    scp.setCipherSuites(csp);
    scp.setSecureSocketProtocols(sspp);

    SSLContext context = scp.createSSLContext();
    SSLServerSocket serverSocket =
        (SSLServerSocket) context.getServerSocketFactory().createServerSocket();
    assertTrue(serverSocket.getNeedClientAuth());
    context.getSocketFactory().createSocket();
    context.createSSLEngine();
  }