public static String getContent()

in src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java [104:154]


    public static String getContent(URL url, MavenProject project, Settings settings, String encoding)
            throws IOException {
        String scheme = url.getProtocol();

        if (encoding == null || encoding.isEmpty()) {
            encoding = "UTF-8";
        }

        if ("file".equals(scheme)) {
            try (InputStream in = url.openConnection().getInputStream()) {
                final String content = IOUtil.toString(in, encoding);
                return content;
            }
        }

        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());
                        }
                    });
                }
            }
        }

        try (InputStream in = getURLConnection(url, project, settings).getInputStream()) {
            return IOUtil.toString(in, encoding);
        }
    }