|
Java HTTP Proxy Library Project Page
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.wpg.proxy.SSLByteChannel
public class SSLByteChannel
Upgrade a ByteChannel for SSL.
Change Log:
This source code is given to the Public Domain. Do what you want with it. This software comes with no guarantees or warranties. Please visit http://perso.wanadoo.fr/reuse/sslbytechannel/ periodically to check for updates or to contribute improvements.
usage: KeyStore ks = KeyStore.getInstance("JKS"); File kf = new File("keystore"); ks.load(new FileInputStream(kf), "storepassword".toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, "keypassword".toCharArray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ks); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); engine.beginHandshake(); SSLByteChannel sslByteChannel = new SSLByteChannel(channel, engine);
| Constructor Summary | |
|---|---|
SSLByteChannel(java.nio.channels.ByteChannel wrappedChannel,
javax.net.ssl.SSLEngine engine)
Creates a new instance of SSLByteChannel |
|
| Method Summary | |
|---|---|
void |
close()
Ends SSL operation and close the wrapped byte channel |
boolean |
isOpen()
Is the channel open ? |
int |
read(java.nio.ByteBuffer byteBuffer)
Fill the given buffer with some bytes and return the number of bytes added in the buffer. This method may return immediately with nothing added in the buffer. |
int |
write(java.nio.ByteBuffer byteBuffer)
Write remaining bytes of the given byte buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SSLByteChannel(java.nio.channels.ByteChannel wrappedChannel,
javax.net.ssl.SSLEngine engine)
wrappedChannel - The byte channel on which this ssl channel is built.
This channel contains encrypted data.engine - A SSLEngine instance that will remember SSL current
context. Warning, such an instance CAN NOT be shared
between multiple SSLByteChannel.| Method Detail |
|---|
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.nio.channels.Channeljava.io.IOException - May be raised by close operation on wrapped byte channelpublic boolean isOpen()
isOpen in interface java.nio.channels.Channel
public int read(java.nio.ByteBuffer byteBuffer)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelbyteBuffer - The buffer that will received read bytes
java.io.IOException - May be raised by ByteChannel read operation
public int write(java.nio.ByteBuffer byteBuffer)
throws java.io.IOException
write in interface java.nio.channels.WritableByteChannelbyteBuffer - buffer with remaining bytes to write
java.io.IOException - May be raised by ByteChannel write operation
|
Java HTTP Proxy Library Project Page
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||