⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sslsocketconnector.java

📁 是离开的肌肤了卡机是离开的就富利卡及是了的开发及拉考试及的福利科技阿斯利康的肌肤莱卡及时的离开福建阿斯顿发
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /* ------------------------------------------------------------ */    public String getProtocol()     {        return _protocol;    }    /* ------------------------------------------------------------ */    public String getProvider() {	return _provider;    }    /* ------------------------------------------------------------ */    public String getSecureRandomAlgorithm()     {        return (this._secureRandomAlgorithm);    }    /* ------------------------------------------------------------ */    public String getSslKeyManagerFactoryAlgorithm()     {        return (this._sslKeyManagerFactoryAlgorithm);    }    /* ------------------------------------------------------------ */    public String getSslTrustManagerFactoryAlgorithm()     {        return (this._sslTrustManagerFactoryAlgorithm);    }    /* ------------------------------------------------------------ */    public String getTruststore()    {        return _truststore;    }    /* ------------------------------------------------------------ */    public String getTruststoreType()    {        return _truststoreType;    }    /* ------------------------------------------------------------ */    public boolean getWantClientAuth()    {        return _wantClientAuth;    }    /* ------------------------------------------------------------ */    /**     * By default, we're confidential, given we speak SSL. But, if we've been told about an     * confidential port, and said port is not our port, then we're not. This allows separation of     * listeners providing INTEGRAL versus CONFIDENTIAL constraints, such as one SSL listener     * configured to require client certs providing CONFIDENTIAL, whereas another SSL listener not     * requiring client certs providing mere INTEGRAL constraints.     */    public boolean isConfidential(Request request)    {        final int confidentialPort = getConfidentialPort();        return confidentialPort == 0 || confidentialPort == request.getServerPort();    }        /* ------------------------------------------------------------ */    /**     * By default, we're integral, given we speak SSL. But, if we've been told about an integral     * port, and said port is not our port, then we're not. This allows separation of listeners     * providing INTEGRAL versus CONFIDENTIAL constraints, such as one SSL listener configured to     * require client certs providing CONFIDENTIAL, whereas another SSL listener not requiring     * client certs providing mere INTEGRAL constraints.     */    public boolean isIntegral(Request request)    {        final int integralPort = getIntegralPort();        return integralPort == 0 || integralPort == request.getServerPort();    }        /* ------------------------------------------------------------ */    /**     * @param addr The {@link SocketAddress address} that this server should listen on      * @param backlog See {@link ServerSocket#bind(java.net.SocketAddress, int)}     * @return A new {@link ServerSocket socket object} bound to the supplied address with all other     * settings as per the current configuration of this connector.      * @see #setWantClientAuth     * @see #setNeedClientAuth     * @see #setCipherSuites     * @exception IOException     */    /* ------------------------------------------------------------ */    protected ServerSocket newServerSocket(String host, int port,int backlog) throws IOException    {        SSLServerSocketFactory factory = null;        SSLServerSocket socket = null;        try        {            factory = createFactory();            socket = (SSLServerSocket) (host==null?                            factory.createServerSocket(port,backlog):                            factory.createServerSocket(port,backlog,InetAddress.getByName(host)));            if (_wantClientAuth)                socket.setWantClientAuth(_wantClientAuth);            if (_needClientAuth)                socket.setNeedClientAuth(_needClientAuth);            if (_excludeCipherSuites != null && _excludeCipherSuites.length >0)             {                List excludedCSList = Arrays.asList(_excludeCipherSuites);                String[] enabledCipherSuites = socket.getEnabledCipherSuites();            	List enabledCSList = new ArrayList(Arrays.asList(enabledCipherSuites));            	Iterator exIter = excludedCSList.iterator();                while (exIter.hasNext())            	{            	    String cipherName = (String)exIter.next();                    if (enabledCSList.contains(cipherName))                    {                        enabledCSList.remove(cipherName);                    }            	}                enabledCipherSuites = (String[])enabledCSList.toArray(new String[enabledCSList.size()]);                socket.setEnabledCipherSuites(enabledCipherSuites);            }                    }        catch (IOException e)        {            throw e;        }        catch (Exception e)        {            Log.warn(Log.EXCEPTION, e);            throw new IOException("Could not create JsseListener: " + e.toString());        }        return socket;    }    /* ------------------------------------------------------------ */    /**      * @author Tony Jiang     */    public void setExcludeCipherSuites(String[] cipherSuites) {        this._excludeCipherSuites = cipherSuites;    }    /* ------------------------------------------------------------ */    public void setKeyPassword(String password)    {        _keyPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null);    }    /* ------------------------------------------------------------ */    /**     * @param keystore The resource path to the keystore, or null for built in keystores.     */    public void setKeystore(String keystore)    {        _keystore = keystore;    }    /* ------------------------------------------------------------ */    public void setKeystoreType(String keystoreType)     {        _keystoreType = keystoreType;    }    /* ------------------------------------------------------------ */    /**     * Set the value of the needClientAuth property     *      * @param needClientAuth true iff we require client certificate authentication.     */    public void setNeedClientAuth(boolean needClientAuth)    {        _needClientAuth = needClientAuth;    }        /* ------------------------------------------------------------ */    public void setPassword(String password)    {        _password = Password.getPassword(PASSWORD_PROPERTY,password,null);    }        /* ------------------------------------------------------------ */    public void setTrustPassword(String password)    {        _trustPassword = Password.getPassword(PASSWORD_PROPERTY,password,null);    }    /* ------------------------------------------------------------ */    public void setProtocol(String protocol)     {        _protocol = protocol;    }    /* ------------------------------------------------------------ */    public void setProvider(String _provider) {	this._provider = _provider;    }    /* ------------------------------------------------------------ */    public void setSecureRandomAlgorithm(String algorithm)     {        this._secureRandomAlgorithm = algorithm;    }    /* ------------------------------------------------------------ */    public void setSslKeyManagerFactoryAlgorithm(String algorithm)     {        this._sslKeyManagerFactoryAlgorithm = algorithm;    }        /* ------------------------------------------------------------ */    public void setSslTrustManagerFactoryAlgorithm(String algorithm)     {        this._sslTrustManagerFactoryAlgorithm = algorithm;    }    public void setTruststore(String truststore)    {        _truststore = truststore;    }        public void setTruststoreType(String truststoreType)    {        _truststoreType = truststoreType;    }    /* ------------------------------------------------------------ */    /**     * Set the value of the _wantClientAuth property. This property is used when     * {@link #newServerSocket(SocketAddress, int) opening server sockets}.     *      * @param wantClientAuth true iff we want client certificate authentication.     * @see SSLServerSocket#setWantClientAuth     */    public void setWantClientAuth(boolean wantClientAuth)    {        _wantClientAuth = wantClientAuth;    }    /**     * Set the time in milliseconds for so_timeout during ssl handshaking     * @param msec a non-zero value will be used to set so_timeout during     * ssl handshakes. A zero value means the maxIdleTime is used instead.     */    public void setHandshakeTimeout (int msec)    {        _handshakeTimeout = msec;    }            public int getHandshakeTimeout ()    {        return _handshakeTimeout;    }    /**     * Simple bundle of information that is cached in the SSLSession. Stores the effective keySize     * and the client certificate chain.     */    private class CachedInfo    {        private X509Certificate[] _certs;        private Integer _keySize;        CachedInfo(Integer keySize, X509Certificate[] certs)        {            this._keySize = keySize;            this._certs = certs;        }        X509Certificate[] getCerts()        {            return _certs;        }        Integer getKeySize()        {            return _keySize;        }    }            public class SslConnection extends Connection    {        public SslConnection(Socket socket) throws IOException        {            super(socket);        }                public void run()        {            try            {                int handshakeTimeout = getHandshakeTimeout();                int oldTimeout = _socket.getSoTimeout();                if (handshakeTimeout > 0)                                _socket.setSoTimeout(handshakeTimeout);                ((SSLSocket)_socket).startHandshake();                if (handshakeTimeout>0)                    _socket.setSoTimeout(oldTimeout);                super.run();            }            catch (SSLException e)            {                Log.warn(e);                 try{close();}                catch(IOException e2){Log.ignore(e2);}            }            catch (IOException e)            {                Log.debug(e);                try{close();}                catch(IOException e2){Log.ignore(e2);}            }         }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -