首页 > 解决方案 > Spring SAML 安全证书缓存问题

问题描述

我正在使用 Spring security SAML 1.0.3 Release 版本。我发现了一个问题,如果我们为 IDP 上传证书,它不会反映在 Spring SAML 中。问题似乎出 在有缓存 Map 的MetadataCredentialResolver上

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

它从缓存中挑选证书,因此新上传的证书被忽略。有没有办法重置缓存?

标签: springspring-securityspring-security-saml2

解决方案


我认为摆脱缓存的方法是覆盖一个类并使其为所有与缓存相关的调用将值设置为 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
}

推荐阅读