APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.net.httpserver

pack-priv Class SSLStreams

extends Object
Class Inheritance
Imports
java.net.*, java.nio.*, java.io.*, java.nio.channels.*, java.util.concurrent.locks.*, javax.net.ssl.*, javax.net.ssl.SSLEngineResult.*, com.sun.net.httpserver.*

given a non-blocking SocketChannel, it produces (blocking) streams which encrypt/decrypt the SSL content and handle the SSL handshaking automatically.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
pack-priv class
SSLStreams.EngineWrapper

This is a thin wrapper over SSLEngine and the SocketChannel, which guarantees the ordering of wraps/unwraps with respect to the underlying channel read/writes.

pack-priv class
SSLStreams.InputStream

represents an SSL input stream.

pack-priv class
SSLStreams.OutputStream

represents an SSL output stream.

pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv SocketChannel
pack-priv SSLEngine
pack-priv Lock
pack-priv SSLStreams.InputStream
pack-priv SSLStreams.OutputStream
pack-priv int
pack-priv ServerImpl
pack-priv SSLContext
pack-priv SSLStreams.EngineWrapper

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private ByteBuffer
private ByteBuffer
allocate(SSLStreams.BufType type, int len)

pack-priv void
beginHandshake()

request the engine to repeat the handshake on this session the handshake must be driven by reads/writes on the streams Normally, not necessary to call this.

pack-priv void
close()

cleanup resources allocated inside this object

private void
pack-priv void
pack-priv void
pack-priv SSLStreams.InputStream
getInputStream()

return the SSL InputStream

pack-priv SSLStreams.OutputStream
getOutputStream()

return the SSL OutputStream

pack-priv SSLEngine
private ByteBuffer
realloc(ByteBuffer b, boolean flip, SSLStreams.BufType type)

public SSLStreams.WrapperResult
recvData(ByteBuffer dst)

read data thru the engine into the given ByteBuffer.

public SSLStreams.WrapperResult
sendData(ByteBuffer src)

send the data in the given ByteBuffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

app_buf_sizeback to summary
pack-priv int app_buf_size
chanback to summary
pack-priv SocketChannel chan
engineback to summary
pack-priv SSLEngine engine
handshakingback to summary
pack-priv Lock handshaking
isback to summary
pack-priv SSLStreams.InputStream is
osback to summary
pack-priv SSLStreams.OutputStream os
packet_buf_sizeback to summary
pack-priv int packet_buf_size
serverback to summary
pack-priv ServerImpl server
sslctxback to summary
pack-priv SSLContext sslctx
wrapperback to summary
pack-priv SSLStreams.EngineWrapper wrapper

Constructor Detail

SSLStreamsback to summary
pack-priv SSLStreams(ServerImpl server, SSLContext sslctx, SocketChannel chan) throws IOException

Method Detail

allocateback to summary
private ByteBuffer allocate(SSLStreams.BufType type)
allocateback to summary
private ByteBuffer allocate(SSLStreams.BufType type, int len)
beginHandshakeback to summary
pack-priv void beginHandshake() throws SSLException

request the engine to repeat the handshake on this session the handshake must be driven by reads/writes on the streams Normally, not necessary to call this.

closeback to summary
pack-priv void close() throws IOException

cleanup resources allocated inside this object

configureEngineback to summary
private void configureEngine(HttpsConfigurator cfg, InetSocketAddress addr)
Annotations
@SuppressWarnings:deprecation
doClosureback to summary
pack-priv void doClosure() throws IOException
doHandshakeback to summary
pack-priv void doHandshake(SSLEngineResult.HandshakeStatus hs_status) throws IOException
Annotations
@SuppressWarnings:fallthrough
getInputStreamback to summary
pack-priv SSLStreams.InputStream getInputStream() throws IOException

return the SSL InputStream

getOutputStreamback to summary
pack-priv SSLStreams.OutputStream getOutputStream() throws IOException

return the SSL OutputStream

getSSLEngineback to summary
pack-priv SSLEngine getSSLEngine()
reallocback to summary
private ByteBuffer realloc(ByteBuffer b, boolean flip, SSLStreams.BufType type)
recvDataback to summary
public SSLStreams.WrapperResult recvData(ByteBuffer dst) throws IOException

read data thru the engine into the given ByteBuffer. If the given buffer was not large enough, a new one is allocated and returned. This call handles handshaking automatically. Caller should check if engine has been closed.

