• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SSLFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.mina.filter.SSLFilter的典型用法代码示例。如果您正苦于以下问题:Java SSLFilter类的具体用法?Java SSLFilter怎么用?Java SSLFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SSLFilter类属于org.apache.mina.filter包,在下文中一共展示了SSLFilter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: write

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Override
public WriteFuture write(Object message) {
    DefaultWriteFuture ret = new DefaultWriteFuture(this);
    try {
        otherEnd.messageReceived(nextFilter, otherSession, message);
        ret.setWritten(true);
    }
    catch (Exception e) {
        e.printStackTrace();
        ret.setWritten(false);
    }
    // behave like the real thing..
    if (attributes.get(SSLFilter.DISABLE_ENCRYPTION_ONCE) != null) {
        attributes.remove(SSLFilter.DISABLE_ENCRYPTION_ONCE);
    }
    return ret;
}
 
开发者ID:betfair,项目名称:cougar,代码行数:18,代码来源:CougarProtocolTest.java


示例2: getLocalCertificates

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
public Certificate[] getLocalCertificates() {
    SSLSession sslSession = (SSLSession) ioSession.getAttribute(SSLFilter.SSL_SESSION);
    if (sslSession != null) {
        return sslSession.getLocalCertificates();
    }
    return new Certificate[0];
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:8,代码来源:NIOConnection.java


示例3: getPeerCertificates

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
public Certificate[] getPeerCertificates() {
    try {
        SSLSession sslSession = (SSLSession) ioSession.getAttribute(SSLFilter.SSL_SESSION);
        if (sslSession != null) {
            return sslSession.getPeerCertificates();
        }
    } catch (SSLPeerUnverifiedException e) {
        Log.warn("Error retrieving client certificates of: " + session, e);
    }
    return new Certificate[0];
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:12,代码来源:NIOConnection.java


示例4: sessionCreated

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
public void sessionCreated(IoSession ioSession) throws Exception
{
    if(log.isDebugEnabled())
    {
        log.debug("Created session: " + ioSession.getRemoteAddress());
    }

    SessionUtil.initialize(ioSession);
    IoFilterChain chain = ioSession.getFilterChain();

  if (_sslFactory != null)
    {
        // at the time of initializing sslfactory no 'protocolFilter' is created. Hence we need to add 'sslFilter' as first in filter chain.
        chain.addFirst("sslFilter", new SSLFilter(_sslFactory.buildServerContext()));

    }

    if (_factory != null)
    {
       NetworkConnection netConn = new MinaNetworkConnection(ioSession);

       ProtocolEngine engine = _factory.newProtocolEngine(netConn);
       ioSession.setAttachment(engine);
    }

    // We limit the size of receiving buffer to 1 MB
    ReadThrottleFilterBuilder readFilter = new ReadThrottleFilterBuilder();
    readFilter.setMaximumConnectionBufferSize(1024*1024);
    readFilter.attach(chain);
}
 
开发者ID:wso2,项目名称:andes,代码行数:31,代码来源:MinaNetworkHandler.java


示例5: CougarProtocol

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
protected CougarProtocol(boolean server, NioLogger nioLogger, int keepAliveInterval, int keepAliveTimeout, SSLFilter sslFilter, boolean supportsTls, boolean requiresTls, long rpcTimeoutMillis) {
    this.isServer = server;
    this.nioLogger = nioLogger;
    this.interval = keepAliveInterval;
    this.timeout = keepAliveTimeout;
    this.sslFilter = sslFilter;
    this.supportsTls = supportsTls;
    this.requiresTls = requiresTls;
    this.rpcTimeoutMillis = rpcTimeoutMillis;
    export(nioLogger.getJmxControl());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:12,代码来源:CougarProtocol.java


示例6: CougarProtocol4

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
protected CougarProtocol4(boolean server, NioLogger nioLogger, int keepAliveInterval, int keepAliveTimeout, SSLFilter sslFilter, boolean supportsTls, boolean requiresTls, long rpcTimeoutMillis) {
    super(server, nioLogger, keepAliveInterval, keepAliveTimeout, sslFilter, supportsTls, requiresTls, rpcTimeoutMillis);
    this.isServer = server;
    this.nioLogger = nioLogger;
    this.interval = keepAliveInterval;
    this.timeout = keepAliveTimeout;
    this.sslFilter = sslFilter;
    this.supportsTls = supportsTls;
    this.requiresTls = requiresTls;
    this.rpcTimeoutMillis = rpcTimeoutMillis;
    export(nioLogger.getJmxControl());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:13,代码来源:CougarProtocol4.java


示例7: CougarProtocol3

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
protected CougarProtocol3(boolean server, NioLogger nioLogger, int keepAliveInterval, int keepAliveTimeout, SSLFilter sslFilter, boolean supportsTls, boolean requiresTls, long rpcTimeoutMillis) {
    this.isServer = server;
    this.nioLogger = nioLogger;
    this.interval = keepAliveInterval;
    this.timeout = keepAliveTimeout;
    this.sslFilter = sslFilter;
    this.supportsTls = supportsTls;
    this.requiresTls = requiresTls;
    this.rpcTimeoutMillis = rpcTimeoutMillis;
    export(nioLogger.getJmxControl());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:12,代码来源:CougarProtocol3.java


示例8: secureClientSupportsTlsNoClientAuthTruststoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureClientSupportsTlsNoClientAuthTruststoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getClientTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setWantClientAuth(false);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, false);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertFalse(sslFilter.isWantClientAuth());
    assertTrue(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:33,代码来源:TlsNioConfigTest.java


示例9: secureClientSupportsTlsNoClientAuthTruststoreProvidedSpecifiedCiphers

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureClientSupportsTlsNoClientAuthTruststoreProvidedSpecifiedCiphers() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getClientTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setWantClientAuth(false);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.setAllowedCipherSuites("DES,AES");
    config.configureProtocol(minaConfig, false);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertFalse(sslFilter.isWantClientAuth());
    assertTrue(sslFilter.isUseClientMode());
    assertNotNull(sslFilter.getEnabledCipherSuites());
    assertEquals(2, sslFilter.getEnabledCipherSuites().length);
}
 
开发者ID:betfair,项目名称:cougar,代码行数:35,代码来源:TlsNioConfigTest.java


示例10: secureClientSupportsTlsWantsClientAuthTruststoreProvidedKeystoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureClientSupportsTlsWantsClientAuthTruststoreProvidedKeystoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getClientTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setKeystore(new FileSystemResource(getClientKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(true);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, false);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertTrue(sslFilter.isWantClientAuth());
    assertTrue(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:36,代码来源:TlsNioConfigTest.java


示例11: secureClientSupportsTlsNeedsClientAuthTruststoreProvidedKeystoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureClientSupportsTlsNeedsClientAuthTruststoreProvidedKeystoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getClientTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setKeystore(new FileSystemResource(getClientKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(true);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, false);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertTrue(sslFilter.isWantClientAuth());
    assertTrue(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:36,代码来源:TlsNioConfigTest.java


示例12: secureClientRequiresTlsNoClientAuthTruststoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureClientRequiresTlsNoClientAuthTruststoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getClientTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setWantClientAuth(false);
    config.setNeedClientAuth(false);
    config.setRequiresTls(true);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, false);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertTrue(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertFalse(sslFilter.isWantClientAuth());
    assertTrue(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:33,代码来源:TlsNioConfigTest.java


示例13: secureServerSupportsTlsNoClientAuthKeystoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureServerSupportsTlsNoClientAuthKeystoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setKeystore(new FileSystemResource(getServerKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(false);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, true);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertFalse(sslFilter.isWantClientAuth());
    assertFalse(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:33,代码来源:TlsNioConfigTest.java


示例14: secureServerSupportsTlsNoClientAuthKeystoreProvidedSpecifiedCiphers

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureServerSupportsTlsNoClientAuthKeystoreProvidedSpecifiedCiphers() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setKeystore(new FileSystemResource(getServerKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(false);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.setAllowedCipherSuites("DES,AES");
    config.configureProtocol(minaConfig, true);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertFalse(sslFilter.isWantClientAuth());
    assertFalse(sslFilter.isUseClientMode());
    assertNotNull(sslFilter.getEnabledCipherSuites());
    assertEquals(2, sslFilter.getEnabledCipherSuites().length);
}
 
开发者ID:betfair,项目名称:cougar,代码行数:35,代码来源:TlsNioConfigTest.java


示例15: secureServerSupportsTlsWantsClientAuthKeystoreProvidedTruststoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureServerSupportsTlsWantsClientAuthKeystoreProvidedTruststoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getServerTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setKeystore(new FileSystemResource(getServerKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(true);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, true);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertTrue(sslFilter.isWantClientAuth());
    assertFalse(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:36,代码来源:TlsNioConfigTest.java


示例16: secureServerSupportsTlsNeedsClientAuthKeystoreProvidedTruststoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureServerSupportsTlsNeedsClientAuthKeystoreProvidedTruststoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setTruststore(new FileSystemResource(getServerTruststorePath()));
    config.setTruststorePassword("password");
    config.setTruststoreType("JKS");
    config.setKeystore(new FileSystemResource(getServerKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(true);
    config.setNeedClientAuth(false);
    config.setRequiresTls(false);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, true);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertFalse(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertTrue(sslFilter.isWantClientAuth());
    assertFalse(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:36,代码来源:TlsNioConfigTest.java


示例17: secureServerRequiresTlsNoClientAuthKeystoreProvided

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
@Test
public void secureServerRequiresTlsNoClientAuthKeystoreProvided() throws IOException {
    TlsNioConfig config = new TlsNioConfig();
    config.setNioLogger(logger);
    config.setMbeanServer(mbeanServer);
    config.setKeystore(new FileSystemResource(getServerKeystorePath()));
    config.setKeystorePassword("password");
    config.setKeystoreType("JKS");
    config.setWantClientAuth(false);
    config.setNeedClientAuth(false);
    config.setRequiresTls(true);
    config.setSupportsTls(true);
    config.configureProtocol(minaConfig, true);

    List<Tuple<String, IoFilter>> addedFilters = getAddedFilters();
    assertEquals("slowHandling", addedFilters.get(0).getFirst());
    assertInstanceOf(SessionWriteQueueMonitoring.class, addedFilters.get(0).getSecond());
    assertEquals("codec", addedFilters.get(1).getFirst());
    assertInstanceOf(ProtocolCodecFilter.class, addedFilters.get(1).getSecond());
    assertEquals("protocol", addedFilters.get(2).getFirst());
    assertInstanceOf(CougarProtocol.class, addedFilters.get(2).getSecond());

    CougarProtocol cp = (CougarProtocol) addedFilters.get(2).getSecond();
    assertTrue(cp.isRequiresTls());
    assertTrue(cp.isSupportsTls());
    assertNotNull(cp.getSslFilter());
    SSLFilter sslFilter = cp.getSslFilter();
    assertFalse(sslFilter.isNeedClientAuth());
    assertFalse(sslFilter.isWantClientAuth());
    assertFalse(sslFilter.isUseClientMode());
    assertNull(sslFilter.getEnabledCipherSuites());
}
 
开发者ID:betfair,项目名称:cougar,代码行数:33,代码来源:TlsNioConfigTest.java


示例18: connectFederationTLS

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
/**
 * Create a connection to federation listener.
 */
private static IoSession connectFederationTLS (Router router,
                                               EwafURI uri,
                                               IoHandler listener)
  throws Exception
{
  SocketConnector connector = new SocketConnector (1, router.executor ());
  SocketConnectorConfig connectorConfig = new SocketConnectorConfig ();
  
  connector.setWorkerTimeout (0);
  
  connectorConfig.setThreadModel (ThreadModel.MANUAL);
  connectorConfig.setConnectTimeout (20);
  
  SSLFilter filter = new SSLFilter (defaultSSLContext ());
  
  filter.setUseClientMode (true);
  
  connectorConfig.getFilterChain ().addFirst ("ssl", filter);   
  
  connectorConfig.getFilterChain ().addLast   
    ("codec", FederationFrameCodec.FILTER);
  
  ConnectFuture future = 
    connector.connect (new InetSocketAddress (uri.host, uri.port),
                       listener, connectorConfig);
  
  future.join ();
  
  return future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:34,代码来源:JUTestFederationTLS.java


示例19: createTLSConfig

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
private static SocketConnectorConfig createTLSConfig () 
  throws Exception
{
  SocketConnectorConfig connectorConfig = createStandardConfig ();
  
  SSLContext sslContext = SSLContext.getInstance ("TLS");
  sslContext.init (null, new TrustManager [] {ACCEPT_ALL_MANAGER}, null);
  
  SSLFilter sslFilter = new SSLFilter (sslContext);
  sslFilter.setUseClientMode (true);
  
  connectorConfig.getFilterChain ().addFirst  ("ssl", sslFilter);
                              
  return connectorConfig;
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:16,代码来源:JUTestRouterTLS.java


示例20: createClientSSLListeners

import org.apache.mina.filter.SSLFilter; //导入依赖的package包/类
private void createClientSSLListeners() {
    // Start clients SSL unless it's been disabled.
    if (isClientSSLListenerEnabled()) {
        int port = getClientSSLListenerPort();
        String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm");
        if ("".equals(algorithm) || algorithm == null) {
            algorithm = "TLS";
        }
        try {
            // Create SocketAcceptor with correct number of processors
            sslSocketAcceptor = buildSocketAcceptor();
            // Customize Executor that will be used by processors to process incoming stanzas
            int eventThreads = JiveGlobals.getIntProperty("xmpp.client_ssl.processing.threads", 16);
            ExecutorFilter executorFilter = new ExecutorFilter();
            ThreadPoolExecutor eventExecutor = (ThreadPoolExecutor)executorFilter.getExecutor();
            final ThreadFactory originalThreadFactory = eventExecutor.getThreadFactory();
            ThreadFactory newThreadFactory = new ThreadFactory()
            {
                private final AtomicInteger threadId = new AtomicInteger( 0 );

                public Thread newThread( Runnable runnable )
                {
                    Thread t = originalThreadFactory.newThread( runnable );
                    t.setName("Old SSL executor thread - " + threadId.incrementAndGet() );
                    t.setDaemon( true );
                    return t;
                }
            };
            eventExecutor.setThreadFactory( newThreadFactory );
            eventExecutor.setCorePoolSize(eventThreads + 1);
            eventExecutor.setMaximumPoolSize(eventThreads + 1);
            eventExecutor.setKeepAliveTime(60, TimeUnit.SECONDS);

            sslSocketAcceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
            // Add the XMPP codec filter
            sslSocketAcceptor.getFilterChain().addFirst("xmpp", new ProtocolCodecFilter(new XMPPCodecFactory()));
            sslSocketAcceptor.getFilterChain().addFirst("threadModel", executorFilter);
            // Kill sessions whose outgoing queues keep growing and fail to send traffic
            sslSocketAcceptor.getFilterChain().addAfter("xmpp", "outCap", new StalledSessionsFilter());

            // Add the SSL filter now since sockets are "borned" encrypted in the old ssl method
            SSLContext sslContext = SSLContext.getInstance(algorithm);
            KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            keyFactory.init(SSLConfig.getKeyStore(), SSLConfig.getKeyPassword().toCharArray());
            TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            trustFactory.init(SSLConfig.getc2sTrustStore());

            sslContext.init(keyFactory.getKeyManagers(),
                    trustFactory.getTrustManagers(),
                    new java.security.SecureRandom());

            SSLFilter sslFilter = new SSLFilter(sslContext);
            if (JiveGlobals.getProperty("xmpp.client.cert.policy","disabled").equals("needed")) {
                sslFilter.setNeedClientAuth(true);
            }
            else if(JiveGlobals.getProperty("xmpp.client.cert.policy","disabled").equals("wanted")) {
                sslFilter.setWantClientAuth(true);
            }
            sslSocketAcceptor.getFilterChain().addFirst("tls", sslFilter);

        }
        catch (Exception e) {
            System.err.println("Error starting SSL XMPP listener on port " + port + ": " +
                    e.getMessage());
            Log.error(LocaleUtils.getLocalizedString("admin.error.ssl"), e);
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:69,代码来源:ConnectionManagerImpl.java



注:本文中的org.apache.mina.filter.SSLFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Document类代码示例发布时间:2022-05-23
下一篇:
Java Tuple4f类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap