use of com.cloudbees.plugins.credentials.domains.SchemeSpecification in project blueocean-plugin by jenkinsci.
the class CredentialsUtils method generateDomainSpecifications.
public static List<DomainSpecification> generateDomainSpecifications(@Nullable String uriStr) {
if (StringUtils.isBlank(uriStr)) {
return Collections.emptyList();
}
List<DomainSpecification> domainSpecifications = new ArrayList<>();
try {
URI uri = new URI(uriStr);
// XXX: UriRequirementBuilder.fromUri() maps "" path to "/", so need to take care of it here
String path = uri.getRawPath() == null ? null : (uri.getRawPath().trim().isEmpty() ? "/" : uri.getRawPath());
domainSpecifications.add(new PathSpecification(path, "", false));
if (uri.getPort() != -1) {
domainSpecifications.add(new HostnamePortSpecification(uri.getHost() + ":" + uri.getPort(), null));
} else {
domainSpecifications.add(new HostnameSpecification(uri.getHost(), null));
}
domainSpecifications.add(new SchemeSpecification(uri.getScheme()));
} catch (URISyntaxException e) {
// for now, we are returning empty list to match with URIRequirementBuilder.fromUri()
return domainSpecifications;
}
return Collections.emptyList();
}
Aggregations