sendDataback to summary
public SSLStreams.WrapperResult sendData(ByteBuffer src) throws IOException

send the data in the given ByteBuffer. If a handshake is needed then this is handled within this method. When this call returns, all of the given user data has been sent and any handshake has been completed. Caller should check if engine has been closed.

sun.net.httpserver back to summary

pack-priv final Enum SSLStreams.BufType

extends Enum<SSLStreams.BufType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final SSLStreams.BufType
public static final SSLStreams.BufType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SSLStreams.BufType
public static SSLStreams.BufType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

APPLICATIONback to summary
public static final SSLStreams.BufType APPLICATION
PACKETback to summary
public static final SSLStreams.BufType PACKET

Constructor Detail

BufTypeback to summary
private BufType()

Method Detail

valueOfback to summary
public static SSLStreams.BufType valueOf(String name)
valuesback to summary
public static SSLStreams.BufType[] values()
sun.net.httpserver back to summary

pack-priv Class SSLStreams.EngineWrapper

extends Object
Class Inheritance

This is a thin wrapper over SSLEngine and the SocketChannel, which guarantees the ordering of wraps/unwraps with respect to the underlying channel read/writes. It handles the UNDER/OVERFLOW status codes It does not handle the handshaking status codes, or the CLOSED status code though once the engine is closed, any attempt to read/write to it will get an exception. The overall result is returned. It functions synchronously/blocking

Field Summary

Modifier and TypeField and Description
pack-priv SocketChannel
pack-priv boolean
pack-priv SSLEngine
pack-priv int
pack-priv ByteBuffer
pack-priv Object
pack-priv ByteBuffer
pack-priv Object

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv SSLStreams.WrapperResult
pack-priv SSLStreams.WrapperResult
pack-priv SSLStreams.WrapperResult
wrapAndSendX(ByteBuffer src, boolean ignoreClose)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

chanback to summary
pack-priv SocketChannel chan
closedback to summary
pack-priv boolean closed
engineback to summary
pack-priv SSLEngine engine
u_remainingback to summary
pack-priv int u_remaining
unwrap_srcback to summary
pack-priv ByteBuffer unwrap_src
unwrapLockback to summary
pack-priv Object unwrapLock
wrap_dstback to summary
pack-priv ByteBuffer wrap_dst
wrapLockback to summary
pack-priv Object wrapLock

Constructor Detail

EngineWrapperback to summary
pack-priv EngineWrapper(SocketChannel chan, SSLEngine engine) throws IOException

Method Detail

closeback to summary
pack-priv void close() throws IOException
recvAndUnwrapback to summary
pack-priv SSLStreams.WrapperResult recvAndUnwrap(ByteBuffer dst) throws IOException
wrapAndSendback to summary
pack-priv SSLStreams.WrapperResult wrapAndSend(ByteBuffer src) throws IOException
wrapAndSendXback to summary
pack-priv SSLStreams.WrapperResult wrapAndSendX(ByteBuffer src, boolean ignoreClose) throws IOException
sun.net.httpserver back to summary

pack-priv Class SSLStreams.InputStream

extends InputStream
Class Inheritance

represents an SSL input stream. Multiple https requests can be sent over one stream. closing this stream causes an SSL close input.

Field Summary

