Refine search
String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4"; URL url = new URL(urlStr); URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); url = uri.toURL();
public static String removeUserInfo(String url) { String userInfo = ""; try { userInfo = new URL(url).getUserInfo(); } catch (MalformedURLException e) { // ignore } if (null == userInfo || userInfo.isEmpty()) { return url; } return url.replace(userInfo, "XXXX:XXXX"); } }
private String evaluate(URL url, int index) { if (url == null || index < 0 || index >= partnames.length) { return null; } switch (partnames[index]) { case HOST : return url.getHost(); case PATH : return url.getPath(); case QUERY : return url.getQuery(); case REF : return url.getRef(); case PROTOCOL : return url.getProtocol(); case FILE : return url.getFile(); case AUTHORITY : return url.getAuthority(); case USERINFO : return url.getUserInfo(); case QUERY_WITH_KEY: return evaluateQuery(url.getQuery(), paths[index]); case NULLNAME: default : return null; } }
URL proximo = new URL(System.getenv("PROXIMO_URL")); String userInfo = proximo.getUserInfo(); String user = userInfo.substring(0, userInfo.indexOf(':')); String password = userInfo.substring(userInfo.indexOf(':') + 1); System.setProperty("socksProxyHost", proximo.getHost()); Authenticator.setDefault(new ProxyAuthenticator(user, password));
set(context.protocol, context.getHost(), context.getPort(), context.getAuthority(), context.getUserInfo(), context.getPath(), context.getQuery(), context.getRef()); if (streamHandler == null) {
/** * Creates and returns a new URL identical to the specified URL, except using the specified host. * @param u the URL on which to base the returned URL * @param newHost the new host to use in the returned URL * @return a new URL identical to the specified URL, except using the specified host * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewHost(final URL u, final String newHost) throws MalformedURLException { return createNewUrl(u.getProtocol(), u.getUserInfo(), newHost, u.getPort(), u.getPath(), u.getRef(), u.getQuery()); }
/** * Creates and returns a new URL identical to the specified URL, except using the specified host. * @param u the URL on which to base the returned URL * @param newHost the new host to use in the returned URL * @param newPort the new port to use in the returned URL * @return a new URL identical to the specified URL, except using the specified host * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewHostAndPort(final URL u, final String newHost, final int newPort) throws MalformedURLException { return createNewUrl(u.getProtocol(), u.getUserInfo(), newHost, newPort, u.getPath(), u.getRef(), u.getQuery()); }
/** * FtpURLConnection constructor comment. * * @param url */ protected FtpURLConnection(URL url) { super(url); hostName = url.getHost(); String parse = url.getUserInfo(); if (parse != null) { int split = parse.indexOf(':'); if (split >= 0) { username = parse.substring(0, split); password = parse.substring(split + 1); } else { username = parse; } } uri = null; try { uri = url.toURI(); } catch (URISyntaxException e) { // do nothing. } }
String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4"; URL url = new URL(urlStr); URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); url = uri.toURL();
/** * If given path is a URL, return the string representation with the user-info part filtered out. * @param path path to object * @return either the original string or string representation of URL with the user-info part removed */ public static String redactUrl(String path) { URL url; try { url = new URL(path); } catch (MalformedURLException e) { // not an URL return path; } if (url.getUserInfo() != null) { return url.toString().replace(url.getUserInfo(), REDACTED_USER_INFO); } else { return path; } }
private String evaluate(URL url, int index) { if (url == null || index < 0 || index >= partnames.length) { return null; } switch (partnames[index]) { case HOST : return url.getHost(); case PATH : return url.getPath(); case QUERY : return url.getQuery(); case REF : return url.getRef(); case PROTOCOL : return url.getProtocol(); case FILE : return url.getFile(); case AUTHORITY : return url.getAuthority(); case USERINFO : return url.getUserInfo(); case QUERY_WITH_KEY: return evaluateQuery(url.getQuery(), paths[index]); case NULLNAME: default : return null; } }
protected FTPClient createFTP() throws IOException, JMSException { String connectUrl = url.getHost(); setUserInformation(url.getUserInfo()); int port = url.getPort() < 1 ? 21 : url.getPort(); FTPClient ftp = new FTPClient(); try { ftp.connect(connectUrl, port); } catch(ConnectException e) { throw new JMSException("Problem connecting the FTP-server"); } if(!ftp.login(ftpUser, ftpPass)) { ftp.quit(); ftp.disconnect(); throw new JMSException("Cant Authentificate to FTP-Server"); } return ftp; }
/** * Creates and returns a new URL identical to the specified URL, except using the specified host. * @param u the URL on which to base the returned URL * @param newHost the new host to use in the returned URL * @return a new URL identical to the specified URL, except using the specified host * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewHost(final URL u, final String newHost) throws MalformedURLException { return createNewUrl(u.getProtocol(), u.getUserInfo(), newHost, u.getPort(), u.getPath(), u.getRef(), u.getQuery()); }
public IGVSeekableFTPStream(URL url) throws IOException { this.source = url.toExternalForm(); this.userInfo = url.getUserInfo(); this.host = url.getHost(); this.path = url.getPath(); ftp = FTPUtils.connect(host, userInfo, new UserPasswordInputImpl()); }
String urlStr = "http://www.example.com/CEREC® Materials & Accessories/IPS Empress® CAD.pdf" URL url= new URL(urlStr); URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
URL url = new URL("http://user:pass@domain.com/url"); URLConnection urlConnection = url.openConnection(); if (url.getUserInfo() != null) { String basicAuth = "Basic " + new String(new Base64().encode(url.getUserInfo().getBytes())); urlConnection.setRequestProperty("Authorization", basicAuth); } InputStream inputStream = urlConnection.getInputStream();
/** * Creates and returns a new URL identical to the specified URL, except using the specified port. * @param u the URL on which to base the returned URL * @param newPort the new port to use in the returned URL * @return a new URL identical to the specified URL, except using the specified port * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewPort(final URL u, final int newPort) throws MalformedURLException { return createNewUrl(u.getProtocol(), u.getUserInfo(), u.getHost(), newPort, u.getPath(), u.getRef(), u.getQuery()); }
private HttpClient clientFor(URL url) { HttpClientBuilder builder = HttpClients.custom(); final String userInfo = url.getUserInfo(); if (userInfo != null) { CredentialsProvider credsProvider = new BasicCredentialsProvider(); final String[] usernamePassword = userInfo.split(":"); credsProvider.setCredentials(new AuthScope(url.getHost(), url.getPort()), new UsernamePasswordCredentials(usernamePassword[0], usernamePassword[1])); builder = builder.setDefaultCredentialsProvider(credsProvider); } return builder.build(); }
@Override public InputStream openInputStream() throws IOException { String file = url.getPath(); FTPClient ftp = FTPUtils.connect(url.getHost(), url.getUserInfo(), null); ftp.pasv(); ftp.retr(file); return new FTPStream(ftp); }
public URL convertToURLEscapingIllegalCharacters(String string){ try { String decodedURL = URLDecoder.decode(string, "UTF-8"); URL url = new URL(decodedURL); URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); return uri.toURL(); } catch (Exception ex) { ex.printStackTrace(); return null; } }