Package javax.net.ssl

Examples of javax.net.ssl.SSLSession


      return socket;
   }

   public void handshakeCompleted(HandshakeCompletedEvent event)
   {
      SSLSession session = event.getSession();
      String sessionID = null;
      byte[] id = session.getId();
      try
      {
         sessionID = new String(id, "UTF-8");
      }
      catch (UnsupportedEncodingException e)
View Full Code Here


        //DISABLED assert engine != null;
        synchronized (this) {
            int size;
            if (type == BufType.PACKET) {
                if (packet_buf_size == 0) {
                    SSLSession sess = engine.getSession();
                    packet_buf_size = sess.getPacketBufferSize();
                }
                if (len > packet_buf_size) {
                    packet_buf_size = len;
                }
                size = packet_buf_size;
            } else {
                if (app_buf_size == 0) {
                    SSLSession sess = engine.getSession();
                    app_buf_size = sess.getApplicationBufferSize();
                }
                if (len > app_buf_size) {
                    app_buf_size = len;
                }
                size = app_buf_size;
View Full Code Here

        //DISABLED assert engine != null;
        synchronized (this) {
            int size;
            if (type == BufType.PACKET) {
                if (packet_buf_size == 0) {
                    SSLSession sess = engine.getSession();
                    packet_buf_size = sess.getPacketBufferSize();
                }
                if (len > packet_buf_size) {
                    packet_buf_size = len;
                }
                size = packet_buf_size;
            } else {
                if (app_buf_size == 0) {
                    SSLSession sess = engine.getSession();
                    app_buf_size = sess.getApplicationBufferSize();
                }
                if (len > app_buf_size) {
                    app_buf_size = len;
                }
                size = app_buf_size;
View Full Code Here

    public Result authenticate(HttpExchange httpExchange) {
        // If we already have a Principal from the SSLSession no need to continue with
        // username / password authentication.
        if (httpExchange instanceof HttpsExchange) {
            HttpsExchange httpsExch = (HttpsExchange) httpExchange;
            SSLSession session = httpsExch.getSSLSession();
            if (session != null) {
                try {
                    Principal p = session.getPeerPrincipal();

                    return new Success(new HttpPrincipal(p.getName(), realm));

                } catch (SSLPeerUnverifiedException e) {
                }
View Full Code Here

    public Result authenticate(HttpExchange httpExchange) {
        // If we already have a Principal from the SSLSession no need to continue with
        // username / password authentication.
        if (httpExchange instanceof HttpsExchange) {
            HttpsExchange httpsExch = (HttpsExchange) httpExchange;
            SSLSession session = httpsExch.getSSLSession();
            if (session != null) {
                try {
                    Principal p = session.getPeerPrincipal();

                    return new Success(new HttpPrincipal(p.getName(), realm));

                } catch (SSLPeerUnverifiedException e) {
                }
View Full Code Here

     */
    @Override
    public Result authenticate(HttpExchange exchange) {
        if (exchange instanceof HttpsExchange) {
            HttpsExchange httpsExch = (HttpsExchange) exchange;
            SSLSession session = httpsExch.getSSLSession();
            if (session != null) {
                try {
                    Principal p = session.getPeerPrincipal();

                    return new Success(new HttpPrincipal(p.getName(), realm));

                } catch (SSLPeerUnverifiedException e) {
                }
View Full Code Here

        if (command instanceof ConnectionInfo) {
            ConnectionInfo connectionInfo = (ConnectionInfo)command;

            SSLSocket sslSocket = (SSLSocket)this.socket;

            SSLSession sslSession = sslSocket.getSession();

            X509Certificate[] clientCertChain;
            try {
                clientCertChain = (X509Certificate[])sslSession.getPeerCertificates();
            } catch (SSLPeerUnverifiedException e) {
                clientCertChain = null;
            }

            connectionInfo.setTransportContext(clientCertChain);
View Full Code Here

        ssl=sock;
    }

    public String getCipherSuite() throws IOException {
        // Look up the current SSLSession
        SSLSession session = ssl.getSession();
        if (session == null)
            return null;
        return session.getCipherSuite();
    }
View Full Code Here

    }

    public Object[] getPeerCertificateChain(boolean force)
  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 {
      try {
    jsseCerts = session.getPeerCertificateChain();
      } catch(Exception bex) {
    // ignore.
      }
            if (jsseCerts == null)
                jsseCerts = new X509Certificate[0];
      if(jsseCerts.length <= 0 && force) {
    session.invalidate();
    ssl.setNeedClientAuth(true);
    ssl.startHandshake();
    session = ssl.getSession();
    jsseCerts = session.getPeerCertificateChain();
    if(jsseCerts == null)
        jsseCerts = new X509Certificate[0];
      }
            x509Certs =
              new java.security.cert.X509Certificate[jsseCerts.length];
View Full Code Here

     * Copied from <code>org.apache.catalina.valves.CertificateValve</code>
     */
    public Integer getKeySize()
        throws IOException {
        // Look up the current SSLSession
        SSLSession session = ssl.getSession();
        SSLSupport.CipherData c_aux[]=ciphers;
        if (session == null)
            return null;
        Integer keySize = (Integer) session.getValue(KEY_SIZE_KEY);
        if (keySize == null) {
            int size = 0;
            String cipherSuite = session.getCipherSuite();
            for (int i = 0; i < c_aux.length; i++) {
                if (cipherSuite.indexOf(c_aux[i].phrase) >= 0) {
                    size = c_aux[i].keySize;
                    break;
                }
            }
            keySize = new Integer(size);
            session.putValue(KEY_SIZE_KEY, keySize);
        }
        return keySize;
    }
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.