Verifying Client Version


Table of Contents

What is a Client Version Checker?

In the process of making revisions, a developer may create many versions of the client, some of which may or may not be compatible to the server. The client version checker does the job of verifying whether the client version (defined by the UserIdentifier class) is compatible to the server. In other words, the checker allows backward compatibility; the developer can enumerate the supported versions of the client when the server is initialized with the client version checker, and any client version that is rejected by the checker will not work with the server.

TIVersionIdentifer

A TIVersionIdentifier is our way of identifying the versions of our clients by assigning version numbers to three categories: major, minor, and revision. We initialize a TIVersionIdentifier by passing in the numbers we choose for major, minor, and revision:

// designating the three version categories
int major, minor, revision = 1, 2, 3;

// initializing the client version
TIVersionIdentifier YourClientVersion = new TIVersionIdentifier(major, minor, revision);

How to Create a Client Version Checker

There are a couple client version checkers implemented for your convenience (ClientVersionChecker and ClientVersionIntervalChecker), but you can create your own client version checker by implementing the ClientVersionCheckerInterface. The interface requires the implementation of the method isClientValid(clientVersion) to return a boolean value. If the function returns true, the server will acknowledge clientVersion to be valid client version and continue on to authenticating the client ID (you can read more about authenticating client IDs here). For example, the following class implements a version checker that regards all client versions valid:

public class yourClientVersionChecker implements ClientVersionCheckerInterface{
    // always returns true because all client versions are compatible to the server
    @Override
    public boolean isClientValid(TIVersionIdentifier version) {
        return true;
    }
}

How Do I Use a Client Version Checker?

Ultimately, it is up to you to decide which client versions are compatible to your servers, so a client version checker should be initialized when you set up your server.

// initializing a client version identifier
YourClientVersionChecker checker = new YourClientVersionChecker();

// pass the ClientVersionChecker into the server protocol
TIProtocol tiProtocol = new TIProtocol(ciphers, finalPort, keyStorePassword, YourClientVersionChecker, idAuthenticator);

Once you’ve created your client version checker, all you need to do is pass the checker into the server protocol, and the protocol will do the rest. You can refer to Start a Server to learn more about initializing your server.

Running Example

To keep things simple, in our running example application we will use the client version checker that accepts all client versions under “How to Create a Client Version Checker”. Please refer to Start a Server under “Running Example” to see how to use the client version checker defined on this page in the running example.

The next step in the running example can be found here.