Package org.apache.mina.filter.ssl

Examples of org.apache.mina.filter.ssl.SslFilter


        SslConfiguration ssl = session.getListener().getSslConfiguration();

        if (ssl != null) {
            session.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE);

            SslFilter sslFilter = new SslFilter(ssl.getSSLContext());
            if (ssl.getClientAuth() == ClientAuth.NEED) {
                sslFilter.setNeedClientAuth(true);
            } else if (ssl.getClientAuth() == ClientAuth.WANT) {
                sslFilter.setWantClientAuth(true);
            }

            // note that we do not care about the protocol, we allow both types
            // and leave it to the SSL handshake to determine the protocol to
            // use. Thus the type argument is ignored.

            if (ssl.getEnabledCipherSuites() != null) {
                sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
            }

            session.getFilterChain().addFirst(SSL_SESSION_FILTER_NAME,
                    sslFilter);
View Full Code Here


            acceptor.getFilterChain().addLast("mdcFilter2", mdcFilter);
            acceptor.getFilterChain().addLast("logger", new FtpLoggingFilter());
   
            if (isImplicitSsl()) {
                SslConfiguration ssl = getSslConfiguration();
                SslFilter sslFilter;
                try {
                    sslFilter = new SslFilter(ssl.getSSLContext());
                } catch (GeneralSecurityException e) {
                    throw new FtpServerConfigurationException("SSL could not be initialized, check configuration");
                }
   
                if (ssl.getClientAuth() == ClientAuth.NEED) {
                    sslFilter.setNeedClientAuth(true);
                } else if (ssl.getClientAuth() == ClientAuth.WANT) {
                    sslFilter.setWantClientAuth(true);
                }
   
                if (ssl.getEnabledCipherSuites() != null) {
                    sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
                }
   
                acceptor.getFilterChain().addFirst("sslFilter", sslFilter);
            }
   
View Full Code Here

  return (Date) getAttribute(ATTRIBUTE_LAST_ACCESS_TIME);
    }

    public Certificate[] getClientCertificates() {
  if (getFilterChain().contains(SslFilter.class)) {
      SslFilter sslFilter = (SslFilter) getFilterChain().get(
        SslFilter.class);

      SSLSession sslSession = sslFilter.getSslSession(this);

      if (sslSession != null) {
    try {
        return sslSession.getPeerCertificates();
    } catch (SSLPeerUnverifiedException e) {
View Full Code Here

        try
        {
            SSLContext sslContext = SSLContext.getInstance( config.getSslProtocol() );
            sslContext.init( config.getKeyManagers(), config.getTrustManagers(), config.getSecureRandom() );

            SslFilter sslFilter = new SslFilter( sslContext, true );
            sslFilter.setUseClientMode( true );
            sslFilter.setEnabledCipherSuites( config.getEnabledCipherSuites() );

            // for LDAPS
            if ( ldapSession == null )
            {
                connector.getFilterChain().addFirst( SSL_FILTER_KEY, sslFilter );
View Full Code Here

    private SslFilter getSSLFilter() {
  try {
      SSLContext sslcontext = SSLContext.getInstance("SSL");
      sslcontext.init(null, new TrustManager[] { new DummyX509TrustManager() }, new java.security.SecureRandom());
      SslFilter sslfilter = new SslFilter(sslcontext);
      sslfilter.setUseClientMode(true);
      return sslfilter;
  } catch (Exception e) {
      throw new IllegalStateException(e);
  }
    }
View Full Code Here

    public void handleExtendedOperation( LdapSession session, ExtendedRequest req ) throws Exception
    {
        LOG.info( "Handling StartTLS request." );

        IoFilterChain chain = session.getIoSession().getFilterChain();
        SslFilter sslFilter = ( SslFilter ) chain.get( "sslFilter" );
       
        if ( sslFilter == null )
        {
            sslFilter = new SslFilter( sslContext );

            if ( ( cipherSuites != null ) && !cipherSuites.isEmpty() )
            {
                sslFilter.setEnabledCipherSuites( cipherSuites.toArray( new String[cipherSuites.size()] ) );
            }

            chain.addFirst( "sslFilter", sslFilter );
        }
        else
        {
            sslFilter.startSsl( session.getIoSession() );
        }

        ExtendedResponseDecorator<ExtendedResponse> res = new ExtendedResponseDecorator<ExtendedResponse>(
            LdapApiServiceFactory.getSingleton(), new StartTlsResponseImpl( req.getMessageId() ) );
        LdapResult result = res.getLdapResult();
View Full Code Here

        {
            throw new LdapException( I18n.err( I18n.ERR_683 ), e );
        }

        DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
        SslFilter sslFilter = new SslFilter( sslCtx );

        List<String> cipherSuites = server.getEnabledCipherSuites();
        if( ( cipherSuites != null ) && !cipherSuites.isEmpty() )
        {
            sslFilter.setEnabledCipherSuites( cipherSuites.toArray( new String[cipherSuites.size()] ) );
        }
       
        sslFilter.setWantClientAuth( true );
        chain.addLast( "sslFilter", sslFilter );
        return chain;
    }
View Full Code Here

        try
        {
            SSLContext sslContext = SSLContext.getInstance( config.getSslProtocol() );
            sslContext.init( config.getKeyManagers(), config.getTrustManagers(), config.getSecureRandom() );

            SslFilter sslFilter = new SslFilter( sslContext, true );
            sslFilter.setUseClientMode( true );
            sslFilter.setEnabledCipherSuites( config.getEnabledCipherSuites() );

            // for LDAPS
            if ( ldapSession == null )
            {
                connector.getFilterChain().addFirst( SSL_FILTER_KEY, sslFilter );
View Full Code Here

        if (minaLogger) {
            connector.getFilterChain().addLast("logger", new LoggingFilter());
        }
        appendIoFiltersToChain(filters, connector.getFilterChain());
        if (configuration.getSslContextParameters() != null) {
            connector.getFilterChain().addFirst("sslFilter", new SslFilter(configuration.getSslContextParameters().createSSLContext(), configuration.isAutoStartTls()));
        }
        configureCodecFactory("Mina2Producer", connector);
        connector.setConnectTimeoutMillis(timeout);
    }
View Full Code Here

    public void write(Stanza stanza) {
        if (switchToTLS) {
            minaSession.suspendRead();
            minaSession.suspendWrite();
            SslFilter filter = new SslFilter(getServerRuntimeContext().getSslContext());
            filter.setUseClientMode(false);
            minaSession.getFilterChain().addFirst("sslFilter", filter);
            minaSession.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.TRUE);
            minaSession.setAttribute(SslFilter.USE_NOTIFICATION, Boolean.TRUE);
            minaSession.resumeWrite();
            minaSession.resumeRead();
View Full Code Here

TOP

Related Classes of org.apache.mina.filter.ssl.SslFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.