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


Java SSLSocket.getOutputStream方法代碼示例

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


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

示例1: connect

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
void connect() throws IOException{
	this.socket = FeedManager.createSocket(proxy, host, port);
	socket.setSoTimeout(3000);
	this.socket = FeedManager.getHelloFromServer(socket, TLSEnabled, host, charset);
	if (TLSEnabled){
		
		SSLSocket sslsocket = (SSLSocket) this.socket;
		//system.out Log.get().severe("Socket:"+socket.getClass().getName());
		//new encrypted streams
		this.out = new PrintWriter(new OutputStreamWriter(sslsocket.getOutputStream(), this.charset));
		this.in = new BufferedReader(new InputStreamReader(sslsocket.getInputStream(), this.charset));
		
		this.instream = sslsocket.getInputStream();
		
	}else{
		this.out = new PrintWriter(new OutputStreamWriter(this.socket.getOutputStream(), this.charset));
		//this.in = new BufferedReader(new InputStreamReader(this.socket.getInputStream(), this.charset));
		
		this.instream = socket.getInputStream();

	}
}
 
開發者ID:Anoncheg1,項目名稱:dibd,代碼行數:23,代碼來源:ArticlePuller.java

示例2: 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

示例3: runServerApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Override
protected void runServerApplication(SSLSocket socket) throws Exception {
    String ciphers[] = {
            "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
            "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
            "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" };
    socket.setEnabledCipherSuites(ciphers);
    socket.setWantClientAuth(true);

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

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

示例4: 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

示例5: doServerSide

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

    // require client authentication.
    sslServerSocket.setNeedClientAuth(true);

    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,代碼行數:26,代碼來源:EmptyCertificateAuthorities.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: 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

示例8: 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,代碼來源:ExportableStreamCipher.java

示例9: 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

示例10: Sender

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
public Sender(SSLSocket ss){ //Port to create server on
  try{
    out = new PrintWriter(ss.getOutputStream(), true);
    in = new BufferedReader(new InputStreamReader(ss.getInputStream()));
  }
  catch(Exception e){
    e.printStackTrace();
  }

  System.out.println("\033[1m\033[32mSender socket successfully set up\033[0m");
}
 
開發者ID:jeffreyshen19,項目名稱:Virtual-IoT-Server,代碼行數:12,代碼來源:Sender.java

示例11: runClientApplication

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
@Override
protected void runClientApplication(SSLSocket socket) throws Exception {
    String ciphers[] = {
            "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
            "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5" };
    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,代碼行數:16,代碼來源:AnonCipherWithWantClientAuth.java

示例12: NewConnection

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
public NewConnection(String nickname,String i2p_dest)
{
    try 
    {
        // Create socket
        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, i2p_dest));//here goes nickname and i2p_dest
        out.flush();
        
        ar1 = (ArrayList<Message>) in.readObject();//get users from server
        for (int i = 0; i < ar1.size(); i++) {//remove curent user from list
            if (ar1.get(i).get_i2p_dest().equals(i2p_dest)) {
                ar1.remove(i);
            }
        }
        System.out.println("New Connection");
        System.out.print("Users:");
        for (int i = 0; i < ar1.size(); i++) {
            System.out.print(" " + ar1.get(i).get_nickname());
        }
        System.out.println();
        Client.registered=true;
        sslSocket.close();
        
        Client.model1.removeAllElements();//remove users
        for (int i = 0; i < ar1.size(); i++) {//insert active users
            Client.model1.addElement(ar1.get(i).get_nickname());
        }
        Client.users=ar1;
    } catch (IOException | ClassNotFoundException ex) {
        Logger.getLogger(NewConnection.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:georgemakrakis,項目名稱:TrackMeIfYouCanChat,代碼行數:38,代碼來源:NewConnection.java

示例13: 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

示例14: doServerSide

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

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

    SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept();
    try {
        sslSocket.setSoTimeout(5000);
        sslSocket.setSoLinger(true, 5);

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

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

        throw new Exception("EC curve secp224k1 should be disabled");
    } catch (SSLHandshakeException she) {
        // expected exception: no cipher suites in common
        System.out.println("Expected exception: " + she);
    } finally {
        sslSocket.close();
        sslServerSocket.close();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:ECCurvesconstraints.java

示例15: doClientSide

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

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

        SSLContext context = generateSSLContext(true);
        SSLSocketFactory sslsf = context.getSocketFactory();

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

        try {
            sslSocket.setSoTimeout(5000);
            sslSocket.setSoLinger(true, 5);

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

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

            throw new Exception("EC curve secp224k1 should be disabled");
        } catch (SSLHandshakeException she) {
            // expected exception: Received fatal alert
            System.out.println("Expected exception: " + she);
        } finally {
            sslSocket.close();
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:35,代碼來源:ECCurvesconstraints.java


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