当前位置: 首页>>代码示例>>Java>>正文


Java DefaultEncoder类代码示例

本文整理汇总了Java中org.owasp.esapi.reference.DefaultEncoder的典型用法代码示例。如果您正苦于以下问题:Java DefaultEncoder类的具体用法?Java DefaultEncoder怎么用?Java DefaultEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultEncoder类属于org.owasp.esapi.reference包,在下文中一共展示了DefaultEncoder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeHtml

import org.owasp.esapi.reference.DefaultEncoder; //导入依赖的package包/类
/**
 * Using ESAPI HTML Encoder, encodes the supplied html string.
 * @param html the string to be encoded.
 * @return the encoded string.
 */
private String encodeHtml(String html) {
    Encoder encoder = DefaultEncoder.getInstance();
    String s = encoder.encodeForHTML(html);
    return s;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:11,代码来源:JSONStringXSSDeserializer.java

示例2: fixParams

import org.owasp.esapi.reference.DefaultEncoder; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String[] fixParams(final String name, final String url, final String[] params) throws ValidationFailedException {
	checkNotNull(name);
	checkArgument(!name.trim().isEmpty());
	checkNotNull(url);
	checkArgument(!url.trim().isEmpty());
	checkNotNull(params);
	checkArgument(params.length != 0, "PVF-BUG-0003: params should always have at least one value");
	
	final String[] retValues = new String[params.length];

	for (int paramIndex = 0, paramLength = params.length; paramIndex < paramLength; ++paramIndex) {
		final String param = params[paramIndex];
		
		if (param == null) {
			retValues[paramIndex] = null;
		} else {
			final Encoder encoder = DefaultEncoder.getInstance();
			final String canonicalized = encoder.canonicalize(param, false);
			retValues[paramIndex] = canonicalized;
		}
	}
	
	return retValues;
}
 
开发者ID:mcasperson,项目名称:ParameterValidationFilter,代码行数:29,代码来源:CanonicalizeTextValidationRule.java

示例3: fixParams

import org.owasp.esapi.reference.DefaultEncoder; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String[] fixParams(final String name, final String url, final String[] params) throws ValidationFailedException {
	checkNotNull(name);
	checkArgument(!name.trim().isEmpty());
	checkNotNull(url);
	checkArgument(!url.trim().isEmpty());
	checkNotNull(params);
	checkArgument(params.length != 0, "PVF-BUG-0003: params should always have at least one value");

	for (int paramIndex = 0, paramLength = params.length; paramIndex < paramLength; ++paramIndex) {
		String param = params[paramIndex];

		if (allowBackSlash) {
			param = param.replaceAll("\\\\", "");
		}
		
		if (param != null) {
			final Encoder encoder = DefaultEncoder.getInstance();
			final String canonicalized = encoder.canonicalize(param, false);
			
			if (!canonicalized.equals(param)) {
				throw new ValidationFailedException("PVF-SECURITY-0002: Param was found to already be encoded.\nNAME: " + name + "\nVALUE: " + param + "\nURL: " + url);
			}
		}
	}
	
	return params;
}
 
开发者ID:mcasperson,项目名称:ParameterValidationFilter,代码行数:32,代码来源:FailIfNotCanonicalizedValidationRule.java

示例4: encodeHtml

import org.owasp.esapi.reference.DefaultEncoder; //导入依赖的package包/类
protected String encodeHtml(String html) {
    Encoder encoder = DefaultEncoder.getInstance();
    String s = encoder.encodeForHTML(html);
    System.out.println("Encoded from ["+html+"] to ["+s+"]");
    return s;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:7,代码来源:JSONHtmlXssSerializer.java


注:本文中的org.owasp.esapi.reference.DefaultEncoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。