2

我正在使用 spring security saml 扩展以 ADFS 作为 IDP 实现 SSO。

据我了解,spring security 使用 open saml 以 SHA1withRSA 作为签名算法对 SAML 请求进行签名。

我们需要更改以使用 SHA256withRSA 对 SAML 请求进行签名。

如何才能做到这一点 ?

感谢您对此的任何建议。首先十分感谢

4

1 回答 1

5

确保使用最新的 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);

    }

}
于 2014-05-17T17:11:14.690 回答