SDK Java v2.x

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

addPolicy #

Adds a role to the security profile.

Updating a security profile will have no impact until the save method is called

addPolicy(id) #

Arguments Type Description
id string Unique id of the new role to associate

addPolicy(policy) #

Arguments Type Description
policy JSON Object policy instance corresponding to the new associated role and its restrictions

Return Value #

Returns the Profile object to allow chaining calls.

Usage #

Copied to clipboard!
JSONObject policy = new JSONObject()
  .put("roleId", "some role id")
  .put("restrictedTo", new JSONArray()
    .put(new JSONObject().put("index", "index1"))
    .put(new JSONObject()
      .put("index", "index2")
      .put("collections", new JSONArray().put("foo").put("bar"))
// you may also add a role ID directly
profile.addPolicy("some role id");