EncryptionKeys (NotesDocument - JavaScript)

Read-Write. The key(s) used to encrypt a document.

Defined in

NotesDocument

Syntax

getEncryptionKeys() : java.util.Vector

setEncryptionKeys(keys:any) : java.util.Vector

Usage

The encrypt method uses these keys when it encrypts the document.

Each element in EncryptionKeys contains the name of an encryption key that you want to use to encrypt the document. The document can be decrypted by any user who possesses one of the keys. If there are no encryption keys specified for a document, the document is encrypted with the current user's public key and can only be decrypted by that user.

You must call the encrypt and save methods to actually encrypt the document. Since encryption works differently when a document is mailed, the EncryptionKeys property has no effect when a document is encrypted when mailed.

The name of each encryption key in a document is stored in a text item called SecretEncryptionKeys. This property returns the contents of the item.

Examples

This button adds an encryption key to the current document.
var query:string = requestScope.query;
if (query.isEmpty()) {
	requestScope.status = "No key specified";
	return;
}
var doc:NotesDocument = currentDocument.getDocument();
var keys:java.util.Vector = doc.getEncryptionKeys();
if (!keys.isEmpty()) {
	var keysi = keys.iterator();
	while (keysi.hasNext()) {
		if (keysi.next().equals(query)) {
			requestScope.status = "This key already exists";
			return;
		}
	}
}
keys.addElement(query);
doc.setEncryptionKeys(keys);
doc.save();
requestScope.status = "Key added";