|
|
|
@ -28,6 +28,7 @@ import java.net.URL; |
|
|
|
import java.net.URLConnection; |
|
|
|
import java.net.URLConnection; |
|
|
|
import java.net.URLDecoder; |
|
|
|
import java.net.URLDecoder; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
|
|
import java.util.Base64; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
@ -46,6 +47,8 @@ import org.springframework.util.StringUtils; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class UrlResource extends AbstractFileResolvingResource { |
|
|
|
public class UrlResource extends AbstractFileResolvingResource { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String AUTHORIZATION = "Authorization"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Original URI, if available; used for URI and File access. |
|
|
|
* Original URI, if available; used for URI and File access. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -237,6 +240,16 @@ public class UrlResource extends AbstractFileResolvingResource { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void customizeConnection(URLConnection con) throws IOException { |
|
|
|
|
|
|
|
super.customizeConnection(con); |
|
|
|
|
|
|
|
String userInfo = this.url.getUserInfo(); |
|
|
|
|
|
|
|
if (userInfo != null) { |
|
|
|
|
|
|
|
String encodedCredentials = Base64.getUrlEncoder().encodeToString(userInfo.getBytes()); |
|
|
|
|
|
|
|
con.setRequestProperty(AUTHORIZATION, "Basic " + encodedCredentials); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This implementation returns the underlying URL reference. |
|
|
|
* This implementation returns the underlying URL reference. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|