# Infinispan Web Session Store

An implementation of `SessionStore` that relies on the Infinispan Java Client.

Warning | This module has Tech Preview status, this means the API can change between versions.

## Getting started

To use this module, add the following to the dependencies section of your Maven POM file:

    <dependency>
     <groupId>io.vertx</groupId>
     <artifactId>vertx-web-sstore-infinispan</artifactId>
     <version>4.2.7</version>
    </dependency>

Or, if you use Gradle:

    compile 'io.vertx:vertx-web-sstore-infinispan:4.2.7'

## Using

If this session store is the only one you have in your dependencies, you can initialize it in a generic way:

    JsonObject config = new JsonObject()
      .put("servers", new JsonArray()
        .add(new JsonObject()
          .put("host", "server1.datagrid.mycorp.int")
          .put("username", "foo")
          .put("password", "bar"))
        .add(new JsonObject()
          .put("host", "server2.datagrid.mycorp.int")
          .put("username", "foo")
          .put("password", "bar"))
      );
    SessionStore store = SessionStore.create(vertx, config);
    SessionHandler sessionHandler = SessionHandler.create(store);
    router.route().handler(sessionHandler);

Otherwise, use the `InfinispanSessionStore` type explicitely:

    JsonObject config = new JsonObject()
      .put("servers", new JsonArray()
        .add(new JsonObject()
          .put("host", "server1.datagrid.mycorp.int")
          .put("username", "foo")
          .put("password", "bar"))
        .add(new JsonObject()
          .put("host", "server2.datagrid.mycorp.int")
          .put("username", "foo")
          .put("password", "bar"))
      );
    InfinispanSessionStore store = InfinispanSessionStore.create(vertx, config);
    SessionHandler sessionHandler = SessionHandler.create(store);
    router.route().handler(sessionHandler);

## Configuring

### Config entries

The root entries are:

- `servers`: mandatory, a JSON array of server definitions (see below)

- `cacheName`: optional, the name of the cache used to store session data (defaults to `vertx-web.sessions`)

- `retryTimeout`: optional, the retry timeout value in milli-seconds used by the session handler when it retrieves a value from the store (defaults to `5000`)

The entries for a server definition are:

- `uri` : optional, a Hot Rod URI

- `host`: optional (defaults to `localhost`)

- `port`: optional (defaults to `11222`)

- `clientIntelligence`: optional (one of `BASIC`, `TOPOLOGY_AWARE`, `HASH_DISTRIBUTION_AWARE`)

- `username`: mandatory

- `password`: mandatory

- `realm`: optional (defaults to `default`)

- `saslMechanism`: optional (defaults to `DIGEST-MD5`)

- `saslQop`: optional (one of `AUTH`, `AUTH_INT`, `AUTH_CONF`)

Important | If the `uri` entry is set, the others are ignored.

### Custom Infinispan Client

For advanced configuration requirements, you can provide a custom `RemoteCacheManager`:

    InfinispanSessionStore sessionStore = InfinispanSessionStore.create(vertx, config, remoteCacheManager);