Spring SAML安全证书缓存问题

时间:2020-01-31 14:56:38

标签: spring spring-security spring-security-saml2

我正在使用Spring Security SAML 1.0.3发行版。我发现了一个问题,如果我们为IDP上载证书,则该证书不会反映在Spring SAML中。 问题似乎出在 MetadataCredentialResolver 上,那里有一个缓存Map

  Map<MetadataCacheKey, SoftReference<Collection<Credential>>> cache;

它正在从缓存中选择证书,因此将忽略较新的上载证书。有什么方法可以重置缓存?

1 个答案:

答案 0 :(得分:0)

我认为摆脱缓存的方法是重写一个类,并使所有与缓存相关的调用的值都设置为null:-

@Override
protected Collection<Credential> retrieveFromCache(MetadataCacheKey cacheKey) 
{
    //return null and let it fetch from metadata
    return null;
}
@Override
protected void cacheCredentials(MetadataCacheKey cacheKey, 
Collection<Credential> credentials) {
   //do not put anything into cache
}