infinispan 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Jenkinsfile-release +1 -1
- package/README.md +31 -907
- package/documentation/asciidoc/stories/assembly_client_usage_examples.adoc +10 -0
- package/documentation/asciidoc/stories/assembly_installation_configuration.adoc +20 -0
- package/documentation/asciidoc/titles/js_client.asciidoc +28 -0
- package/documentation/asciidoc/titles/stories.adoc +5 -0
- package/documentation/asciidoc/topics/attributes/community-attributes.adoc +8 -0
- package/documentation/asciidoc/topics/attributes/downstream-attributes.adoc +2 -0
- package/documentation/asciidoc/topics/code_examples/authentication-digest.js +12 -0
- package/documentation/asciidoc/topics/code_examples/authentication-external.js +15 -0
- package/documentation/asciidoc/topics/code_examples/authentication-oauthbearer.js +10 -0
- package/documentation/asciidoc/topics/code_examples/authentication-plain.js +11 -0
- package/documentation/asciidoc/topics/code_examples/authentication-scram.js +11 -0
- package/documentation/asciidoc/topics/code_examples/await-multiple-entries.js +36 -0
- package/documentation/asciidoc/topics/code_examples/await-single-entries.js +29 -0
- package/documentation/asciidoc/topics/code_examples/conditional-operations.js +57 -0
- package/documentation/asciidoc/topics/code_examples/connection-multiple-servers.js +23 -0
- package/documentation/asciidoc/topics/code_examples/connection-xsite-cluster-switch.js +39 -0
- package/documentation/asciidoc/topics/code_examples/connection-xsite.js +13 -0
- package/documentation/asciidoc/topics/code_examples/data-types.js +30 -0
- package/documentation/asciidoc/topics/code_examples/encryption-crypto-store.js +11 -0
- package/documentation/asciidoc/topics/code_examples/encryption-private-key.js +13 -0
- package/documentation/asciidoc/topics/code_examples/encryption-sni-hostname.js +9 -0
- package/documentation/asciidoc/topics/code_examples/encryption-trust-certs.js +8 -0
- package/documentation/asciidoc/topics/code_examples/ephemeral-data.js +52 -0
- package/documentation/asciidoc/topics/code_examples/hello-world.js +42 -0
- package/documentation/asciidoc/topics/code_examples/key-value-converter.js +67 -0
- package/documentation/asciidoc/topics/code_examples/logging-configuration.js +2 -0
- package/documentation/asciidoc/topics/code_examples/multiple-entries.js +64 -0
- package/documentation/asciidoc/topics/code_examples/register-event-listener.js +64 -0
- package/documentation/asciidoc/topics/code_examples/sample-script-execute.js +33 -0
- package/documentation/asciidoc/topics/code_examples/sample-script.js +3 -0
- package/documentation/asciidoc/topics/code_examples/single-entries.js +49 -0
- package/documentation/asciidoc/topics/config_examples/logging.json +14 -0
- package/documentation/asciidoc/topics/proc_configuring_authentication.adoc +16 -0
- package/documentation/asciidoc/topics/proc_configuring_connections.adoc +25 -0
- package/documentation/asciidoc/topics/proc_configuring_connections_xsite.adoc +18 -0
- package/documentation/asciidoc/topics/proc_configuring_data_formats.adoc +30 -0
- package/documentation/asciidoc/topics/proc_configuring_encryption.adoc +15 -0
- package/documentation/asciidoc/topics/proc_configuring_logging.adoc +28 -0
- package/documentation/asciidoc/topics/proc_installing_clients.adoc +58 -0
- package/documentation/asciidoc/topics/proc_switching_clusters.adoc +17 -0
- package/documentation/asciidoc/topics/ref_authentication_mechanisms.adoc +68 -0
- package/documentation/asciidoc/topics/ref_client_usage.adoc +116 -0
- package/documentation/asciidoc/topics/ref_encryption.adoc +71 -0
- package/lib/codec.js +153 -2
- package/lib/infinispan.js +33 -1
- package/lib/io.js +23 -16
- package/lib/protocols.js +165 -68
- package/lib/protostream/message-wrapping.proto +134 -0
- package/lib/protostream/query.proto +122 -0
- package/lib/sasl/bitops.js +24 -0
- package/lib/sasl/digest.js +188 -0
- package/lib/sasl/external.js +54 -0
- package/lib/sasl/factory.js +71 -0
- package/lib/sasl/oauthbearer.js +63 -0
- package/lib/sasl/plain.js +65 -0
- package/lib/sasl/scram.js +135 -0
- package/lib/utils.js +1 -1
- package/memory-profiling/helper.js +9 -0
- package/memory-profiling/infinispan_memory_many_get.js +1 -3
- package/memory-profiling/infinispan_memory_one_get.js +6 -4
- package/package.json +7 -13
- package/run-servers.sh +17 -8
- package/run-testsuite.sh +1 -1
- package/smoke-tests.sh +8 -2
- package/spec/codec_spec.js +7 -7
- package/spec/configs/infinispan-clustered.xml +17 -14
- package/spec/configs/infinispan-ssl.xml +25 -22
- package/spec/configs/infinispan-xsite-EARTH.xml +17 -14
- package/spec/configs/infinispan-xsite-MOON.xml +14 -11
- package/spec/configs/infinispan.xml +22 -13
- package/spec/infinispan_auth_spec.js +16 -37
- package/spec/protostream_spec.js +237 -0
- package/spec/utils/testing.js +1 -3
- package/lib/bitops.js +0 -26
- package/lib/scram.js +0 -116
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var infinispan = require('infinispan');
|
|
2
|
+
|
|
3
|
+
var connected = infinispan.client(
|
|
4
|
+
{port: 11222, host: '127.0.0.1'}
|
|
5
|
+
{
|
|
6
|
+
// Configure client connections with authentication and encryption here.
|
|
7
|
+
}
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
connected.then(function (client) {
|
|
11
|
+
|
|
12
|
+
var clientAddListenerCreate = client.addListener('create', onCreate);
|
|
13
|
+
|
|
14
|
+
var clientAddListeners = clientAddListenerCreate.then(
|
|
15
|
+
function(listenerId) {
|
|
16
|
+
// Associate multiple callbacks with a single client-side listener.
|
|
17
|
+
// To do this, register listeners with the same listener ID.
|
|
18
|
+
var clientAddListenerModify =
|
|
19
|
+
client.addListener('modify', onModify, {listenerId: listenerId});
|
|
20
|
+
|
|
21
|
+
var clientAddListenerRemove =
|
|
22
|
+
client.addListener('remove', onRemove, {listenerId: listenerId});
|
|
23
|
+
|
|
24
|
+
return Promise.all([clientAddListenerModify, clientAddListenerRemove]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var clientCreate = clientAddListeners.then(
|
|
28
|
+
function() { return client.putIfAbsent('eventful', 'v0'); });
|
|
29
|
+
|
|
30
|
+
var clientModify = clientCreate.then(
|
|
31
|
+
function() { return client.replace('eventful', 'v1'); });
|
|
32
|
+
|
|
33
|
+
var clientRemove = clientModify.then(
|
|
34
|
+
function() { return client.remove('eventful'); });
|
|
35
|
+
|
|
36
|
+
var clientRemoveListener =
|
|
37
|
+
Promise.all([clientAddListenerCreate, clientRemove]).then(
|
|
38
|
+
function(values) {
|
|
39
|
+
var listenerId = values[0];
|
|
40
|
+
return client.removeListener(listenerId);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return clientRemoveListener.finally(
|
|
44
|
+
function() { return client.disconnect(); });
|
|
45
|
+
|
|
46
|
+
}).catch(function(error) {
|
|
47
|
+
|
|
48
|
+
console.log("Got error: " + error.message);
|
|
49
|
+
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function onCreate(key, version) {
|
|
53
|
+
console.log('[Event] Created key: ' + key +
|
|
54
|
+
' with version: ' + JSON.stringify(version));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onModify(key, version) {
|
|
58
|
+
console.log('[Event] Modified key: ' + key +
|
|
59
|
+
', version after update: ' + JSON.stringify(version));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function onRemove(key) {
|
|
63
|
+
console.log('[Event] Removed key: ' + key);
|
|
64
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var infinispan = require('infinispan');
|
|
2
|
+
var readFile = Promise.denodeify(require('fs').readFile);
|
|
3
|
+
|
|
4
|
+
var connected = infinispan.client(
|
|
5
|
+
{port: 11222, host: '127.0.0.1'}
|
|
6
|
+
{
|
|
7
|
+
// Configure client connections with authentication and encryption here.
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
connected.then(function (client) {
|
|
12
|
+
|
|
13
|
+
var addScriptFile = readFile('sample-script.js').then(
|
|
14
|
+
function(file) {
|
|
15
|
+
return client.addScript('sample-script', file.toString());
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var clientExecute = addScriptFile.then(
|
|
19
|
+
function() {
|
|
20
|
+
return client.execute('sample-script', {k: 'exec-key', v: 'exec-value'});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var showExecute = clientExecute.then(
|
|
24
|
+
function(ret) { console.log('Script execution returned: ' + ret); });
|
|
25
|
+
|
|
26
|
+
return showExecute.finally(
|
|
27
|
+
function() { return client.disconnect(); });
|
|
28
|
+
|
|
29
|
+
}).catch(function(error) {
|
|
30
|
+
|
|
31
|
+
console.log("Got error: " + error.message);
|
|
32
|
+
|
|
33
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var infinispan = require('infinispan');
|
|
2
|
+
|
|
3
|
+
var connected = infinispan.client(
|
|
4
|
+
{port: 11222, host: '127.0.0.1'},
|
|
5
|
+
{
|
|
6
|
+
cacheName: 'myCache',
|
|
7
|
+
authentication: {
|
|
8
|
+
enabled: true,
|
|
9
|
+
saslMechanism: 'DIGEST-MD5',
|
|
10
|
+
userName: 'username',
|
|
11
|
+
password: 'changeme'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
connected.then(function (client) {
|
|
17
|
+
|
|
18
|
+
var clientPut = client.put('key', 'value');
|
|
19
|
+
|
|
20
|
+
var clientGet = clientPut.then(
|
|
21
|
+
function() { return client.get('key'); });
|
|
22
|
+
|
|
23
|
+
var showGet = clientGet.then(
|
|
24
|
+
function(value) { console.log('get(key)=' + value); });
|
|
25
|
+
|
|
26
|
+
var clientRemove = showGet.then(
|
|
27
|
+
function() { return client.remove('key'); });
|
|
28
|
+
|
|
29
|
+
var showRemove = clientRemove.then(
|
|
30
|
+
function(success) { console.log('remove(key)=' + success); });
|
|
31
|
+
|
|
32
|
+
var clientStats = showRemove.then(
|
|
33
|
+
function() { return client.stats(); });
|
|
34
|
+
|
|
35
|
+
var showStats = clientStats.then(
|
|
36
|
+
function(stats) {
|
|
37
|
+
console.log('Number of stores: ' + stats.stores);
|
|
38
|
+
console.log('Number of cache hits: ' + stats.hits);
|
|
39
|
+
console.log('All statistics: ' + JSON.stringify(stats, null, " "));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return showStats.finally(
|
|
43
|
+
function() { return client.disconnect(); });
|
|
44
|
+
|
|
45
|
+
}).catch(function(error) {
|
|
46
|
+
|
|
47
|
+
console.log("Got error: " + error.message);
|
|
48
|
+
|
|
49
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[id='configuring-authentication_{context}']
|
|
2
|
+
= Configuring authentication
|
|
3
|
+
|
|
4
|
+
{brandname} Server uses different SASL mechanisms to authenticate {hr_js} client connections.
|
|
5
|
+
|
|
6
|
+
.Prerequisites
|
|
7
|
+
|
|
8
|
+
* Create {brandname} users.
|
|
9
|
+
* Add the SASL authentication mechanism to the Hot Rod connector in your {brandname} Server configuration.
|
|
10
|
+
|
|
11
|
+
.Procedure
|
|
12
|
+
|
|
13
|
+
. Open the {hr_js} client configuration for editing.
|
|
14
|
+
. Add an `authentication` method that sets the `enabled: true` flag.
|
|
15
|
+
. Specify a value for the `saslMechanism` parameter that matches the SASL authentication mechanism for the Hot Rod connector.
|
|
16
|
+
. Configure any parameters specific to the SASL authentication mechanism as appropriate.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[id='configuring-connections_{context}']
|
|
2
|
+
= Configuring {brandname} connections
|
|
3
|
+
Configure {hr_js} clients to connect to {brandname} Server.
|
|
4
|
+
|
|
5
|
+
If add multiple server addresses to the configuration, the {hr_js} client loops through them until it finds a node to which it can connect.
|
|
6
|
+
|
|
7
|
+
However, you only need to add one {brandname} Server address for the client to receive the entire cluster topology.
|
|
8
|
+
If the {hr_js} client connects to a single server instance that is a member of a cluster, the client gets the address information for all nodes.
|
|
9
|
+
|
|
10
|
+
Because {hr_js} clients are topology aware, if a connection to one {brandname} Server breaks, the client retries any incomplete operations on other nodes in the cluster.
|
|
11
|
+
Likewise, if client listener that is registered on one {brandname} Server fails or leaves the cluster, the client transparently migrates the listener registration to another node in the cluster so that it can continue receiving events.
|
|
12
|
+
|
|
13
|
+
.Prerequisites
|
|
14
|
+
|
|
15
|
+
* Install the {hr_js} client.
|
|
16
|
+
* Have at least one running {brandname} Server instance.
|
|
17
|
+
|
|
18
|
+
.Procedure
|
|
19
|
+
|
|
20
|
+
* Specify hostnames and ports for {brandname} Server in the client configuration.
|
|
21
|
+
+
|
|
22
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
23
|
+
----
|
|
24
|
+
include::code_examples/connection-multiple-servers.js[]
|
|
25
|
+
----
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[id='configuring-connections-cross-site_{context}']
|
|
2
|
+
= Defining {brandname} clusters in client configuration
|
|
3
|
+
When you set up {brandname} clusters in separate data centers to perform cross-site replication, you can add connection details for the different sites to the client configuration.
|
|
4
|
+
|
|
5
|
+
.Prerequisites
|
|
6
|
+
|
|
7
|
+
* Install the {hr_js} client.
|
|
8
|
+
* Configure {brandname} for cross-site replication.
|
|
9
|
+
|
|
10
|
+
.Procedure
|
|
11
|
+
|
|
12
|
+
. Add a `clusters` definition to your configuration.
|
|
13
|
+
. Add `name` and `servers` definitions for each {brandname} cluster.
|
|
14
|
+
+
|
|
15
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
16
|
+
----
|
|
17
|
+
include::code_examples/connection-xsite.js[]
|
|
18
|
+
----
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[id='configuring-data-formats_{context}']
|
|
2
|
+
= Configuring data formats
|
|
3
|
+
{hr_js} clients can handle keys and values as native JavaScript Object Notation (JSON) objects or as String objects.
|
|
4
|
+
By default, clients handle entries as String objects.
|
|
5
|
+
If you want to transmit data to {brandname} Server in JSON format, then you must configure the {hr_js} client.
|
|
6
|
+
|
|
7
|
+
//Community content
|
|
8
|
+
ifdef::community[]
|
|
9
|
+
Starting at version 0.6, {hr_js} clients support native JSON objects as keys and values.
|
|
10
|
+
Earlier versions of the client support keys and values as String only.
|
|
11
|
+
endif::community[]
|
|
12
|
+
|
|
13
|
+
[NOTE]
|
|
14
|
+
====
|
|
15
|
+
Script operations support String key/value pairs and String parameters only.
|
|
16
|
+
====
|
|
17
|
+
|
|
18
|
+
.Procedure
|
|
19
|
+
|
|
20
|
+
. Add a `dataFormat` configuration to your client.
|
|
21
|
+
. Set the data format for keys and values as appropriate with the `keyType` and `valueType` parameters.
|
|
22
|
+
|
|
23
|
+
Keys and values can have different media types.
|
|
24
|
+
For JSON objects, specify `application/json`.
|
|
25
|
+
For String objects, specify `text/plain` or omit the parameter to use the default.
|
|
26
|
+
|
|
27
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
28
|
+
----
|
|
29
|
+
include::code_examples/data-types.js[]
|
|
30
|
+
----
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[id='configuring-encryption_{context}']
|
|
2
|
+
= Configuring encryption
|
|
3
|
+
|
|
4
|
+
{brandname} Server can enforce different types of SSL/TLS encryption to secure {hr_js} client connections.
|
|
5
|
+
|
|
6
|
+
.Prerequisites
|
|
7
|
+
|
|
8
|
+
* Create a trust store that {hr_js} clients can use to verify {brandname} Server identities.
|
|
9
|
+
* If you configure {brandname} Server to validate or authenticate client certificates, create a keystore as appropriate.
|
|
10
|
+
|
|
11
|
+
.Procedure
|
|
12
|
+
|
|
13
|
+
. Open the {hr_js} client configuration for editing.
|
|
14
|
+
. Add an `ssl` method that sets the `enabled: true` flag.
|
|
15
|
+
. Provide any other configuration specific to the type of encryption you use.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[id='configuring-logging_{context}']
|
|
2
|
+
= Configuring logging
|
|
3
|
+
|
|
4
|
+
{hr_js} clients use `log4js`, which you can modify by providing configuration in JSON format.
|
|
5
|
+
|
|
6
|
+
.Procedure
|
|
7
|
+
|
|
8
|
+
. Create a logging configuration in JSON format.
|
|
9
|
+
+
|
|
10
|
+
For example, the following JSON configures an appender that writes TRACE level log events to file:
|
|
11
|
+
+
|
|
12
|
+
[source,json,options="nowrap",subs=attributes+]
|
|
13
|
+
----
|
|
14
|
+
include::config_examples/logging.json[]
|
|
15
|
+
----
|
|
16
|
+
+
|
|
17
|
+
. Add the `var log4js = require('log4js')` statement to the {hr_js} client configuration.
|
|
18
|
+
. Specify the path to your JSON logging configuration with the `log4js.configure()` method, as in the following example:
|
|
19
|
+
+
|
|
20
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
21
|
+
----
|
|
22
|
+
include::code_examples/logging-configuration.js[]
|
|
23
|
+
----
|
|
24
|
+
|
|
25
|
+
[role="_additional-resources"]
|
|
26
|
+
.Additional resources
|
|
27
|
+
* link:https://www.npmjs.com/package/log4js[log4js]
|
|
28
|
+
* link:https://github.com/log4js-node/log4js-node/tree/master/examples[log4js-node examples]
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[id='installing-clients_{context}']
|
|
2
|
+
= Installing {hr_js} clients
|
|
3
|
+
{brandname} provides a distribution of the {hr_js} client that you can install via the NPM package manager.
|
|
4
|
+
|
|
5
|
+
.Prerequisites
|
|
6
|
+
|
|
7
|
+
* Node.js version `12` or `14`.
|
|
8
|
+
//Community content
|
|
9
|
+
ifdef::community[]
|
|
10
|
+
* {brandname} Server 9.4.x or later.
|
|
11
|
+
+
|
|
12
|
+
Use js-client `0.7` for {brandname} Server `8.2.x` to `9.3.x`.
|
|
13
|
+
endif::community[]
|
|
14
|
+
//Downstream content
|
|
15
|
+
ifdef::downstream[]
|
|
16
|
+
* {brandname} Server {ProductVersion}.
|
|
17
|
+
endif::downstream[]
|
|
18
|
+
|
|
19
|
+
.Procedure
|
|
20
|
+
|
|
21
|
+
//Community content
|
|
22
|
+
ifdef::community[]
|
|
23
|
+
* Install the `infinispan` client as follows:
|
|
24
|
+
+
|
|
25
|
+
[source,options="nowrap",subs=attributes+]
|
|
26
|
+
----
|
|
27
|
+
npm install infinispan
|
|
28
|
+
----
|
|
29
|
+
endif::community[]
|
|
30
|
+
|
|
31
|
+
//Downstream content
|
|
32
|
+
ifdef::rhdg-install-npmrepo[]
|
|
33
|
+
. Add the Red Hat repository to your NPM configuration.
|
|
34
|
+
+
|
|
35
|
+
You can use the `npm config` command or add the following to an `.npmrc` file in your project:
|
|
36
|
+
+
|
|
37
|
+
[source,options="nowrap",subs=attributes+]
|
|
38
|
+
----
|
|
39
|
+
@redhat:registry=https://npm.registry.redhat.com
|
|
40
|
+
registry=https://registry.npmjs.org/
|
|
41
|
+
----
|
|
42
|
+
|
|
43
|
+
. Install the {hr_js} client as follows:
|
|
44
|
+
+
|
|
45
|
+
[source,options="nowrap",subs=attributes+]
|
|
46
|
+
----
|
|
47
|
+
npm install @redhat/infinispan
|
|
48
|
+
----
|
|
49
|
+
endif::rhdg-install-npmrepo[]
|
|
50
|
+
ifdef::rhdg-install-package[]
|
|
51
|
+
. Download and extract the `redhat-datagrid-<version>-nodejs-client.zip` from the {portal}.
|
|
52
|
+
. Install the `tgz` package from the extracted directory as in the following example:
|
|
53
|
+
+
|
|
54
|
+
[source,bash,options="nowrap",subs=attributes+]
|
|
55
|
+
----
|
|
56
|
+
npm install /path/to/redhat-datagrid-<version>-nodejs-client/infinispan-<version>.tgz
|
|
57
|
+
----
|
|
58
|
+
endif::rhdg-install-package[]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[id='switching-clusters_{context}']
|
|
2
|
+
= Manually switching {brandname} clusters
|
|
3
|
+
Change the {brandname} cluster to which the {hr_js} client is connectioned.
|
|
4
|
+
|
|
5
|
+
.Prerequisites
|
|
6
|
+
|
|
7
|
+
* Define {brandname} clusters in the {hr_js} client configuration.
|
|
8
|
+
|
|
9
|
+
.Procedure
|
|
10
|
+
|
|
11
|
+
. Call the `switchToCluster(clusterName)` method to force the client to switch to a {brandname} cluster that is defined in the client configuration.
|
|
12
|
+
. Call the `switchToDefaultCluster()` method to start using the initial {brandname} cluster.
|
|
13
|
+
+
|
|
14
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
15
|
+
----
|
|
16
|
+
include::code_examples/connection-xsite-cluster-switch.js[]
|
|
17
|
+
----
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[id='authentication-mechanisms_{context}']
|
|
2
|
+
= SASL authentication mechanisms
|
|
3
|
+
|
|
4
|
+
{hr_js} clients can use the following SASL authentication mechanisms to connect to {brandname} Server.
|
|
5
|
+
|
|
6
|
+
[discrete]
|
|
7
|
+
== PLAIN
|
|
8
|
+
|
|
9
|
+
Sends credentials in plain text (unencrypted) over the wire in a way that is similar to HTTP `BASIC` authentication.
|
|
10
|
+
|
|
11
|
+
[IMPORTANT]
|
|
12
|
+
====
|
|
13
|
+
To secure {brandname} credentials, you should use `PLAIN` authentication only in combination with TLS encryption.
|
|
14
|
+
====
|
|
15
|
+
|
|
16
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
17
|
+
----
|
|
18
|
+
include::code_examples/authentication-plain.js[]
|
|
19
|
+
----
|
|
20
|
+
|
|
21
|
+
[discrete]
|
|
22
|
+
== DIGEST-MD5
|
|
23
|
+
|
|
24
|
+
Uses the MD5 hashing algorithm in addition to nonces to encrypt credentials.
|
|
25
|
+
|
|
26
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
27
|
+
----
|
|
28
|
+
include::code_examples/authentication-digest.js[]
|
|
29
|
+
----
|
|
30
|
+
|
|
31
|
+
[discrete]
|
|
32
|
+
== SCRAM
|
|
33
|
+
|
|
34
|
+
Uses salt values in addition to hashing algorithms and nonce values to encrypt credentials.
|
|
35
|
+
Hot Rod endpoints support `SCRAM-SHA-1`, `SCRAM-SHA-256`, `SCRAM-SHA-384`, `SCRAM-SHA-512` hashing algorithms, in order of strength.
|
|
36
|
+
|
|
37
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
38
|
+
----
|
|
39
|
+
include::code_examples/authentication-scram.js[]
|
|
40
|
+
----
|
|
41
|
+
|
|
42
|
+
//Community content
|
|
43
|
+
ifdef::community[]
|
|
44
|
+
[discrete]
|
|
45
|
+
== EXTERNAL
|
|
46
|
+
|
|
47
|
+
Uses client certificates to provide valid identities to {brandname} Server and enable encryption.
|
|
48
|
+
|
|
49
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
50
|
+
----
|
|
51
|
+
include::code_examples/authentication-external.js[]
|
|
52
|
+
----
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
[discrete]
|
|
56
|
+
== OAUTHBEARER
|
|
57
|
+
|
|
58
|
+
Uses tokens obtained via an OAuth 2.0 provider to securely connect to {brandname} Server.
|
|
59
|
+
|
|
60
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
61
|
+
----
|
|
62
|
+
include::code_examples/authentication-oauthbearer.js[]
|
|
63
|
+
----
|
|
64
|
+
endif::community[]
|
|
65
|
+
|
|
66
|
+
[role="_additional-resources"]
|
|
67
|
+
.Additional resources
|
|
68
|
+
* link:{server_docs}#endpoint-authentication[Configuring Endpoint Authentication Mechanisms]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[id='client-usage_{context}']
|
|
2
|
+
= {hr_js} client examples
|
|
3
|
+
|
|
4
|
+
After you install and configure your {hr_js} client, start using it by trying out some basic cache operations before moving on to more complex interactions with {brandname}.
|
|
5
|
+
|
|
6
|
+
== Hello world
|
|
7
|
+
|
|
8
|
+
Create a cache named "myCache" on {brandname} Server then add and retrieve an entry.
|
|
9
|
+
|
|
10
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
11
|
+
----
|
|
12
|
+
include::code_examples/hello-world.js[]
|
|
13
|
+
----
|
|
14
|
+
|
|
15
|
+
== Working with entries and retrieving cache statistics
|
|
16
|
+
|
|
17
|
+
Add, retrieve, remove single entries and view statistics for the cache.
|
|
18
|
+
|
|
19
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
20
|
+
----
|
|
21
|
+
include::code_examples/single-entries.js[]
|
|
22
|
+
----
|
|
23
|
+
|
|
24
|
+
== Working with multiple cache entries
|
|
25
|
+
|
|
26
|
+
Create multiple cache entries with simple recursive loops.
|
|
27
|
+
|
|
28
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
29
|
+
----
|
|
30
|
+
include::code_examples/multiple-entries.js[]
|
|
31
|
+
----
|
|
32
|
+
|
|
33
|
+
== Using Async and Await constructs
|
|
34
|
+
|
|
35
|
+
Node.js provides `async` and `await` constructs that can simplify cache operations.
|
|
36
|
+
|
|
37
|
+
.Single cache entries
|
|
38
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
39
|
+
----
|
|
40
|
+
include::code_examples/await-single-entries.js[]
|
|
41
|
+
----
|
|
42
|
+
|
|
43
|
+
.Multiple cache entries
|
|
44
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
45
|
+
----
|
|
46
|
+
include::code_examples/await-multiple-entries.js[]
|
|
47
|
+
----
|
|
48
|
+
|
|
49
|
+
== Running server-side scripts
|
|
50
|
+
|
|
51
|
+
You can add custom scripts to {brandname} Server and then run them from {hr_js} clients.
|
|
52
|
+
|
|
53
|
+
.Sample script
|
|
54
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
55
|
+
----
|
|
56
|
+
include::code_examples/sample-script.js[]
|
|
57
|
+
----
|
|
58
|
+
|
|
59
|
+
.Script execution
|
|
60
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
61
|
+
----
|
|
62
|
+
include::code_examples/sample-script-execute.js[]
|
|
63
|
+
----
|
|
64
|
+
|
|
65
|
+
== Registering event listeners
|
|
66
|
+
|
|
67
|
+
Event listeners notify {hr_js} clients when cache updates occur, including when entries are created, modified, removed, or expired.
|
|
68
|
+
|
|
69
|
+
[NOTE]
|
|
70
|
+
====
|
|
71
|
+
Events for entry creation and modification notify clients about keys and values.
|
|
72
|
+
Events for entry removal and expiration notify clients about keys only.
|
|
73
|
+
====
|
|
74
|
+
|
|
75
|
+
.Event listener registration
|
|
76
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
77
|
+
----
|
|
78
|
+
include::code_examples/register-event-listener.js[]
|
|
79
|
+
----
|
|
80
|
+
|
|
81
|
+
You can tune notifications from event listeners to avoid unnecessary roundtrips with the `key-value-with-previous-converter-factory` converter.
|
|
82
|
+
This allows you to, for example, find out values associated with keys within the event instead of retrieving them afterwards.
|
|
83
|
+
|
|
84
|
+
.Remote event converter
|
|
85
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
86
|
+
----
|
|
87
|
+
include::code_examples/key-value-converter.js[]
|
|
88
|
+
----
|
|
89
|
+
|
|
90
|
+
[TIP]
|
|
91
|
+
====
|
|
92
|
+
You can add custom converters to {brandname} Server.
|
|
93
|
+
See the link:{doc_home}[{brandname} documentation] for information.
|
|
94
|
+
====
|
|
95
|
+
|
|
96
|
+
== Using conditional operations
|
|
97
|
+
|
|
98
|
+
The Hot Rod protocol stores metadata about values in {brandname}.
|
|
99
|
+
This metadata provides a deterministic factor that lets you perform cache operations for certain conditions.
|
|
100
|
+
For example, if you want to replace the value of a key if the versions do not match.
|
|
101
|
+
|
|
102
|
+
Use the `getWithMetadata` method to retrieve metadata associated with the value for a key.
|
|
103
|
+
|
|
104
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
105
|
+
----
|
|
106
|
+
include::code_examples/conditional-operations.js[]
|
|
107
|
+
----
|
|
108
|
+
|
|
109
|
+
== Working with ephemeral data
|
|
110
|
+
|
|
111
|
+
Use the `getWithMetadata` and `size` methods expire cache entries.
|
|
112
|
+
|
|
113
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
114
|
+
----
|
|
115
|
+
include::code_examples/ephemeral-data.js[]
|
|
116
|
+
----
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[id='encryption_{context}']
|
|
2
|
+
= Encryption types
|
|
3
|
+
|
|
4
|
+
{hr_js} clients can use different types of encryption to negotiate secure connections with {brandname} Server.
|
|
5
|
+
|
|
6
|
+
[discrete]
|
|
7
|
+
== {brandname} Server identities
|
|
8
|
+
|
|
9
|
+
For basic encryption, you can add the signing certificate, or CA bundle, for {brandname} Server certificates to your configuration as follows:
|
|
10
|
+
|
|
11
|
+
[NOTE]
|
|
12
|
+
====
|
|
13
|
+
To verify certificates issued to {brandname} Server, {hr_js} clients require either the full certificate chain or a partial chain that starts with the Root CA.
|
|
14
|
+
====
|
|
15
|
+
|
|
16
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
17
|
+
----
|
|
18
|
+
include::code_examples/encryption-trust-certs.js[]
|
|
19
|
+
----
|
|
20
|
+
|
|
21
|
+
[discrete]
|
|
22
|
+
== Trust stores
|
|
23
|
+
|
|
24
|
+
You can add trust stores in `PKCS12` or `PFX` format as follows:
|
|
25
|
+
|
|
26
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
27
|
+
----
|
|
28
|
+
include::code_examples/encryption-crypto-store.js[]
|
|
29
|
+
----
|
|
30
|
+
|
|
31
|
+
[discrete]
|
|
32
|
+
== Client certificate authentication
|
|
33
|
+
|
|
34
|
+
If you enable client certificate authentication in {brandname} Server configuration, add a keystore as in the following example:
|
|
35
|
+
|
|
36
|
+
[NOTE]
|
|
37
|
+
====
|
|
38
|
+
You must configure the {hr_js} client with the `EXTERNAL` authentication mechanism when using client certificate authentication.
|
|
39
|
+
====
|
|
40
|
+
|
|
41
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
42
|
+
----
|
|
43
|
+
include::code_examples/encryption-private-key.js[]
|
|
44
|
+
----
|
|
45
|
+
|
|
46
|
+
[discrete]
|
|
47
|
+
== Server Name Indication (SNI)
|
|
48
|
+
|
|
49
|
+
If you use SNI to allow {hr_js} clients to request {brandname} Server hostnames, set a value for the `sniHostName` parameter that matches a hostname in the {brandname} Server configuration.
|
|
50
|
+
|
|
51
|
+
[NOTE]
|
|
52
|
+
====
|
|
53
|
+
The `sniHostName` parameter defaults to `localhost`.
|
|
54
|
+
====
|
|
55
|
+
|
|
56
|
+
[source,javascript,options="nowrap",subs=attributes+]
|
|
57
|
+
----
|
|
58
|
+
include::code_examples/encryption-sni-hostname.js[]
|
|
59
|
+
----
|
|
60
|
+
|
|
61
|
+
[TIP]
|
|
62
|
+
====
|
|
63
|
+
{hr_js} clients do not allow self-signed certificates by default, which can cause issues in development or test environments where no public certificate authority (CA) key is available.
|
|
64
|
+
|
|
65
|
+
Check out the link:{code_tutorials}[{brandname} code tutorials] for an example on creating signed certificates with the Java keytool.
|
|
66
|
+
====
|
|
67
|
+
|
|
68
|
+
[role="_additional-resources"]
|
|
69
|
+
.Additional resources
|
|
70
|
+
* link:{server_docs}#interfaces-endpoints[Network interfaces and endpoints]
|
|
71
|
+
* link:{server_docs}#endpoint-encryption[Encrypting {brandname} Server connections]
|