Class ESAPIEncoder
Please note that the OWASP Java Encoders does not implement all the encodings of the ESAPI Encoder API. In such situations this implementation will fallback onto the default reference implementation included with ESAPI. Thus you should see the performance benefit from the methods included in the Encoder, but still maintain compatibility with all methods from ESAPI Encoder.
For clarity, the reason the OWASP Java Encoders do not include some of the ESAPI library is that the Encoders library is specifically focused on encoding, and thus does not include:
- Input validation/normalization methods:
Encoder.canonicalize(String),Encoder.canonicalize(String, boolean),Encoder.canonicalize(String, boolean, boolean)Encoder.getCanonicalizedURI(URI) - Decoding methods:
Encoder.decodeForHTML(String),Encoder.decodeFromURL(String) - Binary-to-text/text-to-binary:
Encoder.encodeForBase64(byte[], boolean),Encoder.decodeFromBase64(String). - Bind-able APIs (such as
PreparedStatement:Encoder.encodeForSQL(org.owasp.esapi.codecs.Codec, String),Encoder.encodeForXPath(String),Encoder.encodeForOS(org.owasp.esapi.codecs.Codec, String) - Rarely-used or alternate compatible encoding:
Encoder.encodeForVBScript(String),Encoder.encodeForLDAP(String),Encoder.encodeForLDAP(String, boolean),Encoder.encodeForDN(String)
(Please note that with sufficient feedback from the user base, the above mentioned methods may be implemented in future releases of the OWASP Java Encoders, if/when that happens, this shim class will be updated to call out to the new methods.)
You may notice that this class does not actually implement Encoder
itself. Instead it simply provides a getInstance() method that
does. This allows the implementation details maximum flexibility by not
creating a any public API that would restrict changes later
- Author:
- jeffi
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.owasp.esapi.EncoderReturns an instance of the Encoder.
-
Method Details
-
getInstance
public static org.owasp.esapi.Encoder getInstance()Returns an instance of the Encoder. This method is the only supported mechanism by which an ESAPIEncoder instance should be obtained. The returned implementation is guaranteed to be thread-safe for the methods that the OWASP Java Encoders implement (see class documentation). Though not a requirement of the ESAPI Encoder API, the returned value is also serializable.- Returns:
- An encoder implementation that uses the OWASP Java Encoders for most of the common encoding methods.
-