当前位置: 首页>>代码示例>>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;未经允许,请勿转载。