Configuring security policy for FreeMarker
When FreeMarker is used in a Java virtual machine with a
security manager installed, you have to grant it few permissions to
ensure it operates properly. Most notably, you need these entries to
your security policy file for
freemarker.jar:
| | |
|
grant codeBase "file:/path/to/freemarker.jar"
{
permission java.util.PropertyPermission "file.encoding", "read";
permission java.util.PropertyPermission "freemarker.*", "read";
} |
| |
| | |
Additionally, if you are loading templates from a directory, you
need to give FreeMarker permissions to read files from that directory
using the following permission:
| | |
|
grant codeBase "file:/path/to/freemarker.jar"
{
...
permission java.io.FilePermission "/path/to/templates/-", "read";
} |
| |
| | |
Finally, if you're just using the default template loading
mechanism which loads templates from the current directory, then
specify these permissions additionally: (note that the expression
${user.dir} will be evaluated at run time by the
policy interpreter, pretty much as if it were a FreeMarker
template)
| | |
|
grant codeBase "file:/path/to/freemarker.jar"
{
...
permission java.util.PropertyPermission "user.dir", "read";
permission java.io.FilePermission "${user.dir}/-", "read";
} |
| |
| | |
Naturally, if you're running under Windows, use double backslash
instead of a single slash for separating directory components in
paths.