Search in sources :

Example 6 with MustExitRuntimeException

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;
}
Also used : MustExitRuntimeException(com.mercedesbenz.sechub.owaspzapwrapper.cli.MustExitRuntimeException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

MustExitRuntimeException (com.mercedesbenz.sechub.owaspzapwrapper.cli.MustExitRuntimeException)6 IOException (java.io.IOException)3 SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)2 URI (java.net.URI)2 Path (java.nio.file.Path)2 TextFileReader (com.mercedesbenz.sechub.commons.TextFileReader)1 SecHubScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubScanConfiguration)1 AuthenticationType (com.mercedesbenz.sechub.owaspzapwrapper.config.auth.AuthenticationType)1 File (java.io.File)1 HttpURLConnection (java.net.HttpURLConnection)1 InetSocketAddress (java.net.InetSocketAddress)1 MalformedURLException (java.net.MalformedURLException)1 Proxy (java.net.Proxy)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)1 SSLContext (javax.net.ssl.SSLContext)1 TrustManager (javax.net.ssl.TrustManager)1 X509TrustManager (javax.net.ssl.X509TrustManager)1