【问题标题】:Spring SAML Security Certificate Caching IssueSpring SAML 安全证书缓存问题
【发布时间】:2020-05-17 06:19:04
【问题描述】:
我使用的是 Spring security SAML 1.0.3 Release 版本。我发现了一个问题,如果我们为 IDP 上传证书,它不会反映在 Spring SAML 中。
问题似乎出在 MetadataCredentialResolver 那里有一个缓存 Map
Map<MetadataCacheKey, SoftReference<Collection<Credential>>> cache;
它正在从缓存中挑选证书,因此新上传的证书被忽略。有没有办法重置缓存?
【问题讨论】:
标签:
spring
spring-security
spring-security-saml2
【解决方案1】:
我认为摆脱缓存的方法是重写一个类,并将所有与缓存相关的调用的值设置为 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
}