本文整理汇总了Java中org.owasp.esapi.errors.EncodingException类的典型用法代码示例。如果您正苦于以下问题:Java EncodingException类的具体用法?Java EncodingException怎么用?Java EncodingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EncodingException类属于org.owasp.esapi.errors包,在下文中一共展示了EncodingException类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: encode
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String encode(String item, short encFor) throws PageException {
PrintStream out = System.out;
try {
System.setOut(new PrintStream(DevNullOutputStream.DEV_NULL_OUTPUT_STREAM));
Encoder encoder = ESAPI.encoder();
switch(encFor){
//case ENC_CSS:return encoder.encodeForBase64(item);
case ENC_CSS:return encoder.encodeForCSS(item);
case ENC_DN:return encoder.encodeForDN(item);
case ENC_HTML:return encoder.encodeForHTML(item);
case ENC_HTML_ATTR:return encoder.encodeForHTMLAttribute(item);
case ENC_JAVA_SCRIPT:return encoder.encodeForJavaScript(item);
case ENC_LDAP:return encoder.encodeForLDAP(item);
//case ENC_CSS:return encoder.encodeForOS(arg0, arg1)(item);
//case ENC_CSS:return encoder.encodeForSQL(arg0, arg1)CSS(item);
case ENC_URL:return encoder.encodeForURL(item);
case ENC_VB_SCRIPT:return encoder.encodeForVBScript(item);
case ENC_XML:return encoder.encodeForXML(item);
case ENC_XML_ATTR:return encoder.encodeForXMLAttribute(item);
case ENC_XPATH:return encoder.encodeForXPath(item);
}
throw new ApplicationException("invalid target encoding defintion");
}
catch(EncodingException ee){
throw Caster.toPageException(ee);
}
finally {
System.setOut(out);
}
}
开发者ID:lucee,项目名称:Lucee4,代码行数:32,代码来源:ESAPIEncode.java
示例2: decode
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String decode(String item, short decFrom) throws PageException {
PrintStream out = System.out;
try {
System.setOut(new PrintStream(DevNullOutputStream.DEV_NULL_OUTPUT_STREAM));
Encoder encoder = ESAPI.encoder();
switch(decFrom){
case DEC_URL:return encoder.decodeFromURL(item);
}
throw new ApplicationException("invalid target decoding defintion");
}
catch(EncodingException ee){
throw Caster.toPageException(ee);
}
finally {
System.setOut(out);
}
}
开发者ID:lucee,项目名称:Lucee4,代码行数:19,代码来源:ESAPIDecode.java
示例3: decode
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String decode(String item, short decFrom) throws PageException {
PrintStream out = System.out;
try {
System.setOut(new PrintStream(DevNullOutputStream.DEV_NULL_OUTPUT_STREAM));
Encoder encoder = ESAPI.encoder();
switch(decFrom){
case DEC_URL:return encoder.decodeFromURL(item);
//case DEC_BASE64:return encoder.decodeFromBase64(item);
case DEC_HTML:return encoder.decodeForHTML(item);
}
throw new ApplicationException("invalid target decoding defintion");
}
catch(EncodingException ee){
throw Caster.toPageException(ee);
}
finally {
System.setOut(out);
}
}
开发者ID:lucee,项目名称:Lucee,代码行数:21,代码来源:ESAPIDecode.java
示例4: encode
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* Encode tag's content for usage in a URL.
* @param content The tag's content as a String
* @param enc Encoder used to call
* {@link Encoder#encodeForURL(String)}
* @return content encoded for usage in a URL
* @throws EncodingException if {@link Encoder#encodeForURL(String)} does.
*/
protected String encode(String content, Encoder enc) throws JspTagException
{
try
{
return enc.encodeForURL(content);
}
catch(EncodingException e)
{
throw new JspTagException("Unable to encode to URL encoding", e);
}
}
开发者ID:abimael93,项目名称:owasp-esapi-java,代码行数:20,代码来源:EncodeForURLTag.java
示例5: encodeForURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public String encodeForURL(String input) throws EncodingException {
if ( input == null ) {
return null;
}
try {
return URLEncoder.encode(input, ESAPI.securityConfiguration().getCharacterEncoding());
} catch (UnsupportedEncodingException ex) {
throw new EncodingException("Encoding failure", "Character encoding not supported", ex);
} catch (Exception e) {
throw new EncodingException("Encoding failure", "Problem URL encoding input", e);
}
}
开发者ID:abimael93,项目名称:owasp-esapi-java,代码行数:16,代码来源:DefaultEncoder.java
示例6: decodeFromURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public String decodeFromURL(String input) throws EncodingException {
if ( input == null ) {
return null;
}
String canonical = canonicalize(input);
try {
return URLDecoder.decode(canonical, ESAPI.securityConfiguration().getCharacterEncoding());
} catch (UnsupportedEncodingException ex) {
throw new EncodingException("Decoding failed", "Character encoding not supported", ex);
} catch (Exception e) {
throw new EncodingException("Decoding failed", "Problem URL decoding input", e);
}
}
开发者ID:abimael93,项目名称:owasp-esapi-java,代码行数:17,代码来源:DefaultEncoder.java
示例7: encode
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String encode(String item, short encFor, boolean canonicalize) throws PageException {
if(StringUtil.isEmpty(item)) return item;
PrintStream out = System.out;
try {
System.setOut(new PrintStream(DevNullOutputStream.DEV_NULL_OUTPUT_STREAM));
Encoder encoder = ESAPI.encoder();
if(canonicalize)item=encoder.canonicalize(item, false);
switch(encFor){
case ENC_CSS:return encoder.encodeForCSS(item);
case ENC_DN:return encoder.encodeForDN(item);
case ENC_HTML:return encoder.encodeForHTML(item);
case ENC_HTML_ATTR:return encoder.encodeForHTMLAttribute(item);
case ENC_JAVA_SCRIPT:return encoder.encodeForJavaScript(item);
case ENC_LDAP:return encoder.encodeForLDAP(item);
case ENC_URL:return encoder.encodeForURL(item);
case ENC_VB_SCRIPT:return encoder.encodeForVBScript(item);
case ENC_XML:return encoder.encodeForXML(item);
case ENC_XML_ATTR:return encoder.encodeForXMLAttribute(item);
case ENC_XPATH:return encoder.encodeForXPath(item);
}
throw new ApplicationException("invalid target encoding defintion");
}
catch(EncodingException ee){
throw Caster.toPageException(ee);
}
finally {
System.setOut(out);
}
}
开发者ID:lucee,项目名称:Lucee,代码行数:34,代码来源:ESAPIEncode.java
示例8: addNameValuePairToQueryString
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
private void addNameValuePairToQueryString(StringBuilder queryString, String name, String value) {
if (UtilValidate.isNotEmpty(value)) {
if (queryString.length() > 1) {
queryString.append("&");
}
try {
queryString.append(StringUtil.defaultWebEncoder.encodeForURL(name));
queryString.append("=");
queryString.append(StringUtil.defaultWebEncoder.encodeForURL(value));
} catch (EncodingException e) {
Debug.logError(e, module);
}
}
}
开发者ID:gildaslemoal,项目名称:elpi,代码行数:16,代码来源:RequestHandler.java
示例9: resetMetric
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static Map<String, Object> resetMetric(DispatchContext dctx, Map<String, ?> context) {
String name = (String) context.get("name");
try {
name = StringUtil.defaultWebEncoder.decodeFromURL(name);
} catch (EncodingException e) {
return ServiceUtil.returnError("Exception thrown while decoding metric name \"" + name + "\"");
}
Metrics metric = MetricsFactory.getMetric(name);
if (metric != null) {
metric.reset();
return ServiceUtil.returnSuccess();
}
return ServiceUtil.returnError("Metric \"" + name + "\" not found.");
}
开发者ID:gildaslemoal,项目名称:elpi,代码行数:16,代码来源:CommonServices.java
示例10: encodeUrlWithId
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String encodeUrlWithId(HttpServletRequest request,
String page, String id) {
try {
return encodeUrl(request, page) + "?id="
+ ESAPI.encoder().encodeForURL(id);
} catch (EncodingException e) {
return "???";
}
}
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:10,代码来源:HTMLHelper.java
示例11: encodeUrlWithPath
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String encodeUrlWithPath(HttpServletRequest request,
String path) {
try {
return encodeUrl(request, "browse") + "?path="
+ ESAPI.encoder().encodeForURL(path);
} catch (EncodingException e) {
return "???";
}
}
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:10,代码来源:HTMLHelper.java
示例12: encodeUrlWithTag
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public static String encodeUrlWithTag(HttpServletRequest request, String tag) {
try {
return encodeUrl(request, "tags") + "?tag="
+ ESAPI.encoder().encodeForURL(tag);
} catch (EncodingException e) {
return "???";
}
}
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:9,代码来源:HTMLHelper.java
示例13: encodeForURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/** {@inheritDoc} */
public String encodeForURL(String s) throws EncodingException {
return Encode.forUri(s);
}
开发者ID:OWASP,项目名称:owasp-java-encoder,代码行数:5,代码来源:ESAPIEncoder.java
示例14: decodeFromURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/** {@inheritDoc} */
public String decodeFromURL(String s) throws EncodingException {
return _referenceEncoder.decodeFromURL(s);
}
开发者ID:OWASP,项目名称:owasp-java-encoder,代码行数:5,代码来源:ESAPIEncoder.java
示例15: findMatchingLabels
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
public void findMatchingLabels(String component, String fileName, String key, String locale) throws MalformedURLException, SAXException, ParserConfigurationException, IOException, EncodingException, GeneralException {
if (UtilValidate.isEmpty(component) && UtilValidate.isEmpty(fileName) && UtilValidate.isEmpty(key) && UtilValidate.isEmpty(locale)) {
// Important! Don't allow unparameterized queries - doing so will result in loading the entire project into memory
return;
}
for (LabelFile fileInfo : filesFound.values()) {
if (UtilValidate.isNotEmpty(component) && !component.equals(fileInfo.componentName)) {
continue;
}
if (UtilValidate.isNotEmpty(fileName) && !fileName.equals(fileInfo.getFileName())) {
continue;
}
if (Debug.infoOn()) {
Debug.logInfo("Current file : " + fileInfo.getFileName(), module);
}
Document resourceDocument = UtilXml.readXmlDocument(fileInfo.file.toURI().toURL(), false);
Element resourceElem = resourceDocument.getDocumentElement();
String labelKeyComment = "";
for (Node propertyNode : UtilXml.childNodeList(resourceElem.getFirstChild())) {
if (propertyNode instanceof Element) {
Element propertyElem = (Element) propertyNode;
String labelKey = StringUtil.defaultWebEncoder.canonicalize(propertyElem.getAttribute("key"));
String labelComment = "";
for (Node valueNode : UtilXml.childNodeList(propertyElem.getFirstChild())) {
if (valueNode instanceof Element) {
Element valueElem = (Element) valueNode;
// Support old way of specifying xml:lang value.
// Old way: en_AU, new way: en-AU
String localeName = valueElem.getAttribute("xml:lang");
if( localeName.contains("_")) {
localeName = localeName.replace('_', '-');
}
String labelValue = StringUtil.defaultWebEncoder.canonicalize(UtilXml.nodeValue(valueElem.getFirstChild()));
LabelInfo label = labels.get(labelKey + keySeparator + fileInfo.getFileName());
if (UtilValidate.isEmpty(label)) {
label = new LabelInfo(labelKey, labelKeyComment, fileInfo.getFileName(), localeName, labelValue, labelComment);
labels.put(labelKey + keySeparator + fileInfo.getFileName(), label);
} else {
if (label.setLabelValue(localeName, labelValue, labelComment, false)) {
duplicatedLocalesLabelsList.add(label);
}
}
localesFound.add(localeName);
labelComment = "";
} else if (valueNode instanceof Comment) {
labelComment = labelComment + StringUtil.defaultWebEncoder.canonicalize(valueNode.getNodeValue());
}
}
labelKeyComment = "";
} else if (propertyNode instanceof Comment) {
labelKeyComment = labelKeyComment + StringUtil.defaultWebEncoder.canonicalize(propertyNode.getNodeValue());
}
}
}
}
开发者ID:gildaslemoal,项目名称:elpi,代码行数:57,代码来源:LabelManagerFactory.java
示例16: encodeForURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* Encode for use in a URL. This method performs <a
* href="http://en.wikipedia.org/wiki/Percent-encoding">URL encoding</a>
* on the entire string.
*
* @see <a href="http://en.wikipedia.org/wiki/Percent-encoding">URL encoding</a>
*
* @param input
* the text to encode for use in a URL
*
* @return input
* encoded for use in a URL
*
* @throws EncodingException
* if encoding fails
*/
String encodeForURL(String input) throws EncodingException;
开发者ID:abimael93,项目名称:owasp-esapi-java,代码行数:18,代码来源:Encoder.java
示例17: decodeFromURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* Decode from URL. Implementations should first canonicalize and
* detect any double-encoding. If this check passes, then the data is decoded using URL
* decoding.
*
* @param input
* the text to decode from an encoded URL
*
* @return
* the decoded URL value
*
* @throws EncodingException
* if decoding fails
*/
String decodeFromURL(String input) throws EncodingException;
开发者ID:abimael93,项目名称:owasp-esapi-java,代码行数:16,代码来源:Encoder.java
示例18: encodeForURL
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* Encode string for use in a URL.
* @param str The string to encode.
* @return str encoded for use in a URL.
* @see Encoder#encodeForURL(String)
*/
public static String encodeForURL(String str) throws EncodingException
{
return ESAPI.encoder().encodeForURL(str);
}
开发者ID:abimael93,项目名称:owasp-esapi-java,代码行数:11,代码来源:ELEncodeFunctions.java
示例19: url
import org.owasp.esapi.errors.EncodingException; //导入依赖的package包/类
/**
* Encode string for URL context
*
* @param obj
* @return
* @throws EncodingException
*/
public static String url(Object obj) throws EncodingException {
return encoder.encodeForURL(toStr(obj));
}
开发者ID:yangjm,项目名称:winlet,代码行数:11,代码来源:EncodeUtils.java
注:本文中的org.owasp.esapi.errors.EncodingException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论