//HIDE package security_patterns.abstract_.aspects; import java.io.InputStream; import java.net.HttpURLConnection; //END HIDE public aspect HttpURLConnectionAspect extends StreamAspect { protected pointcut monitor(): call(InputStream HttpURLConnection.getInputStream()); InputStream around(HttpURLConnection that): target(that) && monitor() && ignore() { InputStream stream = proceed(that); if (that.getContentType().contains("html")) return wrap(stream, Format.HTML); else if (that.getContentType().contains("xml")) return wrap(stream, Format.XML); else return proceed(that); } }