changed: deprecation code

This commit is contained in:
Ludy87 2024-10-19 16:48:57 +02:00
parent f23007515a
commit 1c1bea090d
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

@ -3,6 +3,8 @@ package stirling.software.SPDF.model;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -131,19 +133,20 @@ public class ApplicationProperties {
private String privateKey; private String privateKey;
private String spCert; private String spCert;
private String entityId;
private String spBaseUrl;
private String idpMetadataLocation;
public InputStream getIdpMetadataUri() throws IOException { public InputStream getIdpMetadataUri() throws IOException {
if (idpMetadataUri.startsWith("classpath:")) { if (idpMetadataUri.startsWith("classpath:")) {
return new ClassPathResource(idpMetadataUri.substring("classpath".length())) return new ClassPathResource(idpMetadataUri.substring("classpath".length()))
.getInputStream(); .getInputStream();
} }
URL url = new URL(idpMetadataUri); try {
URI uri = new URI(idpMetadataUri);
URL url = uri.toURL();
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
return connection.getInputStream(); return connection.getInputStream();
} catch (URISyntaxException e) {
throw new IOException("Invalid URI format: " + idpMetadataUri, e);
}
} }
public Resource getSpCert() { public Resource getSpCert() {