我正在使用 spring security saml 扩展来使用 ADFS 作为 IDP 来实现 SSO。
据我了解,spring security 使用 open saml 以 SHA1withRSA 作为签名算法对 SAML 请求进行签名。
我们需要更改为使用 SHA256withRSA 来签署 SAML 请求。
如何才能做到这一点?
感谢对此的任何建议。提前非常感谢
最佳答案
确保使用最新的 Spring SAML(或至少将 OpenSAML 更新到最新版本)。按如下方式扩展 SAMLBootstrap 类,并将其插入到 Spring 配置中,而不是原始的 SAMLBootstrap 类:
package fi.schafer.saml.custom;
import org.opensaml.Configuration;
import org.opensaml.xml.security.BasicSecurityConfiguration;
import org.opensaml.xml.signature.SignatureConstants;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
public class SAMLBootstrap extends org.springframework.security.saml.SAMLBootstrap {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
super.postProcessBeanFactory(beanFactory);
BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
}
}
关于java - 如何更改Spring Security中SAML请求的签名算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23681362/