File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 11package org .cloudfoundry .identity .uaa .provider .saml ;
22
3+ import lombok .extern .slf4j .Slf4j ;
34import org .bouncycastle .jcajce .provider .BouncyCastleFipsProvider ;
45import org .cloudfoundry .identity .uaa .zone .IdentityZoneHolder ;
56import org .cloudfoundry .identity .uaa .zone .IdentityZoneProvisioning ;
1112import java .security .Security ;
1213
1314@ Configuration
15+ @ Slf4j
1416public class IdentityZoneConfig {
1517
1618 @ Bean
1719 public BouncyCastleFipsProvider setUpBouncyCastle () {
20+ // Ensure non blocking random if system property java.security.egd is set
21+ if (System .getProperty ("java.security.egd" , "/random" ).endsWith ("/urandom" ) &&
22+ !Security .getProperty ("securerandom.strongAlgorithms" ).contains ("NativePRNGNonBlocking" )) {
23+ String originalStrongAlgorithm = Security .getProperty ("securerandom.strongAlgorithms" );
24+ log .info ("Current securerandom.strongAlgorithms: {}" , originalStrongAlgorithm );
25+ String newStrongAlgorithm = "NativePRNGNonBlocking:SUN," + originalStrongAlgorithm ;
26+ log .info ("New securerandom.strongAlgorithms: {}" , newStrongAlgorithm );
27+ Security .setProperty ("securerandom.strongAlgorithms" , newStrongAlgorithm );
28+ }
1829 BouncyCastleFipsProvider provider = new BouncyCastleFipsProvider ();
1930 Security .addProvider (provider );
2031 return provider ;
Original file line number Diff line number Diff line change 1414package org .cloudfoundry .identity .uaa .provider .saml ;
1515
1616import lombok .extern .slf4j .Slf4j ;
17- import org .bouncycastle .jcajce .provider .BouncyCastleFipsProvider ;
1817import org .cloudfoundry .identity .uaa .saml .SamlKey ;
1918import org .cloudfoundry .identity .uaa .util .KeyWithCert ;
2019import org .cloudfoundry .identity .uaa .zone .SamlConfig ;
2120
22- import java .security .Security ;
2321import java .security .cert .CertificateException ;
2422import java .util .ArrayList ;
2523import java .util .Collections ;
@@ -54,10 +52,6 @@ public SamlKeyManager getKeyManager(SamlConfig config) {
5452
5553 abstract static class BaseSamlKeyManagerImpl implements SamlKeyManager {
5654
57- static {
58- Security .addProvider (new BouncyCastleFipsProvider ());
59- }
60-
6155 protected List <KeyWithCert > convertList (List <SamlKey > samlKeys ) {
6256 List <KeyWithCert > result = new ArrayList <>();
6357 for (SamlKey k : samlKeys ) {
Original file line number Diff line number Diff line change 88import org .springframework .beans .factory .annotation .Value ;
99import org .springframework .context .annotation .Bean ;
1010import org .springframework .context .annotation .Configuration ;
11+ import org .springframework .context .annotation .DependsOn ;
1112import org .springframework .security .saml2 .Saml2Exception ;
1213import org .springframework .security .saml2 .provider .service .registration .InMemoryRelyingPartyRegistrationRepository ;
1314import org .springframework .security .saml2 .provider .service .registration .RelyingPartyRegistration ;
@@ -42,6 +43,7 @@ public SamlRelyingPartyRegistrationRepositoryConfig(@Qualifier("samlEntityID") S
4243 }
4344
4445 @ Autowired
46+ @ DependsOn ({"setUpBouncyCastle" })
4547 @ Bean
4648 RelyingPartyRegistrationRepository relyingPartyRegistrationRepository (SamlIdentityProviderConfigurator samlIdentityProviderConfigurator ) {
4749 SamlKeyManagerFactory .SamlConfigPropsSamlKeyManagerImpl samlKeyManager = new SamlKeyManagerFactory .SamlConfigPropsSamlKeyManagerImpl (samlConfigProps );
You can’t perform that action at this time.
0 commit comments