use of com.mercedesbenz.sechub.owaspzapwrapper.cli.MustExitRuntimeException in project sechub by mercedes-benz.
the class BaseTargetUriFactory method createBaseURIForTarget.
private URI createBaseURIForTarget(String targetUri) {
if (targetUri == null) {
throw new MustExitRuntimeException("Target URI may not be null.", MustExitCode.TARGET_URL_CONFIGURATION_INVALID);
}
String sanitizedTargetUri = sanitizeTargetUri(targetUri);
URI uri;
try {
uri = URI.create(sanitizedTargetUri);
} catch (IllegalArgumentException e) {
throw new MustExitRuntimeException("Target URI could not be converted from string.", e, MustExitCode.TARGET_URL_CONFIGURATION_INVALID);
}
String scheme = uri.getScheme();
if (!isValidScheme(scheme)) {
throw new MustExitRuntimeException("URI: " + uri.toString() + " does not contain valid scheme!", MustExitCode.TARGET_URL_CONFIGURATION_INVALID);
}
String userInfo = null;
String host = uri.getHost();
int port = uri.getPort();
String path = uri.getPath();
String query = null;
String fragment = null;
URI rootURI = null;
try {
rootURI = new URI(scheme, userInfo, host, port, path, query, fragment);
} catch (URISyntaxException e) {
throw new MustExitRuntimeException("Was not able to build base uri for: " + uri, e, MustExitCode.TARGET_URL_CONFIGURATION_INVALID);
}
return rootURI;
}
Aggregations