private File toFile(final URL url) throws MalformedURLException { // only correct way to convert the URL to a File object, also see issue #16 // Do not use URLDecoder try { return new File(url.toURI()); } catch (URISyntaxException ex) { throw new MalformedURLException(ex.getMessage()); } catch (IllegalArgumentException ex) { try { return new File(URLDecoder.decode(url.getFile(), "UTF-8")); } catch (Exception ex2) { throw new MalformedURLException(ex.getMessage()); } } }
private MySqlJdbcUrl(String url) throws MalformedURLException, URISyntaxException { if (!url.startsWith(PREFIX)) { throw new MalformedURLException(); } builder = new URIBuilder(url.substring(PREFIX.length())); }
@Override public String getGID(URL url) throws MalformedURLException { Matcher m = p1.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException( "Expected hqporner URL format: " + "hentaidude.com/VIDEO - got " + url + " instead"); }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("^https?://[wm.]*shesfreaky\\.com/gallery/([a-zA-Z0-9\\-_]+).*$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException("Expected shesfreaky.com URL format: " + "shesfreaky.com/gallery/... - got " + url + "instead"); }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("https?://gfycatporntube.com/([a-zA-Z1-9_-]*)/?$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException("Expected gfycatporntube URL format: " + "gfycatporntube.com/NAME - got " + url + " instead"); }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("https?://www.picstatio.com/([a-zA-Z1-9_-]*)/?$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException("Expected picstatio URL format: " + "www.picstatio.com//ID - got " + url + " instead"); }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("^https?://[wm.]*youporn\\.com/watch/([0-9]+).*$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException( "Expected youporn format:" + "youporn.com/watch/####" + " Got: " + url); }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("^http://.*tubex6\\.com/(.*)/$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException("Expected tubex6.com URL format: " + "tubex6.com/NAME - got " + url + " instead"); }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("https?://www\\.modelmayhem\\.com/portfolio/(\\d+)/viewall"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } throw new MalformedURLException("Expected modelmayhem URL format: " + "modelmayhem.com/portfolio/ID/viewall - got " + url + " instead"); }
/** * Create a new {@code UrlResource} based on a URI specification. * <p>The given parts will automatically get encoded if necessary. * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon); * also known as "scheme" * @param location the location (e.g. the file path within that protocol); * also known as "scheme-specific part" * @param fragment the fragment within that location (e.g. anchor on an HTML page, * as following after a "#" separator) * @throws MalformedURLException if the given URL specification is not valid * @see java.net.URI#URI(String, String, String) */ public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException { try { this.uri = new URI(protocol, location, fragment); this.url = this.uri.toURL(); this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString()); } catch (URISyntaxException ex) { MalformedURLException exToThrow = new MalformedURLException(ex.getMessage()); exToThrow.initCause(ex); throw exToThrow; } }
@Override public String getGID(URL url) throws MalformedURLException { Pattern p = Pattern.compile("^https://clips\\.twitch\\.tv/(.*)$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(m.groupCount()); } throw new MalformedURLException( "Expected Twitch.tv format:" + "https://clips.twitch.tv/####" + " Got: " + url); }
public static InetSocketAddress getCliPort ( String jenkinsUrl ) throws MalformedURLException, IOException { URL u = new URL(jenkinsUrl); URLConnection conn = u.openConnection(); if ( ! ( conn instanceof HttpURLConnection ) ) { System.err.println("Not a HTTP URL"); throw new MalformedURLException(); } HttpURLConnection hc = (HttpURLConnection) conn; if ( hc.getResponseCode() >= 400 ) { System.err.println("* Error connection to jenkins HTTP " + u); } int clip = Integer.parseInt(hc.getHeaderField("X-Jenkins-CLI-Port")); return new InetSocketAddress(u.getHost(), clip); }
@Override public String getGID(URL url) throws MalformedURLException { String capID = getChapterID(url.toExternalForm()); if (capID != null) { return capID; } throw new MalformedURLException("Unable to get chapter ID from" + url); }
throw new MalformedURLException("The specified file path " + fileName + " is not allowed due to security reasons");
/** * Returns a new {@code HttpUrl} representing {@code url} if it is a well-formed HTTP or HTTPS * URL, or throws an exception if it isn't. * * @throws MalformedURLException if there was a non-host related URL issue * @throws UnknownHostException if the host was invalid */ static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException { Builder builder = new Builder(); Builder.ParseResult result = builder.parse(null, url); switch (result) { case SUCCESS: return builder.build(); case INVALID_HOST: throw new UnknownHostException("Invalid host: " + url); case UNSUPPORTED_SCHEME: case MISSING_SCHEME: case INVALID_PORT: default: throw new MalformedURLException("Invalid URL: " + result + " for " + url); } }
@Override public final MalformedURLException invalidURIEncoding(final String encoding) { final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), invalidURIEncoding$str(), encoding)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToLookupJSSEDomain = "WFLYIIOP0051: Error configuring domain socket factory: failed to lookup JSSE security domain";
@Override public final MalformedURLException invalidURL(final String protocol, final String url) { final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), invalidURL$str(), protocol, url)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String problemInvokingPortableRemoteObjectToStub = "WFLYIIOP0041: Problem with PortableRemoteObject.toStub(); object not exported or stub not found";
@Override public final MalformedURLException invalidIIOPURLVersion(final String version) { final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), invalidIIOPURLVersion$str(), version)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String unavailableRMIPackages = "WFLYIIOP0048: javax.rmi packages not available";
@Override public final MalformedURLException unavailableISOLatin1Decoder() { final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), unavailableISOLatin1Decoder$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidURIEncoding = "WFLYIIOP0050: Invalid URI encoding: %s";
String protocol = url.getProtocol(); if (protocol != null && !"rmi".equals(protocol)) { throw new MalformedURLException("Invalid URL scheme '" + protocol + "'");