Listing security objects (keys) requires a Self-Defending KMS account, a group, and a user or application configured in that group. You must also have one or more security objects in that group to have any results returned. See the Self-Defending KMS Getting Started Guide for more details.
Authorization and Configuration
You must first authenticate and optionally configure a default API client as described in Configure API Client and Client Authentication. You may authenticate as a user or as an app. Using the API, you may list all keys belonging to all groups that the user or app belongs to.
Create a SecurityObjectsApi Client Object
Listing keys is performed with a SecurityObjectsApi object.
import com.fortanix.sdkms.v1.api.SecurityObjectsApi(); SecurityObjectsApi sobjectsApi = new SecurityObjectsApi();
List All Keys
The getSecurityObjects method of SecurityObjectsApi can return a list of all of the security objects that the currently authorized entity can access.
import com.fortanix.sdkms.v1.model.KeyObject; List<KeyObject> allKeys = sobjectsApi.getSecurityObjects(null, null, null, null);
Get a Key by Name
The getSecurityObjects() method can also be used to look up keys by name. The first parameter of this method restricts the returned value to only the security object with the requested name.
List<KeyObject> match = sobjectsApi.getSecurityObjects("example-key", null, null, null);
Filter By Group or Creator
The final three parameters of the getSecurityObjects() method filter the returned objects by group id, creator app id, and creator user id, respectively.
List<KeyObject> matchingKeys = sobjectsApi.getSecurityObjects(null, <group id>, null, null); List<KeyObject> matchingKeys = sobjectsApi.getSecurityObjects(null, null, <creator app id>, null); List<KeyObject> matchingKeys = sobjectsApi.getSecurityObjects(null, null, null, <creator user id>);
Get a Key by Key ID (UUID)
The getSecurityObject() method of SecurityObjectsApi will look up and return a specific key by UUID.