664 lines · 26.6 KB · Java
RawDownload
     * <li> client authentication required     * <li> client authentication requested     * <li> no client authentication desired     * </ul>     * <P>     * Unlike {@link #setWantClientAuth(boolean)}, if this option is set and     * the client chooses not to provide authentication information     * about itself, <i>the negotiations will stop and the connection     * will be dropped</i>.     * <P>     * Calling this method overrides any previous setting made by     * this method or {@link #setWantClientAuth(boolean)}.     *     * @param   need set to true if client authentication is required,     *          or false if no client authentication is desired.     * @see #getNeedClientAuth()     * @see #setWantClientAuth(boolean)     * @see #getWantClientAuth()     * @see #setUseClientMode(boolean)     */    public abstract void setNeedClientAuth(boolean need);      /**     * Returns true if the socket will <i>require</i> client authentication.     * This option is only useful to sockets in the server mode.     *     * @return  true if client authentication is required,     *          or false if no client authentication is desired.     * @see #setNeedClientAuth(boolean)     * @see #setWantClientAuth(boolean)     * @see #getWantClientAuth()     * @see #setUseClientMode(boolean)     */    public abstract boolean getNeedClientAuth();      /**     * Configures the socket to <i>request</i> client authentication.     * This option is only useful for sockets in the server mode.     * <P>     * A socket's client authentication setting is one of the following:     * <ul>     * <li> client authentication required     * <li> client authentication requested     * <li> no client authentication desired     * </ul>     * <P>     * Unlike {@link #setNeedClientAuth(boolean)}, if this option is set and     * the client chooses not to provide authentication information     * about itself, <i>the negotiations will continue</i>.     * <P>     * Calling this method overrides any previous setting made by     * this method or {@link #setNeedClientAuth(boolean)}.     *     * @param   want set to true if client authentication is requested,     *          or false if no client authentication is desired.     * @see #getWantClientAuth()     * @see #setNeedClientAuth(boolean)     * @see #getNeedClientAuth()     * @see #setUseClientMode(boolean)     */    public abstract void setWantClientAuth(boolean want);      /**     * Returns true if the socket will <i>request</i> client authentication.     * This option is only useful for sockets in the server mode.     *     * @return  true if client authentication is requested,     *          or false if no client authentication is desired.     * @see #setNeedClientAuth(boolean)     * @see #getNeedClientAuth()     * @see #setWantClientAuth(boolean)     * @see #setUseClientMode(boolean)     */    public abstract boolean getWantClientAuth();      /**     * Controls whether new SSL sessions may be established by this socket.     * If session creations are not allowed, and there are no     * existing sessions to resume, there will be no successful     * handshaking.     *     * @param flag true indicates that sessions may be created; this     *          is the default.  false indicates that an existing session     *          must be resumed     * @see #getEnableSessionCreation()     */    public abstract void setEnableSessionCreation(boolean flag);      /**     * Returns true if new SSL sessions may be established by this socket.     *     * @return true indicates that sessions may be created; this     *          is the default.  false indicates that an existing session     *          must be resumed     * @see #setEnableSessionCreation(boolean)     */    public abstract boolean getEnableSessionCreation();     /**     * Returns the SSLParameters in effect for this SSLSocket.     * The ciphersuites and protocols of the returned SSLParameters     * are always non-null.     *     * @return the SSLParameters in effect for this SSLSocket.     * @since 1.6     */    public SSLParameters getSSLParameters() {        SSLParameters params = new SSLParameters();        params.setCipherSuites(getEnabledCipherSuites());        params.setProtocols(getEnabledProtocols());        if (getNeedClientAuth()) {            params.setNeedClientAuth(true);        } else if (getWantClientAuth()) {            params.setWantClientAuth(true);        }        return params;    }     /**     * Applies SSLParameters to this socket.     *     * <p>This means:     * <ul>     * <li>if <code>params.getCipherSuites()</code> is non-null,     *   <code>setEnabledCipherSuites()</code> is called with that value     * <li>if <code>params.getProtocols()</code> is non-null,     *   <code>setEnabledProtocols()</code> is called with that value     * <li>if <code>params.getNeedClientAuth()</code> or     *   <code>params.getWantClientAuth()</code> return <code>true</code>,     *   <code>setNeedClientAuth(true)</code> and     *   <code>setWantClientAuth(true)</code> are called, respectively;     *   otherwise <code>setWantClientAuth(false)</code> is called.     * </ul>     *     * @param params the parameters     * @throws IllegalArgumentException if the setEnabledCipherSuites() or     *    the setEnabledProtocols() call fails     * @since 1.6     */    public void setSSLParameters(SSLParameters params) {        String[] s;        s = params.getCipherSuites();        if (s != null) {            setEnabledCipherSuites(s);        }        s = params.getProtocols();        if (s != null) {            setEnabledProtocols(s);        }        if (params.getNeedClientAuth()) {            setNeedClientAuth(true);        } else if (params.getWantClientAuth()) {            setWantClientAuth(true);        } else {            setWantClientAuth(false);        }    } }

Lines 501–664 of 664. Previous lines