Get Key Names
To get a list of names of the user keys and global keys on Key Manager, you must pass the session object to the getKeyNames method. The NAE Server then returns the key, provided that the key is accessible to the authenticated user.
List key names with user keys and global keys without any criterion
Create an NAESession object.
Obtain an instance of the key using the getKeyNames method of the NAEKey class. Pass the NAESession object as an argument.
NAESession session = NAESession.getSession("user1", "password1".toCharArray()); UserKeysDetail keyNames = NAEKey.getKeyNames(NAESession);
For global sessions, set the
NAESession
parameter to null.The first 10,000 key names are returned.
The maximum number of keys returned is dependent on the Key Manager limit. It returns keys in chronological order. i.e. the order in which keys are generated. As of now, Key Manager supports 10,000 keys in a single operation.
List key names with user keys and global keys on the basis of a criterion
Create an
NAESession
object.Obtain an instance of the key using the
getKeyNames
method of theNAEKey
class. Pass theNAESession
object as an argument.NAESession session = NAESession.getSession("user1", "password1".toCharArray()); UserKeysDetail keyNames = NAEKey.getKeyNames(attributeName, attributeValue, fingerprint,offset, max, session);
Attribute: the custom attribute name, set for the key; to be used for the filtering criteria. This can be set to null.
Value: the custom attribute value for the attribute name given above. Attribute and Value parameters must be used together and both must be set to null together.
Fingerprint: the parameter set to get the key based on fingerprint. Fingerprint is unique for each key. It is an optional parameter and can be passed as null.
Offset: the start Offset value to be used for getting the keys. Minimum value can be 0.
Maxkeys: the max key names to be retrieved, starting from the offset. As of now Key Manager returns only 10000 key names in each request.
List key names with user keys and global keys on the basis of multiple custom criteria
Create an
NAESession
object.Obtain an instance of the key using the
getKeyNames
method of theNAEKey
class. Pass theNAESession
object as an argument.NAESession session = NAESession.getSession("user1", "password1".toCharArray()); CustomAttributes attr = new CustomAttributes(); attr.addAttributeForKeyName(attributeName1, attributeValue1); attr.addAttributeForKeyName(attributeName2, attributeValue2); UserKeysDetail keyNames = NAEKey.getKeyNames(attr, fingerPrint, keyOffset,maxKeys, session,operator));
attr: the custom attribute name and value set for the key; to be used for the filtering criteria. Multiple names and values can be passed here. Maximum 50 attributes can be used for search query.
Note
Custom attributes should be present under the NAE tab of key on CM.
fingerPrint - the parameter set to get the key based on fingerprint. Fingerprint is unique for each key. It is an optional parameter and can be passed as null.
keyOffset: the start Offset value to be used for getting the keys. Minimum value can be 0.
maxKeys: the maximum number of key names to be retrieved, starting from the offset. As of now Key Manager returns only 10000 key names in each request.
session: object of NAESession.
operator: a ConjunctiveOperator enum. Possible values are AND and OR. Default value depends on the operator value set on Key Manager.
Following are the functions supported by the object, to provide the list and the total count of the returned key names matching the criteria.
UserKeyDetailObject.getKeyCount(): Gives the total count of key names returned in the list. This can be less than the total keys as the maximum key names that can be retrieved in single call of
NAEKey.getKeyNames
is 10,000.UserKeyDetailObject.getTotalKeys(): Gives the total number of keys that match the filter criteria.
UserKeyDetailObject.getKeyNames(): Gives the list of the returned key names.