THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||
---|---|---|
| ||
public interface TransportLayer { /** * Closes this channel * * @throws IOException If and I/O error occurs */ void close() throws IOException; /** * Tells wheather or not this channel is open. */ boolean isOpen(); /** * Writes a sequence of bytes to this channel from the given buffer. */ int write(ByteBuffer src) throws IOException; long write(ByteBuffer[] srcs) throws IOException; long write(ByteBuffer[] srcs, int offset, int length) throws IOException; int read(ByteBuffer dst) throws IOException; long read(ByteBuffer[] dsts) throws IOException; long read(ByteBuffer[] dsts, int offset, int length) throws IOException; boolean isReady(); boolean finishConnect() throws IOException; SocketChannel socketChannel(); /** * Performs SSL handshake hence is a no-op for the non-secure * implementation * @param read Unused in non-secure implementation * @param write Unused in non-secure implementation * @return Always return 0 * @throws IOException */ int handshake(boolean read, boolean write) throws IOException; DataInputStream inStream() throws IOException; DataOutputStream outStream() throws IOException; boolean flush(ByteBuffer buffer) throws IOException; Principal getPeerPrincipal(); } |
PlainTextTransportLayer
Code Block | ||
---|---|---|
| ||
public class PlainTextTransportLayer implements TransportLayer { public PlainTextTransportLayer(SocketChannel socketChannel) throws IOException } |
SSLTransportLayer
Code Block | ||
---|---|---|
| ||
public class SSLTransportLayer implements TransportLayer { public SSLTransportLayer(SocketChannel socketChannel, SSLEngine sslEngine) throws IOException } |
...
Code Block | ||
---|---|---|
| ||
public interface Authenticator { /** * Closes any resources * * @throws IOException if any I/O error occurs */ void close() throws IOException; /** * * @throws IOException */ void init() throws IOException; /** * Returns UserPrincipal after authentication is established */ UserPrincipal userPrincipal(); /** * Does authentication in non-blocking way and returns SelectionKey.OP if further communication needed */ int authenticate(boolean read, boolean write) throws IOException; /** * returns true if authentication is complete otherwise returns false; */ boolean isComplete(); } |
DefaultAuthenticator
Code Block | ||
---|---|---|
| ||
public class DefaultAuthenticator implements Authenticator { TransportLayer transportLayer; public DefaultAuthenticator(TransportLayer transportLayer) { this.transportLayer = transportLayer; } public void init() {} public int authenticate(boolean read, boolean write) throws IOException { return 0; } /** returns peer host incase of SSL */ public UserPrincipal userPrincipal() { return new UserPrincipal(transportLayer.getPeerPrincipal().toString()); } public void close() throws IOException {} public boolean isComplete() { return true; } } |
SaslServerAuthenticator
Code Block | ||
---|---|---|
| ||
public class SaslServerAuthenticator implements Authenticator { public SaslServerAuthenticator(final Subject subject, TransportLayer transportLayer) { } } |
SaslClientAuthenticator
Code Block | ||
---|---|---|
| ||
public class SaslServerAuthenticator implements Authenticator { public SaslServerAuthenticator(final Subject subject, TransportLayer transportLayer) { } } |
...