Modifier and TypeField and Description
pack-priv ByteBuffer
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv byte[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

close the SSL connection.

public boolean
markSupported()

Overrides java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

public int
read(byte[] buf, int off, int len)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

public int
read(byte[] buf)

Overrides java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public void
reset()

Overrides java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

public long
skip(long s)

Overrides java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream.

Inherited from java.io.InputStream:
marknullInputStreamreadAllBytesreadNBytesreadNBytesskipNBytestransferTo

Field Detail

bbufback to summary
pack-priv ByteBuffer bbuf
closedback to summary
pack-priv boolean closed
eofback to summary
pack-priv boolean eof
needDataback to summary
pack-priv boolean needData
singleback to summary
pack-priv byte[] single

Constructor Detail

InputStreamback to summary
pack-priv InputStream()

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

close the SSL connection. All data must have been consumed before this is called. Otherwise an exception will be thrown. [Note. May need to revisit this. not quite the normal close() semantics

Exceptions
IOException:

Doc from java.io.InputStream.close.

if an I/O error occurs.

markSupportedback to summary
public boolean markSupported()

Overrides java.io.InputStream.markSupported.

Doc from java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance.

readback to summary
public int read(byte[] buf, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
readback to summary
public int read(byte[] buf) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

Exceptions
IOException:
If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Exceptions
IOException:
if an I/O error occurs.
resetback to summary
public void reset() throws IOException

Overrides java.io.InputStream.reset.

Doc from java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

The general contract of reset is:

  • If the method markSupported returns true, then:
    • If the method mark has not been called since the stream was created, or the number of bytes read from the stream since mark was last called is larger than the argument to mark at that last call, then an IOException might be thrown.
    • If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method, followed by any bytes that otherwise would have been the next input data as of the time of the call to reset.
  • If the method markSupported returns false, then:
    • The call to reset may throw an IOException.
    • If an IOException is not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the read method depend on the particular type of the input stream.
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
skipback to summary
public long skip(long s) throws IOException

Overrides java.io.InputStream.skip.

Doc from java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.

Exceptions
IOException:
if an I/O error occurs.
sun.net.httpserver back to summary

pack-priv Class SSLStreams.OutputStream

extends OutputStream
Class Inheritance

represents an SSL output stream. plain text data written to this stream is encrypted by the stream. Multiple HTTPS responses can be sent on one stream. closing this stream initiates an SSL closure

Field Summary

Modifier and TypeField and Description
pack-priv ByteBuffer
pack-priv boolean
pack-priv byte[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.

public void
write(int b)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[] b)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream.

public void
write(byte[] b, int off, int len)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
nullOutputStream

Field Detail

bufback to summary
pack-priv ByteBuffer buf
closedback to summary
pack-priv boolean closed
singleback to summary
pack-priv byte[] single

Constructor Detail

OutputStreamback to summary
pack-priv OutputStream()

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Exceptions
IOException:
if an I/O error occurs.
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeback to summary
public void write(byte[] b) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
sun.net.httpserver back to summary

pack-priv Class SSLStreams.Parameters

extends HttpsParameters
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv InetSocketAddress
pack-priv HttpsConfigurator
pack-priv SSLParameters

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public InetSocketAddress
getClientAddress()

Implements abstract com.sun.net.httpserver.HttpsParameters.getClientAddress.

Returns the address of the remote client initiating the connection.

public HttpsConfigurator
pack-priv SSLParameters
public void
setSSLParameters(SSLParameters p)

Implements abstract com.sun.net.httpserver.HttpsParameters.setSSLParameters.

Sets the SSLParameters to use for this HttpsParameters.

Inherited from com.sun.net.httpserver.HttpsParameters:
getCipherSuitesgetNeedClientAuthgetProtocolsgetWantClientAuthsetCipherSuitessetNeedClientAuthsetProtocolssetWantClientAuth

Field Detail

addrback to summary
pack-priv InetSocketAddress addr
cfgback to summary
pack-priv HttpsConfigurator cfg
paramsback to summary
pack-priv SSLParameters params

Constructor Detail

Parametersback to summary
pack-priv Parameters(HttpsConfigurator cfg, InetSocketAddress addr)

Method Detail

getClientAddressback to summary
public InetSocketAddress getClientAddress()

Implements abstract com.sun.net.httpserver.HttpsParameters.getClientAddress.

Doc from com.sun.net.httpserver.HttpsParameters.getClientAddress.

Returns the address of the remote client initiating the connection.

getHttpsConfiguratorback to summary
public HttpsConfigurator getHttpsConfigurator()

Implements abstract com.sun.net.httpserver.HttpsParameters.getHttpsConfigurator.

Doc from com.sun.net.httpserver.HttpsParameters.getHttpsConfigurator.

Returns the HttpsConfigurator for this HttpsParameters.

getSSLParametersback to summary
pack-priv SSLParameters getSSLParameters()
setSSLParametersback to summary
public void setSSLParameters(SSLParameters p)

Implements abstract com.sun.net.httpserver.HttpsParameters.setSSLParameters.

Doc from com.sun.net.httpserver.HttpsParameters.setSSLParameters.

Sets the SSLParameters to use for this HttpsParameters. The parameters must be supported by the SSLContext contained by the HttpsConfigurator associated with this HttpsParameters. If no parameters are set, then the default behavior is to use the default parameters from the associated SSLContext.

sun.net.httpserver back to summary

pack-priv Class SSLStreams.WrapperResult

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv ByteBuffer
pack-priv SSLEngineResult

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufback to summary
pack-priv ByteBuffer buf
resultback to summary
pack-priv SSLEngineResult result

Constructor Detail

WrapperResultback to summary
pack-priv WrapperResult()