Package javax.net.ssl

Examples of javax.net.ssl.SSLSession


    }

    public String getSessionId()
        throws IOException {
        // Look up the current SSLSession
        SSLSession session = ssl.getSession();
        if (session == null)
            return null;
        // Expose ssl_session (getId)
        byte [] ssl_session = session.getId();
        if ( ssl_session == null)
            return null;
        StringBuffer buf=new StringBuffer("");
        for(int x=0; x<ssl_session.length; x++) {
            String digit=Integer.toHexString((int)ssl_session[x]);
View Full Code Here


    public Object[] getPeerCertificateChain()
    throws IOException
    {
        // Look up the current SSLSession
        SSLSession session = ssl.getSession();
        if (session == null)
            return null;

        // Convert JSSE's certificate format to the ones we need
        X509Certificate jsseCerts[] = null;
        java.security.cert.X509Certificate x509Certs[] = null;
        try {
            jsseCerts = session.getPeerCertificateChain();
            if (jsseCerts == null)
                jsseCerts = new X509Certificate[0];
            x509Certs =
              new java.security.cert.X509Certificate[jsseCerts.length];
            for (int i = 0; i < x509Certs.length; i++) {
View Full Code Here

          throws IOException {
        if(host == null) {
            throw new NullPointerException("host to verify is null");
        }

        SSLSession session = ssl.getSession();
        if(session == null) {
            // In our experience this only happens under IBM 1.4.x when
            // spurious (unrelated) certificates show up in the server'
            // chain.  Hopefully this will unearth the real problem:
            final InputStream in = ssl.getInputStream();
            in.available();
            /*
              If you're looking at the 2 lines of code above because
              you're running into a problem, you probably have two
              options:

                #1.  Clean up the certificate chain that your server
                     is presenting (e.g. edit "/etc/apache2/server.crt"
                     or wherever it is your server's certificate chain
                     is defined).

                                           OR

                #2.   Upgrade to an IBM 1.5.x or greater JVM, or switch
                      to a non-IBM JVM.
            */

            // If ssl.getInputStream().available() didn't cause an
            // exception, maybe at least now the session is available?
            session = ssl.getSession();
            if(session == null) {
                // If it's still null, probably a startHandshake() will
                // unearth the real problem.
                ssl.startHandshake();

                // Okay, if we still haven't managed to cause an exception,
                // might as well go for the NPE.  Or maybe we're okay now?
                session = ssl.getSession();
            }
        }

        final Certificate[] certs = session.getPeerCertificates();
        final X509Certificate x509 = (X509Certificate) certs[0];
        verify(host, x509);
    }
View Full Code Here

    {
        final String hostName = address.getHostName();
        final SSLSocket sslSocket = (SSLSocket)
            m_factory.createSocket( bareSocket, hostName, port, true );
        sslSocket.startHandshake();
        final SSLSession session = sslSocket.getSession();
        final String DN =
            session.getPeerCertificateChain()[ 0 ].getSubjectDN().getName();
        final String CN = getCN( DN );
        if( !hostName.equals( CN ) )
        {
            final String message = "Host name mismatch, expected '" +
                hostName + "' recevied DN is " + DN;
            throw new IOException( message );
        }
        if( getLogger().isDebugEnabled() )
        {
            final String message = "DN of the server " + DN;
            getLogger().debug( message );
            final String message2 = "Session id " +
                bytesToString( session.getId() );
            getLogger().debug( message2 );
        }
        return sslSocket;
    }
View Full Code Here

                exchange.setRequestMethod(new HttpString(exchange.getRequestHeaders().getFirst(METHOD)));
                exchange.getRequestHeaders().add(Headers.HOST, exchange.getRequestHeaders().getFirst(HOST));
                final String path = exchange.getRequestHeaders().getFirst(PATH);
                setRequestPath(exchange, path, encoding, allowEncodingSlash, decodeBuffer);

                SSLSession session = channel.getSslSession();
                if(session != null) {
                    connection.setSslSessionInfo(new SpdySslSessionInfo(channel));
                }

                Connectors.executeRootHandler(rootHandler, exchange);
View Full Code Here

   {
      Logger log = Logger.getLogger(ClientSocketFactory.class);
      if( log.isTraceEnabled() )
      {
         String cipher = event.getCipherSuite();
         SSLSession session = event.getSession();
         String peerHost = session.getPeerHost();
         log.debug("SSL handshakeCompleted, cipher="+cipher
            +", peerHost="+peerHost);
      }

      /* See if there is a HANDSHAKE_COMPLETE_LISTENER. This is not done from
View Full Code Here

   }

   public void handshakeCompleted(HandshakeCompletedEvent event)
   {
      String cipher = event.getCipherSuite();
      SSLSession session = event.getSession();
      String peerHost = session.getPeerHost();
      Certificate[] localCerts = event.getLocalCertificates();
      Certificate[] peerCerts = null;
      try
      {
         peerCerts = event.getPeerCertificates();
View Full Code Here

      return ssf;
   }

   public static synchronized SSLSession getSSLSession(String sessionID)
   {
      SSLSession session = (SSLSession) sessionMap.get(sessionID);
      return session;
   }
View Full Code Here

      SSLSession session = (SSLSession) sessionMap.get(sessionID);
      return session;
   }
   static synchronized SSLSession putSSLSession(String sessionID, SSLSession session)
   {
      SSLSession prevSession = (SSLSession) sessionMap.put(sessionID, session);
      return prevSession;
   }
View Full Code Here

      SSLSession prevSession = (SSLSession) sessionMap.put(sessionID, session);
      return prevSession;
   }
   static synchronized SSLSession removeSSLSession(String sessionID)
   {
      SSLSession session = (SSLSession) sessionMap.remove(sessionID);
      return session;
   }
View Full Code Here

TOP

Related Classes of javax.net.ssl.SSLSession

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.