LPS-39254 Avoid doPrivileged call in processTemplate, when security is not required

Ray, we missed one important part.

The code is not very elegant, ideally we should move the AccessController.doPrivileged() call from FreeMarkerTemplate/VelocityTemplate to PrivilegedTemplateWrapper.

But because the current logic impl, it is not doable.

Once you finished the statical security manager change, we may want to revisit this one to try to move the AccessController.doPrivileged() into PrivilegedTemplateWrapper.