0

我正在使用 Spring Saml Security 并使用注释来提供 SP 元数据文件。我能够执行 SSO,并且当我尝试使用 http://localhost//saml/metadata 下载 SP 元数据文件时,会下载默认 SP 元数据文件而不是本地文件。 我没有使用任何 MetadataGeneratorFilter 来提供 SP 元数据 XML

@Bean
@DependsOn("parserPool")
public ExtendedMetadataDelegate spMetadataDelegate() throws MetadataProviderException, ResourceException {

    Timer backgroundTaskTimer = new Timer(true);

    ResourceBackedMetadataProvider resourceBackedMetadataProvider = new ResourceBackedMetadataProvider(backgroundTaskTimer,
            new FilesystemResource("<path-to-local-sp.xml>"));

    resourceBackedMetadataProvider.setParserPool(parserPool());
    resourceBackedMetadataProvider.initialize();
    ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate(resourceBackedMetadataProvider, spExtendedMetadata());
    return extendedMetadataDelegate;
}
    
@Bean
public ExtendedMetadata spExtendedMetadata()
{
    ExtendedMetadata extendedMetadata = new ExtendedMetadata();           
    extendedMetadata.setLocal(true);
    extendedMetadata.setAlias("metadataAlias");
    return extendedMetadata;
}

@Bean
public ExtendedMetadataDelegate spExtendedMetadataProvider() throws MetadataProviderException 
{
    File metadata = null;
    try 
    {
        metadata = new File(spMetadataFile);
    }
    catch (Exception e) 
    {
        Debug.println(Debug.INFO, "unable to read sp metadata file from "+ spMetadataFile);
    }
    FilesystemMetadataProvider provider = new FilesystemMetadataProvider(metadata);
    provider.setParserPool(parserPool());
    return new ExtendedMetadataDelegate(provider, spExtendedMetadata());
}

@Bean
@Qualifier("metadata")
public CachingMetadataManager metadata() throws MetadataProviderException, ResourceException 
{
    List<MetadataProvider> providers = new ArrayList<>();
    providers.add(spExtendedMetadataProvider());
    
    CachingMetadataManager metadataManager = new CachingMetadataManager(providers);
    metadataManager.setDefaultIDP(defaultIdp);
    return metadataManager;
}

也可以使用我们自己的登录、元数据和注销 URL,而不是默认 URL。

4

0 回答 0