All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bdeploy.common.cfg.RemoteValidator Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.3.6
Show newest version
package io.bdeploy.common.cfg;

import io.bdeploy.common.cfg.Configuration.ConfigValidator;
import io.bdeploy.common.cfg.Configuration.ValidationMessage;

/**
 * Checks if the given input is a valid remote reference.
 */
@ValidationMessage("Invalid remote: '%s'. A remote must be a local path or start with 'https://' and end with '/api'")
public class RemoteValidator implements ConfigValidator {

    public static final String API_SUFFIX = "/api";

    @Override
    public boolean test(String value) {
        String lower = value.toLowerCase();

        // Allow local paths and file URLs
        if (lower.startsWith("/") || lower.startsWith(".") || lower.startsWith("file:") || lower.startsWith("jar:file:")) {
            return true;
        }

        return lower.startsWith("https://") && lower.endsWith(API_SUFFIX);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy