-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Human Readable Bridgehead for frontend dto
- Loading branch information
Showing
6 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.samply.proxy; | ||
|
||
import de.samply.app.ProjectManagerConst; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = ProjectManagerConst.HTTP_PROXY_PREFIX) | ||
public class HttpProxyConfiguration extends ProxyConfiguration { | ||
|
||
public HttpProxyConfiguration() { | ||
this.setSchema(ProjectManagerConst.HTTP_PROTOCOL_SCHEMA); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/de/samply/proxy/HttpsProxyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.samply.proxy; | ||
|
||
import de.samply.app.ProjectManagerConst; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = ProjectManagerConst.HTTPS_PROXY_PREFIX) | ||
public class HttpsProxyConfiguration extends ProxyConfiguration { | ||
|
||
public HttpsProxyConfiguration() { | ||
this.setSchema(ProjectManagerConst.HTTPS_PROTOCOL_SCHEMA); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package de.samply.proxy; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import lombok.Data; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@Data | ||
public class ProxyConfiguration { | ||
|
||
private String host; | ||
private Integer port; | ||
private String schema; | ||
private String username; | ||
private String password; | ||
private String url; | ||
|
||
// Comma-separated list of hosts or IPs to bypass the proxy | ||
private String noProxy; | ||
|
||
// Convenience method to get noProxy as a List | ||
public List<String> getNoProxyList() { | ||
return noProxy != null ? Arrays.asList(noProxy.split(",")) : List.of(); | ||
} | ||
|
||
@PostConstruct | ||
public void init() throws MalformedURLException { | ||
if (StringUtils.hasText(this.url)) { | ||
URL url = new URL(this.url); | ||
this.schema = url.getProtocol(); | ||
this.host = url.getHost(); | ||
this.port = url.getPort(); | ||
setProxyUserAndPassword(url.getUserInfo()); | ||
} | ||
if (isConfigured()) { | ||
String schema = (this.schema != null) ? this.schema : ""; | ||
log.info(schema + " Proxy configured:"); | ||
log.info("\t-Host: " + this.host); | ||
log.info("\t-Port: " + this.port); | ||
if (username != null && password != null) { | ||
log.info("\t-Username: " + username); | ||
} | ||
} | ||
} | ||
|
||
private void setProxyUserAndPassword(String userInfo) { | ||
if (userInfo != null) { | ||
String[] credentials = userInfo.split(":"); | ||
if (credentials.length == 2) { | ||
this.username = credentials[0]; | ||
this.password = credentials[1]; | ||
} | ||
} | ||
} | ||
|
||
public boolean isConfigured() { | ||
return StringUtils.hasText(this.host) && this.port != null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters