Package org.bouncycastle.tls
Class TlsClientProtocol
- java.lang.Object
-
- org.bouncycastle.tls.TlsProtocol
-
- org.bouncycastle.tls.TlsClientProtocol
-
- All Implemented Interfaces:
TlsCloseable
public class TlsClientProtocol extends TlsProtocol
-
-
Field Summary
Fields Modifier and Type Field Description protected TlsAuthenticationauthenticationprotected CertificateRequestcertificateRequestprotected CertificateStatuscertificateStatusprotected java.util.HashtableclientAgreementsprotected TlsKeyExchangekeyExchangeprotected TlsClienttlsClient-
Fields inherited from class org.bouncycastle.tls.TlsProtocol
ADS_MODE_0_N, ADS_MODE_0_N_FIRSTONLY, ADS_MODE_1_Nsub1, allowCertificateStatus, blocking, clientExtensions, connection_state, CS_CERTIFICATE_REQUEST, CS_CERTIFICATE_STATUS, CS_CERTIFICATE_VERIFY, CS_CLIENT_CERTIFICATE, CS_CLIENT_FINISHED, CS_CLIENT_HELLO, CS_CLIENT_KEY_EXCHANGE, CS_CLIENT_SUPPLEMENTAL_DATA, CS_END, CS_SERVER_CERTIFICATE, CS_SERVER_FINISHED, CS_SERVER_HELLO, CS_SERVER_HELLO_DONE, CS_SERVER_KEY_EXCHANGE, CS_SERVER_SESSION_TICKET, CS_SERVER_SUPPLEMENTAL_DATA, CS_START, expectSessionTicket, EXT_RenegotiationInfo, EXT_SessionTicket, inputBuffers, offeredCipherSuites, outputBuffer, receivedChangeCipherSpec, resumedSession, serverExtensions, sessionParameters, tlsSession
-
-
Constructor Summary
Constructors Constructor Description TlsClientProtocol()Constructor for non-blocking mode.
When data is received, useTlsProtocol.offerInput(byte[])to provide the received ciphertext, then useTlsProtocol.readInput(byte[], int, int)to read the corresponding cleartext.
Similarly, when data needs to be sent, useTlsProtocol.writeApplicationData(byte[], int, int)to provide the cleartext, then useTlsProtocol.readOutput(byte[], int, int)to get the corresponding ciphertext.TlsClientProtocol(java.io.InputStream input, java.io.OutputStream output)Constructor for blocking mode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeginHandshake(boolean renegotiation)protected voidcleanupHandshake()voidconnect(TlsClient tlsClient)Initiates a TLS handshake in the role of client.
In blocking mode, this will not return until the handshake is complete.protected TlsContextgetContext()protected TlsPeergetPeer()protected voidhandleHandshakeMessage(short type, java.io.ByteArrayInputStream buf)protected voidhandleServerCertificate()protected voidhandleSupplementalData(java.util.Vector serverSupplementalData)protected voidreceiveNewSessionTicketMessage(java.io.ByteArrayInputStream buf)protected voidreceiveServerHelloMessage(java.io.ByteArrayInputStream buf)protected voidsendCertificateVerifyMessage(DigitallySigned certificateVerify)protected voidsendClientHelloMessage()protected voidsendClientKeyExchangeMessage()-
Methods inherited from class org.bouncycastle.tls.TlsProtocol
applicationDataAvailable, applyMaxFragmentLengthExtension, assertEmpty, blockForHandshake, checkReceivedChangeCipherSpec, close, closeConnection, closeInput, completeHandshake, createRandomBlock, createRenegotiationInfo, createVerifyData, establishMasterSecret, flush, getAppDataSplitMode, getApplicationDataLimit, getAvailableInputBytes, getAvailableOutputBytes, getInputStream, getOutputStream, getPRFAlgorithm, getRenegotiationPolicy, handleAlertMessage, handleAlertWarningMessage, handleChangeCipherSpecMessage, handleClose, handleException, handleFailure, handleRenegotiation, invalidateSession, isClosed, isHandshaking, isResumableHandshake, offerInput, offerInput, previewInputRecord, previewOutputRecord, processFinishedMessage, processMaxFragmentLengthExtension, processRecord, raiseAlertFatal, raiseAlertWarning, readApplicationData, readExtensions, readExtensionsData, readInput, readOutput, readSupplementalDataMessage, refuseRenegotiation, resumeHandshake, safePreviewRecordHeader, safeReadFullRecord, safeReadRecord, safeWriteRecord, sendCertificateMessage, sendChangeCipherSpecMessage, sendFinishedMessage, sendSupplementalDataMessage, setAppDataSplitMode, setResumableHandshake, validateCredentials, writeApplicationData, writeExtensions, writeHandshakeMessage, writeSelectedExtensions, writeSupplementalData
-
-
-
-
Field Detail
-
tlsClient
protected TlsClient tlsClient
-
clientAgreements
protected java.util.Hashtable clientAgreements
-
keyExchange
protected TlsKeyExchange keyExchange
-
authentication
protected TlsAuthentication authentication
-
certificateStatus
protected CertificateStatus certificateStatus
-
certificateRequest
protected CertificateRequest certificateRequest
-
-
Constructor Detail
-
TlsClientProtocol
public TlsClientProtocol()
Constructor for non-blocking mode.
When data is received, useTlsProtocol.offerInput(byte[])to provide the received ciphertext, then useTlsProtocol.readInput(byte[], int, int)to read the corresponding cleartext.
Similarly, when data needs to be sent, useTlsProtocol.writeApplicationData(byte[], int, int)to provide the cleartext, then useTlsProtocol.readOutput(byte[], int, int)to get the corresponding ciphertext.
-
TlsClientProtocol
public TlsClientProtocol(java.io.InputStream input, java.io.OutputStream output)Constructor for blocking mode.- Parameters:
input- The stream of data from the serveroutput- The stream of data to the server
-
-
Method Detail
-
connect
public void connect(TlsClient tlsClient) throws java.io.IOException
Initiates a TLS handshake in the role of client.
In blocking mode, this will not return until the handshake is complete. In non-blocking mode, useTlsPeer.notifyHandshakeComplete()to receive a callback when the handshake is complete.- Parameters:
tlsClient- TheTlsClientto use for the handshake.- Throws:
java.io.IOException- If in blocking mode and handshake was not successful.
-
beginHandshake
protected void beginHandshake(boolean renegotiation) throws java.io.IOException- Overrides:
beginHandshakein classTlsProtocol- Throws:
java.io.IOException
-
cleanupHandshake
protected void cleanupHandshake()
- Overrides:
cleanupHandshakein classTlsProtocol
-
getContext
protected TlsContext getContext()
- Specified by:
getContextin classTlsProtocol
-
getPeer
protected TlsPeer getPeer()
- Specified by:
getPeerin classTlsProtocol
-
handleHandshakeMessage
protected void handleHandshakeMessage(short type, java.io.ByteArrayInputStream buf) throws java.io.IOException- Specified by:
handleHandshakeMessagein classTlsProtocol- Throws:
java.io.IOException
-
handleServerCertificate
protected void handleServerCertificate() throws java.io.IOException- Throws:
java.io.IOException
-
handleSupplementalData
protected void handleSupplementalData(java.util.Vector serverSupplementalData) throws java.io.IOException- Throws:
java.io.IOException
-
receiveNewSessionTicketMessage
protected void receiveNewSessionTicketMessage(java.io.ByteArrayInputStream buf) throws java.io.IOException- Throws:
java.io.IOException
-
receiveServerHelloMessage
protected void receiveServerHelloMessage(java.io.ByteArrayInputStream buf) throws java.io.IOException- Throws:
java.io.IOException
-
sendCertificateVerifyMessage
protected void sendCertificateVerifyMessage(DigitallySigned certificateVerify) throws java.io.IOException
- Throws:
java.io.IOException
-
sendClientHelloMessage
protected void sendClientHelloMessage() throws java.io.IOException- Throws:
java.io.IOException
-
sendClientKeyExchangeMessage
protected void sendClientKeyExchangeMessage() throws java.io.IOException- Throws:
java.io.IOException
-
-