Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marianobarrios committed May 10, 2024
1 parent e6db1d0 commit f31d39a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TLS Channel

TLS Channel is a library that implements a [ByteChannel](https://docs.oracle.com/javase/8/docs/api/java/nio/channels/ByteChannel.html) interface over a [TLS](https://tools.ietf.org/html/rfc5246) (Transport Layer Security) connection. It delegates all cryptographic operations to the standard Java TLS implementation: [SSLEngine](https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLEngine.html); effectively hiding it behind an easy-to-use streaming API, that allows to securitize JVM applications with minimal added complexity.
TLS Channel is a library that implements a [ByteChannel](https://docs.oracle.com/javase/8/docs/api/java/nio/channels/ByteChannel.html) interface over a [TLS](https://tools.ietf.org/html/rfc5246) (Transport Layer Security) connection. It delegates all cryptographic operations to the standard Java TLS implementation: [SSLEngine](https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLEngine.html); effectively hiding it behind an easy-to-use streaming API, that allows to secure JVM applications with minimal added complexity.

In other words, a simple library that allows the programmer to implement TLS using the same standard socket API used for plaintext, just like OpenSSL does for C, only for Java, filling a specially painful missing feature of the standard library.

Expand Down Expand Up @@ -95,7 +95,7 @@ I/O framework | [XNIO](http://xnio.jboss.org/) | [org.xnio.ssl.JsseStreamConduit
HTTP server | [Tomcat](http://tomcat.apache.org/) | [org.apache.tomcat.util.net.SecureNio2Channel](http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?view=markup)
HTTP server | [OpenJDK](http://openjdk.java.net/) | [sun.net.httpserver.SSLStreams](http://cr.openjdk.java.net/~ohair/openjdk7/jdk7-build-copyright/webrev/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java.html)
HTTP client/server | [Apache HttpComponents](https://hc.apache.org/) | [org.apache.http.impl.nio.reactor.SSLIOSession](https://apache.googlesource.com/httpcore/+/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java)
HTTP server | [Jetty](Jetty) | [org.eclipse.jetty.io.ssl.SslConnection](https://github.com/eclipse/jetty.project/blob/master/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java)
HTTP server | [Jetty](https://eclipse.dev/jetty/) | [org.eclipse.jetty.io.ssl.SslConnection](https://github.com/eclipse/jetty.project/blob/master/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java)
Distributed file system | [XtreemFS](http://www.xtreemfs.org/) | [org.xtreemfs.foundation.pbrpc.channels.SSLChannelIO](https://github.com/xtreemfs/xtreemfs/blob/master/java/xtreemfs-foundation/src/main/java/org/xtreemfs/foundation/pbrpc/channels/SSLChannelIO.java)
Tor client | [Orchid](https://subgraph.com/orchid/index.en.html) | [com.subgraph.orchid.sockets.sslengine.SSLEngineManager](https://github.com/subgraph/Orchid/blob/master/src/com/subgraph/orchid/sockets/sslengine/SSLEngineManager.java)

Expand Down Expand Up @@ -123,8 +123,8 @@ Typical usage involved creating either a [ClientTlsChannel](https://oss.sonatype

Complete examples:

- [Simple blocking client](src/test/scala/tlschannel/example/SimpleBlockingClient.java)
- [Simple blocking server](src/test/scala/tlschannel/example/SimpleBlockingServer.java)
- [Simple blocking client](src/test/java/tlschannel/example/SimpleBlockingClient.java)
- [Simple blocking server](src/test/java/tlschannel/example/SimpleBlockingServer.java)

### Non-blocking

Expand All @@ -149,8 +149,8 @@ try {

Complete examples:

- [Non-blocking client](src/test/scala/tlschannel/example/NonBlockingClient.java)
- [Non-blocking server](src/test/scala/tlschannel/example/NonBlockingServer.java)
- [Non-blocking client](src/test/java/tlschannel/example/NonBlockingClient.java)
- [Non-blocking server](src/test/java/tlschannel/example/NonBlockingServer.java)

### Off-loop tasks

Expand Down Expand Up @@ -184,7 +184,7 @@ try {
}
```

Complete example: [non-blocking server with off-loop tasks](src/test/scala/tlschannel/example/NonBlockingServerWithOffLoopTasks.java)
Complete example: [non-blocking server with off-loop tasks](src/test/java/tlschannel/example/NonBlockingServerWithOffLoopTasks.java)

### Server Name Indication – server side

Expand All @@ -204,7 +204,7 @@ TlsChannel tlsChannel = ServerTlsChannel
.build();
```

Complete example: [SNI-aware server](src/test/scala/tlschannel/example/SniBlockingServer.java)
Complete example: [SNI-aware server](src/test/java/tlschannel/example/SniBlockingServer.java)

### AsynchronousByteChannel

Expand All @@ -223,7 +223,7 @@ asyncTlsChannel.read(res, null, new CompletionHandler<Integer, Object>() {
};
```

Complete example: [Asynchronous channel server](src/test/scala/tlschannel/example/AsynchronousChannelServer.java)
Complete example: [Asynchronous channel server](src/test/java/tlschannel/example/AsynchronousChannelServer.java)

## Buffers

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tlschannel/TlsChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* <p>Instances that implement this interface delegate all cryptographic operations to the standard
* Java TLS implementation: SSLEngine; effectively hiding it behind an easy-to-use streaming API,
* that allows to securitize JVM applications with minimal added complexity.
* that allows to secure JVM applications with minimal added complexity.
*
* <p>In other words, an interface that allows the programmer to have TLS using the same standard
* socket API used for plaintext, just like OpenSSL does for C, only for Java.
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/tlschannel/async/AsynchronousTlsChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,13 @@ public Future<Integer> read(ByteBuffer dst) {
return CompletableFuture.completedFuture(0);
}
FutureReadResult future = new FutureReadResult();
ReadOperation op = group.startRead(
future.op = group.startRead(
registeredSocket,
new ByteBufferSet(dst),
0,
TimeUnit.MILLISECONDS,
c -> future.complete((int) c),
future::completeExceptionally);
future.op = op;
return future;
}

Expand Down Expand Up @@ -209,14 +208,13 @@ public Future<Integer> write(ByteBuffer src) {
return CompletableFuture.completedFuture(0);
}
FutureWriteResult future = new FutureWriteResult();
WriteOperation op = group.startWrite(
future.op = group.startWrite(
registeredSocket,
new ByteBufferSet(src),
0,
TimeUnit.MILLISECONDS,
c -> future.complete((int) c),
future::completeExceptionally);
future.op = op;
return future;
}

Expand All @@ -229,7 +227,7 @@ private <A> void completeWithZeroLong(A attach, CompletionHandler<Long, ? super
}

/**
* Tells whether or not this channel is open.
* Tells whether this channel is open.
*
* @return <code>true</code> if, and only if, this channel is open
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tlschannel/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* TLS Channel is a library that implements a ByteChannel interface to a TLS (Transport Layer
* Security) connection. The library delegates all cryptographic operations to the standard Java TLS
* implementation: SSLEngine; effectively hiding it behind an easy-to-use streaming API, that allows
* to securitize JVM applications with minimal added complexity.
* to secure JVM applications with minimal added complexity.
*
* <p>In other words, a simple library that allows the programmer to have TLS using the same
* standard socket API used for plaintext, just like OpenSSL does for C, only for Java, filling a
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/tlschannel/NullMultiNonBlockingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
@TestInstance(Lifecycle.PER_CLASS)
public class NullMultiNonBlockingTest {

private static final int dataSize = 10 * 1024 * 1024;
private static final int totalConnections = 50;

private final SslContextFactory sslContextFactory = new SslContextFactory();
private final SocketPairFactory factory = new SocketPairFactory(sslContextFactory.defaultContext());
private final int dataSize = 10 * 1024 * 1024;
private final int totalConnections = 50;

@Test
public void testRunTasksInNonBlockingLoop() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/tlschannel/async/AsyncShutdownTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
@TestInstance(Lifecycle.PER_CLASS)
public class AsyncShutdownTest implements AsyncTestBase {

private static final int bufferSize = 10;

private final SslContextFactory sslContextFactory = new SslContextFactory();
private final SocketPairFactory factory = new SocketPairFactory(sslContextFactory.defaultContext());

int bufferSize = 10;

@Test
public void testImmediateShutdown() throws InterruptedException {
System.out.println("testImmediateShutdown():");
Expand Down

0 comments on commit f31d39a

Please sign in to comment.