org.metaeffekt.artifact.resolver.download.ProxyConfig Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.metaeffekt.artifact.resolver.download;
import lombok.Getter;
import lombok.Setter;
import org.metaeffekt.core.util.FileUtils;
import org.yaml.snakeyaml.Yaml;
import java.io.File;
import java.io.IOException;
@Getter
@Setter
public class ProxyConfig {
public ProxyConfig() {}
private String scheme;
private String host;
private int port;
private String username;
private String password;
/**
* A '|'-separated list of hosts which are not routed through the proxy.
*/
private String nonProxyHosts;
public static ProxyConfig parseFromYaml(File yamlFile) throws IOException {
final String content = FileUtils.readFileToString(yamlFile, FileUtils.ENCODING_UTF_8);
return new Yaml().loadAs(content, ProxyConfig.class);
}
public boolean isValid() {
return host != null && port > 0;
}
public String getProxyString() {
return String.format("%s://%s:%s/", getScheme(), getHost(), getPort());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy