/** * Supplies the actual credentials to the given {@link URLConnection}. * * @param conn * the connection to supply the credentials to, cannot be <code>null</code>; * @param urlCreds * the URL credentials to supply, cannot be <code>null</code>. * @throws IOException * in case of I/O problems. */ private void supplyCredentials(URLConnection conn, UrlCredentials urlCreds) throws IOException { final AuthType type = urlCreds.getType(); final Object[] creds = urlCreds.getCredentials(); if (AuthType.BASIC.equals(type)) { applyBasicAuthentication(conn, creds); } else if (AuthType.CLIENT_CERT.equals(type)) { applyClientCertificate(conn, creds); } else if (!AuthType.NONE.equals(type)) { throw new IllegalArgumentException("Unknown authentication type: " + type); } } }