|
47 | 47 | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
48 | 48 | import org.springframework.security.saml.*; |
49 | 49 | import org.springframework.security.saml.context.SAMLContextProviderImpl; |
| 50 | +import org.springframework.security.saml.context.SAMLContextProviderLB; |
50 | 51 | import org.springframework.security.saml.key.EmptyKeyManager; |
51 | 52 | import org.springframework.security.saml.key.JKSKeyManager; |
52 | 53 | import org.springframework.security.saml.key.KeyManager; |
@@ -281,7 +282,28 @@ public SAMLDefaultLogger samlLogger() { |
281 | 282 |
|
282 | 283 | @Bean |
283 | 284 | public SAMLContextProviderImpl contextProvider() { |
284 | | - return new SAMLContextProviderImpl(); |
| 285 | + SAMLContextProviderImpl provider; |
| 286 | + String serverName = environment.getProperty("proxy.saml.lb-server-name"); |
| 287 | + if (serverName != null && !serverName.isEmpty()) { |
| 288 | + SAMLContextProviderLB lbProvider = new SAMLContextProviderLB(); |
| 289 | + lbProvider.setServerName(serverName); |
| 290 | + String contextPath = environment.getProperty("proxy.saml.lb-context-path"); |
| 291 | + if (contextPath == null) contextPath = "/"; |
| 292 | + lbProvider.setContextPath(contextPath); |
| 293 | + String portInUrl = environment.getProperty("proxy.saml.lb-port-in-url"); |
| 294 | + if (portInUrl == null) portInUrl = "false"; |
| 295 | + lbProvider.setIncludeServerPortInRequestURL(Boolean.valueOf(portInUrl)); |
| 296 | + String scheme = environment.getProperty("proxy.saml.lb-scheme"); |
| 297 | + if (scheme == null) scheme = "https"; |
| 298 | + lbProvider.setScheme(scheme); |
| 299 | + String serverPort = environment.getProperty("proxy.saml.lb-server-port"); |
| 300 | + if (serverPort == null) serverPort = "443"; |
| 301 | + lbProvider.setServerPort(Integer.valueOf(serverPort)); |
| 302 | + provider = lbProvider; |
| 303 | + } else { |
| 304 | + provider = new SAMLContextProviderImpl(); |
| 305 | + } |
| 306 | + return provider; |
285 | 307 | } |
286 | 308 |
|
287 | 309 | @Bean |
|
0 commit comments