in src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java [113:184]
public static String getContent(URL url, MavenProject project, Settings settings, String encoding)
throws IOException {
String scheme = url.getProtocol();
if (encoding == null || encoding.isEmpty()) {
encoding = DEFAULT_ENCODING;
}
if ("file".equals(scheme)) {
InputStream in = null;
try {
URLConnection conn = url.openConnection();
in = conn.getInputStream();
final String content = IOUtil.toString(in, encoding);
in.close();
in = null;
return content;
} finally {
IOUtil.close(in);
}
}
Proxy proxy = settings.getActiveProxy();
if (proxy != null) {
if ("http".equals(scheme) || "https".equals(scheme) || "ftp".equals(scheme)) {
scheme += ".";
} else {
scheme = "";
}
String host = proxy.getHost();
if (!(host == null || host.isEmpty())) {
Properties p = System.getProperties();
p.setProperty(scheme + "proxySet", "true");
p.setProperty(scheme + "proxyHost", host);
p.setProperty(scheme + "proxyPort", String.valueOf(proxy.getPort()));
if (!StringUtils.isEmpty(proxy.getNonProxyHosts())) {
p.setProperty(scheme + "nonProxyHosts", proxy.getNonProxyHosts());
}
final String userName = proxy.getUsername();
if (!(userName == null || userName.isEmpty())) {
final String pwd = StringUtils.isEmpty(proxy.getPassword()) ? "" : proxy.getPassword();
Authenticator.setDefault(new Authenticator() {
/** {@inheritDoc} */
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, pwd.toCharArray());
}
});
}
}
}
InputStream in = null;
try {
URLConnection conn = getURLConnection(url, project, settings);
in = conn.getInputStream();
final String string = IOUtil.toString(in, encoding);
in.close();
in = null;
return string;
} finally {
IOUtil.close(in);
}
}