NonSnarlIdpMetadataManager extends IdpMetadataManager implements ExtendedMetadataProvider, InitializingBean, DisposableBean, BeanNameAware { @Override public List<ExtendedMetadataDelegate> getAvailableProviders() { IdentityZone zone = IdentityZoneHolder.get(); List<ExtendedMetadataDelegate> result = new ArrayList<>(); try { result.add(getLocalIdp()); } catch (MetadataProviderException e) { throw new IllegalStateException(e); } for (SamlServiceProviderHolder holder : configurator.getSamlServiceProviders()) { log.info("Adding SAML SP zone[" + zone.getId() + "] alias[" + holder.getSamlServiceProvider().getEntityId() + "]"); try { ExtendedMetadataDelegate delegate = holder.getExtendedMetadataDelegate(); initializeProvider(delegate); initializeProviderData(delegate); initializeProviderFilters(delegate); result.add(delegate); } catch (MetadataProviderException e) { log.error("Invalid SAML IDP zone[" + zone.getId() + "] alias[" + holder.getSamlServiceProvider().getEntityId() + "]", e); } } return result; } NonSnarlIdpMetadataManager(SamlServiceProviderConfigurator configurator); @Override void setBeanName(String name); @Override void setProviders(List<MetadataProvider> newProviders); @Override void refreshMetadata(); @Override void addMetadataProvider(MetadataProvider newProvider); @Override void removeMetadataProvider(MetadataProvider provider); @Override List<MetadataProvider> getProviders(); @Override List<ExtendedMetadataDelegate> getAvailableProviders(); ExtendedMetadataDelegate getLocalIdp(); @Override Set<String> getIDPEntityNames(); @Override Set<String> getSPEntityNames(); List<RoleDescriptor> getRole(String entityID, QName roleName); @Override RoleDescriptor getRole(String entityID, QName roleName, String supportedProtocol); @Override boolean isIDPValid(String idpID); @Override boolean isSPValid(String spID); @Override String getHostedIdpName(); @Override void setHostedIdpName(String hostedIdpName); @Override String getHostedSPName(); @Override void setHostedSPName(String hostedSPName); @Override String getDefaultIDP(); @Override EntityDescriptor getEntityDescriptor(String entityID); @Override EntityDescriptor getEntityDescriptor(byte[] hash); @Override String getEntityIdForAlias(String entityAlias); @Override ExtendedMetadata getDefaultExtendedMetadata(); @Override void setDefaultExtendedMetadata(ExtendedMetadata defaultExtendedMetadata); @Override boolean isRefreshRequired(); @Override void setRefreshRequired(boolean refreshRequired); @Override void setKeyManager(KeyManager keyManager); @Autowired(required = false) void setTLSConfigurer(TLSProtocolConfigurer configurer); @Override void destroy(); @Override ExtendedMetadata getExtendedMetadata(String entityID); IdpMetadataGenerator getGenerator(); void setGenerator(IdpMetadataGenerator generator);  }
@Test void getAvailableProvidersForDefaultAndNonDefaultZone() { IdentityZone uaaZone = IdentityZoneHolder.getUaaZone(); samlTestUtils.setupZoneWithSamlConfig(uaaZone); IdentityZone testZone = new IdentityZone(); testZone.setName("non-default-zone"); testZone.setId(testZone.getName()); samlTestUtils.setupZoneWithSamlConfig(testZone); when(mockSamlServiceProviderProvisioning.retrieveActive(IdentityZone.getUaaZoneId())).thenReturn(Collections.singletonList( mockSamlServiceProviderForZone(IdentityZone.getUaaZoneId()))); when(mockSamlServiceProviderProvisioning.retrieveActive(testZone.getId())).thenReturn(Collections.singletonList( mockSamlServiceProviderForZone(testZone.getId()))); IdentityZoneHolder.set(uaaZone); assertEquals(1, samlServiceProviderConfigurator.getSamlServiceProvidersForZone(uaaZone).size()); assertEquals(2, this.nonSnarlIdpMetadataManager.getAvailableProviders().size()); IdentityZoneHolder.set(testZone); assertEquals(1, samlServiceProviderConfigurator.getSamlServiceProvidersForZone(testZone).size()); assertEquals(2, this.nonSnarlIdpMetadataManager.getAvailableProviders().size()); }