當前位置: 首頁>>代碼示例>>Java>>正文


Java SSLSocket.getInputStream方法代碼示例

本文整理匯總了Java中javax.net.ssl.SSLSocket.getInputStream方法的典型用法代碼示例。如果您正苦於以下問題:Java SSLSocket.getInputStream方法的具體用法?Java SSLSocket.getInputStream怎麽用?Java SSLSocket.getInputStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.net.ssl.SSLSocket的用法示例。


在下文中一共展示了SSLSocket.getInputStream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doClientSide

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
void doClientSide() throws Exception {

        /*
         * Wait for server to get started.
         */
        while (!serverReady) {
            Thread.sleep(50);
        }

        SSLSocketFactory sslsf =
            (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslSocket = (SSLSocket)
            sslsf.createSocket("localhost", serverPort);

        // enable TLSv1.1 only
        sslSocket.setEnabledProtocols(new String[] {"TLSv1.1"});

        InputStream sslIS = sslSocket.getInputStream();
        OutputStream sslOS = sslSocket.getOutputStream();

        sslOS.write('B');
        sslOS.flush();
        sslIS.read();

        sslSocket.close();
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:EmptyCertificateAuthorities.java

示例2: ArticlePusher

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
public ArticlePusher(Socket socket, boolean TLSEnabled, String host) throws IOException{
	//this.host = host;
	
	this.socket = FeedManager.getHelloFromServer(socket, TLSEnabled, host, charset);
	if (TLSEnabled){
		SSLSocket sslsocket = (SSLSocket) this.socket;
		this.out = sslsocket.getOutputStream();//->Output to remote NNTP server
		this.inr = new BufferedReader(new InputStreamReader( //<-INPUT from remote NNTP server
				sslsocket.getInputStream(), charset));
	}else{
		this.out = socket.getOutputStream();//->Output to remote NNTP server
		this.inr = new BufferedReader(new InputStreamReader( //<-INPUT from remote NNTP server
				socket.getInputStream(), charset));
	}
	//TODO:check capabilities for IHAVE
}
 
開發者ID:Anoncheg1,項目名稱:dibd,代碼行數:17,代碼來源:ArticlePusher.java

示例3: check_nickname

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
public boolean check_nickname(String nickname) throws ClassNotFoundException
{
    //connect to Registrar to check if nickname is unique
    boolean check = false;
    try 
    {
        
        SSLSocket sslSocket=Client.get_SSLSock();
        //Socket s1 = new Socket("localhost", 5999);
        ObjectOutputStream out = new ObjectOutputStream(sslSocket.getOutputStream());
        ObjectInputStream in = new ObjectInputStream(sslSocket.getInputStream());

        out.writeObject(new Message(nickname, "null"));//here goes nickname
        out.flush();
        
        check = (boolean)in.readObject();

        sslSocket.close();
    } catch (IOException ex) {
        Logger.getLogger(NewConnection.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    return check;
}
 
開發者ID:georgemakrakis,項目名稱:TrackMeIfYouCanChat,代碼行數:25,代碼來源:Nickname.java

示例4: doServerSide

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
void doServerSide() throws Exception {
    SSLServerSocketFactory sslssf =
        (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket sslServerSocket =
        (SSLServerSocket) sslssf.createServerSocket(serverPort);

    serverPort = sslServerSocket.getLocalPort();

    /*
     * Signal Client, we're ready for his connect.
     */
    serverReady = true;

    SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
    InputStream sslIS = sslSocket.getInputStream();
    OutputStream sslOS = sslSocket.getOutputStream();

    sslIS.read();
    sslOS.write('A');
    sslOS.flush();

    sslSocket.close();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:GenericBlockCipher.java

示例5: runClientApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Override
protected void runClientApplication(SSLSocket socket) throws Exception {
    String ciphers[] = {
            "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
            "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
            "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
            "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
    socket.setEnabledCipherSuites(ciphers);
    socket.setUseClientMode(true);

    InputStream sslIS = socket.getInputStream();
    OutputStream sslOS = socket.getOutputStream();

    sslOS.write(280);
    sslOS.flush();
    sslIS.read();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:UseStrongDHSizes.java

示例6: sslNegotiation

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
/**
 * SSL/TLS negotiation. Acquires an SSL socket of a control
 * connection and carries out handshake processing.
 * @throws java.io.IOException If server negotiation fails
 */
protected void sslNegotiation() throws IOException {
    plainSocket = _socket_;
    initSslContext();

    SSLSocketFactory ssf = context.getSocketFactory();
    String ip = _socket_.getInetAddress().getHostAddress();
    int port = _socket_.getPort();
    SSLSocket socket =
        (SSLSocket) ssf.createSocket(_socket_, ip, port, false);
    socket.setEnableSessionCreation(isCreation);
    socket.setUseClientMode(isClientMode);
    // server mode
    if (!isClientMode) {
        socket.setNeedClientAuth(isNeedClientAuth);
        socket.setWantClientAuth(isWantClientAuth);
    }

    if (protocols != null) {
        socket.setEnabledProtocols(protocols);
    }
    if (suites != null) {
        socket.setEnabledCipherSuites(suites);
    }
    socket.startHandshake();

    _socket_ = socket;
    _controlInput_ = new BufferedReader(new InputStreamReader(
            socket .getInputStream(), getControlEncoding()));
    _controlOutput_ = new BufferedWriter(new OutputStreamWriter(
            socket.getOutputStream(), getControlEncoding()));
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:37,代碼來源:FTPSClient.java

示例7: runServerApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Override
protected void runServerApplication(SSLSocket socket) throws Exception {
    InputStream sslIS = socket.getInputStream();
    OutputStream sslOS = socket.getOutputStream();

    sslIS.read();
    sslOS.write(85);
    sslOS.flush();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:SSLSessionNulls.java

示例8: doClientSide

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
void doClientSide() throws Exception {

        /*
         * Wait for server to get started.
         */
        while (!serverReady) {
            Thread.sleep(50);
        }

        SSLSocketFactory sslsf =
            (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslSocket = (SSLSocket)
            sslsf.createSocket("localhost", serverPort);

        // enable TLSv1.1 only
        sslSocket.setEnabledProtocols(new String[] {"TLSv1.1"});

        // enable a block cipher
        sslSocket.setEnabledCipherSuites(
            new String[] {"TLS_RSA_WITH_AES_128_CBC_SHA"});

        InputStream sslIS = sslSocket.getInputStream();
        OutputStream sslOS = sslSocket.getOutputStream();

        sslOS.write('B');
        sslOS.flush();
        sslIS.read();

        sslSocket.close();
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:GenericBlockCipher.java

示例9: runServerApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
protected void runServerApplication(SSLSocket socket) throws Exception {
    // here comes the test logic
    InputStream sslIS = socket.getInputStream();
    OutputStream sslOS = socket.getOutputStream();

    sslIS.read();
    sslOS.write(85);
    sslOS.flush();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:SSLSocketTemplate.java

示例10: runClientApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
protected void runClientApplication(SSLSocket socket) throws Exception {
    InputStream sslIS = socket.getInputStream();
    OutputStream sslOS = socket.getOutputStream();

    sslOS.write(280);
    sslOS.flush();
    sslIS.read();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:SSLSocketTemplate.java

示例11: doClientSide

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
void doClientSide() throws Exception {

        /*
         * Wait for server to get started.
         */
        while (!serverReady) {
            Thread.sleep(50);
        }

        SSLSocketFactory sslsf =
            (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslSocket = (SSLSocket)
            sslsf.createSocket("localhost", serverPort);

        // enable TLSv1.1 only
        sslSocket.setEnabledProtocols(new String[] {"TLSv1.1"});

        // enable a stream cipher
        sslSocket.setEnabledCipherSuites(
            new String[] {"SSL_RSA_WITH_RC4_128_MD5"});

        InputStream sslIS = sslSocket.getInputStream();
        OutputStream sslOS = sslSocket.getOutputStream();

        sslOS.write('B');
        sslOS.flush();
        sslIS.read();

        sslSocket.close();
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:GenericStreamCipher.java

示例12: doServerSide

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
void doServerSide() throws Exception {
    SSLServerSocketFactory sslssf =
        (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket sslServerSocket =
        (SSLServerSocket) sslssf.createServerSocket(serverPort);

    serverPort = sslServerSocket.getLocalPort();

    /*
     * Signal Client, we're ready for his connect.
     */
    serverReady = true;

    SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
    InputStream sslIS = sslSocket.getInputStream();
    OutputStream sslOS = sslSocket.getOutputStream();

    boolean interrupted = false;
    try {
        sslIS.read();
        sslOS.write('A');
        sslOS.flush();
    } catch (IOException ioe) {
        // get the expected exception
        interrupted = true;
    } finally {
        sslSocket.close();
    }

    if (!interrupted) {
        throw new SSLHandshakeException(
            "A weak cipher suite is negotiated, " +
            "TLSv1.1 must not negotiate the exportable cipher suites.");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:ExportableBlockCipher.java

示例13: runServerApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Override
protected void runServerApplication(SSLSocket socket) throws Exception {
    String response = "Proxy authentication for tunneling succeeded ..";
    DataOutputStream out = new DataOutputStream(socket.getOutputStream());
    try {
        BufferedReader in = new BufferedReader(
                new InputStreamReader(socket.getInputStream()));

        // read the request
        readRequest(in);

        // retrieve bytecodes
        byte[] bytecodes = response.getBytes(US_ASCII);

        // send bytecodes in response (assumes HTTP/1.0 or later)
        out.writeBytes("HTTP/1.0 200 OK\r\n");
        out.writeBytes("Content-Length: " + bytecodes.length + "\r\n");
        out.writeBytes("Content-Type: text/html\r\n\r\n");
        out.write(bytecodes);
        out.flush();
    } catch (IOException e) {
        // write out error response
        out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n");
        out.writeBytes("Content-Type: text/html\r\n\r\n");
        out.flush();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:ProxyAuthTest.java

示例14: runServerApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Override
protected void runServerApplication(SSLSocket socket) throws Exception {
    InputStream sslIS = socket.getInputStream();
    sslIS.read();
    BufferedWriter bw = new BufferedWriter(
            new OutputStreamWriter(socket.getOutputStream()));
    bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
    bw.flush();
    socket.getSession().invalidate();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:ServerIdentityTest.java

示例15: testRenegotiateFail

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Test
public void testRenegotiateFail() throws Exception {

    // If RFC5746 is supported, renegotiation will always work (and will
    // always be secure)
    if (TesterSupport.RFC_5746_SUPPORTED) {
        return;
    }

    Tomcat tomcat = getTomcatInstance();

    File appDir = new File(getBuildDirectory(), "webapps/examples");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());

    TesterSupport.initSsl(tomcat);

    // Default - MITM attack prevented

    tomcat.start();
    SSLContext sslCtx = SSLContext.getInstance("TLS");
    sslCtx.init(null, TesterSupport.getTrustManagers(), null);
    SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
    SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", getPort());

    socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
        @Override
        public void handshakeCompleted(HandshakeCompletedEvent event) {
            handshakeDone = true;
        }
    });

    OutputStream os = socket.getOutputStream();
    os.write("GET /examples/servlets/servlet/HelloWorldExample HTTP/1.0\n".getBytes());
    os.flush();


    InputStream is = socket.getInputStream();

    // Make sure the NIO connector has read the request before the handshake
    Thread.sleep(100);

    socket.startHandshake();

    os = socket.getOutputStream();

    try {
        os.write("Host: localhost\n\n".getBytes());
    } catch (IOException ex) {
        ex.printStackTrace();
        fail("Re-negotiation failed");
    }
    Reader r = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(r);
    String line = br.readLine();
    while (line != null) {
        // For testing System.out.println(line);
        line = br.readLine();
    }

    if (!handshakeDone) {
        // success - we timed-out without handshake
        return;
    }

    fail("Re-negotiation worked");
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:68,代碼來源:TestSsl.java


注:本文中的javax.net.ssl.SSLSocket.getInputStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。