public void initialize() throws URISyntaxException { this.url = getConfiguredUri(this.url); URI uri; try { uri = new URI(this.url); } catch (URISyntaxException e) { throw new URISyntaxException(e.getInput(), e.getMessage()); } this.uri = uri; String[] userInfoArray = uri.getUserInfo() == null ? new String[2] : uri.getUserInfo().split(":"); String user = userInfoArray[0]; String password = userInfoArray[1]; if(user != null && password == null || user == null && password != null) throw new RuntimeException("user and password don't defined check your URL or if you use a key the property in your neo4j.conf file"); this.token = (user != null && password != null) ? AuthTokens.basic(user, password) : AuthTokens.none(); } }
private J4pException mapException(Exception pException) throws J4pException { if (pException instanceof ConnectException) { return new J4pConnectException( "Cannot connect to " + requestHandler.getJ4pServerUrl() + ": " + pException.getMessage(), (ConnectException) pException); } else if (pException instanceof ConnectTimeoutException) { return new J4pTimeoutException( "Read timeout while request " + requestHandler.getJ4pServerUrl() + ": " + pException.getMessage(), (ConnectTimeoutException) pException); } else if (pException instanceof IOException) { return new J4pException("IO-Error while contacting the server: " + pException,pException); } else if (pException instanceof URISyntaxException) { URISyntaxException sExp = (URISyntaxException) pException; return new J4pException("Invalid URI " + sExp.getInput() + ": " + sExp.getReason(),pException); } else { return new J4pException("Exception " + pException,pException); } }
public static URI buildSafeUri(String scheme, String userInfo, String host, int port, String path, String query, String fragment) throws URISyntaxException { try { return new URI(scheme, userInfo, host, port, path, query, fragment); } catch (URISyntaxException e) { String encodedInput = URLEncode(e.getInput()); throw new URISyntaxException(encodedInput, e.getReason()); } }
public static URI buildSafeUri(String uri) throws URISyntaxException { try { return new URI(uri); } catch (URISyntaxException e) { String encodedInput = URLEncode(e.getInput()); throw new URISyntaxException(encodedInput, e.getReason()); } }
resp.sendError(400, "Bad URI: " + ex.getInput()); return;
resp.sendError(400, "Bad URI: " + ex.getInput()); return;
throw e; String input = e.getInput(); int idx = e.getIndex(); String illChar = String.valueOf(input.charAt(idx));
classname = ((InvalidClassException)t).classname; } else if (t instanceof URISyntaxException){ classname = ((URISyntaxException)t).getInput(); } else { classname = null;
@DefaultCommand public void run(@Option(description = "The files to open", defaultValue = ".") final Resource<?>[] dirs) throws IOException { for (Resource<?> resource : dirs) { if (resource instanceof FileResource<?>) { Desktop dt = Desktop.getDesktop(); dt.open((File) resource.getUnderlyingResourceObject()); } else if (resource instanceof URLResource) { Desktop dt = Desktop.getDesktop(); try { dt.browse(((URLResource) resource).getUnderlyingResourceObject().toURI()); } catch (URISyntaxException e) { throw new RuntimeException("Bad URL syntax: " + e.getInput(), e); } } } } }
private void handleURISyntaxException(URISyntaxException e) { int actualIndex = e.getIndex(); String fullURI = e.getInput(); int indexFromRHS = fullURI.length()-actualIndex; int relativeIndex = getEntityName().length() - indexFromRHS; textField.setSelectionStart(relativeIndex); textField.setSelectionEnd(getEntityName().length()); displayWarningMessage("Invalid name: " + e.getReason()); }
log.invalidResourceURI(e.getInput(), e.getReason(), e); response = status(Response.Status.BAD_REQUEST).entity("{ \"error\" : \"Failed to deploy provider configuration " + name + "\" }").build();
log.invalidResourceURI(e.getInput(), e.getReason(), e); response = status(Response.Status.BAD_REQUEST).entity("{ \"error\" : \"Failed to deploy descriptor " + name + "\" }").build();
private void waitForPing(Id id, Ping ping) { URI uri; if (ping.getUrl().toString().contains(CONTAINER_IP_PATTERN)) { try { uri = new URI(ping.getUrl().toString().replace(CONTAINER_IP_PATTERN, getIPAddress(id))); } catch (URISyntaxException e) { throw new OrchestrationException("Bad health check URI syntax: " + e.getMessage() + ", input: " + e.getInput() + ", index:" + e.getIndex()); } } else { uri = ping.getUrl(); } logger.info(String.format("Pinging %s for pattern \"%s\"", uri, ping.getPattern())); if (!Pinger.ping(uri, ping.getPattern(), ping.getTimeout(), ping.isSslVerify())) { throw new OrchestrationException("timeout waiting for " + uri + " for " + ping.getTimeout() + " with pattern " + ping.getPattern()); } }
@Test public void buildSafeUri() { String input = "</script>"; // Builtin URI method's exception contains original input. try { new URI(input); } catch (URISyntaxException e) { assertTrue(e.getInput().contains("</script>")); } // Safe buildSafeUri method's exception has encoded the input. try { UriUtils.buildSafeUri(input); } catch (URISyntaxException e) { assertTrue(e.getInput().contains("%3C%2Fscript%3E")); } }
@Test public void buildSafeUri() { String input = "</script>"; // Builtin URI method's exception contains original input. try { new URI(input); } catch (URISyntaxException e) { assertTrue(e.getInput().contains("</script>")); } // Safe buildSafeUri method's exception has encoded the input. try { UriUtils.buildSafeUri(input); } catch (URISyntaxException e) { assertTrue(e.getInput().contains("%3C%2Fscript%3E")); } }
public static URI getAbsoluteURI(String href, String baseURI, XPathContext context) throws XPathException { URI absoluteURI; try { absoluteURI = ResolveURI.makeAbsolute(href, baseURI); } catch (java.net.URISyntaxException err) { XPathException e = new XPathException(err.getReason() + ": " + err.getInput(), err); e.setErrorCode("FOUT1170"); throw e; } if (absoluteURI.getFragment() != null) { XPathException e = new XPathException("URI for unparsed-text() must not contain a fragment identifier"); e.setErrorCode("FOUT1170"); throw e; } // The URL dereferencing classes throw all kinds of strange exceptions if given // ill-formed sequences of %hh escape characters. So we do a sanity check that the // escaping is well-formed according to UTF-8 rules EncodeForUri.checkPercentEncoding(absoluteURI.toString()); return absoluteURI; }
private void openResource(UIExecutionContext context, Resource<?> resource) throws IOException { UIDesktop desktop = context.getUIContext().getProvider().getDesktop(); if (resource instanceof FileResource<?>) { desktop.open((File) resource.getUnderlyingResourceObject()); } else if (resource instanceof URLResource) { try { desktop.browse(((URLResource) resource).getUnderlyingResourceObject().toURI()); } catch (URISyntaxException e) { throw new RuntimeException("Bad URL syntax: " + e.getInput(), e); } } }
public static URI getAbsoluteURI(String href, String baseURI, XPathContext context) throws XPathException { URI absoluteURI; try { absoluteURI = ResolveURI.makeAbsolute(href, baseURI); } catch (java.net.URISyntaxException err) { XPathException e = new XPathException(err.getReason() + ": " + err.getInput(), err); e.setErrorCode("FOUT1170"); throw e; } if (absoluteURI.getFragment() != null) { XPathException e = new XPathException("URI for unparsed-text() must not contain a fragment identifier"); e.setErrorCode("FOUT1170"); throw e; } // The URL dereferencing classes throw all kinds of strange exceptions if given // ill-formed sequences of %hh escape characters. So we do a sanity check that the // escaping is well-formed according to UTF-8 rules EncodeForUri.checkPercentEncoding(absoluteURI.toString()); return absoluteURI; }
absoluteURI = platform.makeAbsolute(href, baseURI); } catch (java.net.URISyntaxException err) { XPathException e = new XPathException(err.getReason() + ": " + err.getInput(), err); e.setErrorCode("XTDE1170"); throw e;