siloft-networking

A Java library for networking

License

License

Categories

Categories

Net Networking
GroupId

GroupId

com.siloft
ArtifactId

ArtifactId

siloft-networking
Last Version

Last Version

0.8.6
Release Date

Release Date

Type

Type

jar
Description

Description

siloft-networking
A Java library for networking
Project URL

Project URL

https://github.com/siloft/siloft-networking
Project Organization

Project Organization

Siloft
Source Code Management

Source Code Management

https://github.com/siloft/siloft-networking

Download siloft-networking

How to add to project

<!-- https://jarcasting.com/artifacts/com.siloft/siloft-networking/ -->
<dependency>
    <groupId>com.siloft</groupId>
    <artifactId>siloft-networking</artifactId>
    <version>0.8.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.siloft/siloft-networking/
implementation 'com.siloft:siloft-networking:0.8.6'
// https://jarcasting.com/artifacts/com.siloft/siloft-networking/
implementation ("com.siloft:siloft-networking:0.8.6")
'com.siloft:siloft-networking:jar:0.8.6'
<dependency org="com.siloft" name="siloft-networking" rev="0.8.6">
  <artifact name="siloft-networking" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.siloft', module='siloft-networking', version='0.8.6')
)
libraryDependencies += "com.siloft" % "siloft-networking" % "0.8.6"
[com.siloft/siloft-networking "0.8.6"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

system (1)

Group / Artifact Type Version
com.oracle » javafx jar 2.1

Project Modules

There are no modules declared in this project.

A Java library for networking

Help us improve

This Networking library was developed by Siloft (https://siloft.com/). We hope users of this library are willing to help us maintain, improve, and share this library to satisfy all the needs of people around the world.

Overview

The Siloft Networking library is an easy-to-use Java library which handles reading and writing to and from TCP sockets. Each packet transmitted or received on a TCP connection is individually addressed and routed. TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating by an IP network. Packet delivery is guaranteed.

The library has the following features:

  • An TCP server and TCP client.
  • An SSL server and SSL client which can be used for SSL and TLS communication over TCP.
  • Protocol support for easily defining, encoding, and decoding messages.

Requirements

The following requirements are attached to this library:

  • Java 8 (or higher), standard (SE)
  • JavaFX 2.1 (or higher)

Generate key stores

The SSL server and SSL client requires key stores matching each other in order to encrypt data before transmission. To generate these key stores the Java keytool can be used. Java keytool stores the keys and certificates in a key store, protected by a key store password. Further, it protects the private key again with another password. A Java key store contains private-public key pair and multiple trusted certificate entries. All entries in a key store are referred by aliases. Both, the private key and self signed public key, is referred by one alias while any other trusted certificates are referred by different individual aliases.

As the first step, let's create a key store for server. In order to do it, execute following command in a terminal. "server" in the following command corresponds to the private key/self signed public key certificate alias in the key store while "server.jks" is the name of the creating key store file.

keytool -genkey -alias server -keyalg RSA -keystore server.jks

Once you successfully completed this, Java keytool will create a file named "server.jks". In the same way, you can create a client key store named "client.jks" with the alias "client" using following command.

keytool -genkey -alias client -keyalg RSA -keystore client.jks

Now, you have two files named "client.jks" and "server.jks". You can view the content of these key store files using the following command. Replace "123456" with the key store password you entered while creating the key store.

keytool -list -v -keystore server.jks -storepass 123456

The next step is, getting server's self signed public key certificate and storing it in client's key store. And getting and storing client's self signed public key certificate in server's key store. In order to do that, first we need to export both server and client public key certificates into files. Using the following command, you can export server's public key certificate into "server.cert" file and client's public key certificate into "client.cert" file.

keytool -export -file server.cert -keystore server.jks -storepass 123456 -alias server
keytool -export -file client.cert -keystore client.jks -storepass 123456 -alias client

Now you have "server.cert" and "client.cert". You can use following commands to view certificate contents.

keytool -printcert -v -file server.cert
keytool -printcert -v -file client.cert

As the last step, we need to import "server.cert" into client key store and "client.cert" into server key store. As I mentioned earlier, each entry of a Java key store is stored against an alias. So, we need to specify aliases here, which will be used to refer the certificates that we are going to store.

keytool -import -file client.cert -keystore server.jks -storepass 123456 -alias client

Above command will store client's self signed public key certificate (client.cert) in "server.jks" against the alias "client". So, using "client" alias on "server.jks", we can refer client's certificate anytime. Likewise, following command will store "server.cert" within "client.jks" against the alias "server".

keytool -import -file server.cert -keystore client.jks -storepass 123456 -alias server

After all, please view the content of both key store again using following commands.

keytool -list -v -keystore server.jks -storepass 123456
keytool -list -v -keystore client.jks -storepass 123456

Maven install

The Siloft networking library for Java is easy to install, and you can download the binary directly from the Downloads page, or you can use Maven. To use Maven, add the following lines to your pom.xml file:

<project>
  <dependencies>
    <dependency>
      <groupId>com.siloft</groupId>
      <artifactId>siloft-networking</artifactId>
      <version>0.8.6</version>
    </dependency>
  </dependencies>
</project> 

Planned improvements

The list below indicates which future improvements are planned. This does not mean they will be implemented.

  1. Improve error handling to give better indications of failures.

License

Siloft Networking library is open-source and licensed under the MIT License.

Versions

Version
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0