本文整理了Java中freemarker.template.Configuration.setNewBuiltinClassResolver()
方法的一些代码示例,展示了Configuration.setNewBuiltinClassResolver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.setNewBuiltinClassResolver()
方法的具体详情如下:
包路径:freemarker.template.Configuration
类名称:Configuration
方法名:setNewBuiltinClassResolver
暂无
代码示例来源:origin: geoserver/geoserver
/**
* Get a Freemarker configuration that is safe against malicious templates
*
* @return
*/
public static Configuration getSafeConfiguration() {
Configuration config = new Configuration();
config.setNewBuiltinClassResolver(
(name, env, template) -> {
if (ILLEGAL_FREEMARKER_CLASSES.stream().anyMatch(name::equals)) {
throw new TemplateException(
String.format(
"Class %s is not allowed in Freemarker templates", name),
env);
}
if (LEGAL_FREEMARKER_CLASSES.stream().anyMatch(name::equals)) {
try {
ClassUtil.forName(name);
} catch (ClassNotFoundException e) {
throw new TemplateException(e, env);
}
}
return TemplateClassResolver.SAFER_RESOLVER.resolve(name, env, template);
});
return config;
}
}
代码示例来源:origin: sanluan/PublicCMS
/**
*
*/
public GetTemplateResultMethod() {
configuration = new Configuration(Configuration.getVersion());
configuration.setDefaultEncoding(CommonConstants.DEFAULT_CHARSET_NAME);
configuration.setTemplateUpdateDelayMilliseconds(0);
configuration.setAPIBuiltinEnabled(false);
configuration.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
configuration.setLogTemplateExceptions(false);
}
代码示例来源:origin: sanluan/PublicCMS
/**
*
*/
public GetTemplateResultMethod() {
configuration = new Configuration(Configuration.getVersion());
configuration.setDefaultEncoding(CommonConstants.DEFAULT_CHARSET_NAME);
configuration.setTemplateUpdateDelayMilliseconds(0);
configuration.setAPIBuiltinEnabled(false);
configuration.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
configuration.setLogTemplateExceptions(false);
}
代码示例来源:origin: sanluan/PublicCMS
private static void copyConfig(Configuration source, Configuration target) {
target.setNewBuiltinClassResolver(source.getNewBuiltinClassResolver());
target.setTemplateUpdateDelayMilliseconds(source.getTemplateUpdateDelayMilliseconds());
target.setDefaultEncoding(source.getDefaultEncoding());
target.setLocale(source.getLocale());
target.setBooleanFormat(source.getBooleanFormat());
target.setDateTimeFormat(source.getDateTimeFormat());
target.setDateFormat(source.getDateFormat());
target.setTimeFormat(source.getTimeFormat());
target.setNumberFormat(source.getNumberFormat());
target.setOutputFormat(source.getOutputFormat());
target.setURLEscapingCharset(source.getURLEscapingCharset());
target.setLazyAutoImports(source.getLazyAutoImports());
target.setTemplateExceptionHandler(source.getTemplateExceptionHandler());
}
代码示例来源:origin: sanluan/PublicCMS
private static void copyConfig(Configuration source, Configuration target) {
target.setNewBuiltinClassResolver(source.getNewBuiltinClassResolver());
target.setTemplateUpdateDelayMilliseconds(source.getTemplateUpdateDelayMilliseconds());
target.setDefaultEncoding(source.getDefaultEncoding());
target.setLocale(source.getLocale());
target.setBooleanFormat(source.getBooleanFormat());
target.setDateTimeFormat(source.getDateTimeFormat());
target.setDateFormat(source.getDateFormat());
target.setTimeFormat(source.getTimeFormat());
target.setNumberFormat(source.getNumberFormat());
target.setOutputFormat(source.getOutputFormat());
target.setURLEscapingCharset(source.getURLEscapingCharset());
target.setLazyAutoImports(source.getLazyAutoImports());
target.setTemplateExceptionHandler(source.getTemplateExceptionHandler());
}
代码示例来源:origin: org.alfresco/alfresco-repository
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
// custom template loader
cfg.setTemplateLoader(new TemplateWebScriptLoader(ctx.getRepoEndPoint(), ctx.getTicket()));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
代码示例来源:origin: Alfresco/alfresco-repository
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
// custom template loader
cfg.setTemplateLoader(new TemplateWebScriptLoader(ctx.getRepoEndPoint(), ctx.getTicket()));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
代码示例来源:origin: org.alfresco/alfresco-repository
@Override
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
if (useRemoteCallbacks)
{
// as per 3.0, 3.1
return super.getFreemarkerConfiguration(ctx);
}
else
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, contentService, defaultEncoding));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
}
代码示例来源:origin: Alfresco/alfresco-repository
@Override
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
if (useRemoteCallbacks)
{
// as per 3.0, 3.1
return super.getFreemarkerConfiguration(ctx);
}
else
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, contentService, defaultEncoding));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
}
代码示例来源:origin: org.alfresco/alfresco-repository
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
代码示例来源:origin: Alfresco/alfresco-repository
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
代码示例来源:origin: org.alfresco/alfresco-repository
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
代码示例来源:origin: Alfresco/alfresco-repository
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
stringConfig.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
代码示例来源:origin: org.alfresco.surf/spring-webscripts
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
stringConfig.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
内容来源于网络,如有侵权,请联系作者删除!