Using a Safe

As we've seen, the Safe file contains plain text, so you can use it for any purpose. For example for storing all the passwords you need to remember. If you store text in the form:

# This is a comment
Name=Value
Another=Something Else 		
		

then the file can be read as properties, which can be used to parameterize a report or datasource. To use these external properties within a report, you put a script in your Report OnRenderBegin:

var props = elxfn.getSafeProperties("/Workspace/Data.safe","pass");
setParameters(props); 		
		

where "pass" is the password to unlock the Safe. The call to setParameters adds the name=value pairs into the report parameter list, so they will be passed to datasources etc. as required. Another benefit of this approach is that it allows you to share a common set of properties across multiple reports and datasources.

If you don't want to hardcode the password in the script, you can get it from another parameter:

var pass = getParameterValue("Password");
var props = elxfn.getSafeProperties("/Workspace/Data.safe",pass);
setParameters(props); 		
		

This can either read Pass from the Report parameters, or prompt for a dynamic parameter as you choose.

The Safe is also useful in conjunction with the Remote Designer as you can edit the file on the client and all network traffic and the server will only see the encrypted file contents.