Spring Security中如何更改SAML请求的签名算法

use*_*968 2 java spring saml digital-signature spring-saml

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

据我了解,Spring Security使用开放的saml对SHA1withRSA作为签名算法的SAML请求进行签名。

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

如何才能做到这一点 ?

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

Vla*_*fer 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);

    }

}
Run Code Online (Sandbox Code Playgroud)