Java 如何在WebsProfileConsumerImpl中设置maxAuthenticationAge?
我是Spring新手,刚刚通过Spring Security和Okta获得SAML身份验证。然而,Spring拒绝超过7200秒的SAML身份验证,我想延长这段时间 有人说要在WebsProfileConsumerImpl bean上设置maxAuthenticationAge,但是……我不知道怎么做Java 如何在WebsProfileConsumerImpl中设置maxAuthenticationAge?,java,spring,spring-security,saml,Java,Spring,Spring Security,Saml,我是Spring新手,刚刚通过Spring Security和Okta获得SAML身份验证。然而,Spring拒绝超过7200秒的SAML身份验证,我想延长这段时间 有人说要在WebsProfileConsumerImpl bean上设置maxAuthenticationAge,但是……我不知道怎么做 有人能给我举个例子或者给我指出正确的方向吗?通常,如果你创建了所有的设置,你可以使用@Been in@Configuration类 // can put this been in any rela
有人能给我举个例子或者给我指出正确的方向吗?通常,如果你创建了所有的设置,你可以使用@Been in@Configuration类
// can put this been in any related config class, no need to create new one
@Configuration
public class Config {
@Bean
public WebSSOProfileConsumer getWebSSOProfileConsumerImpl(){
WebSSOProfileConsumerImpl consumer = new WebSSOProfileConsumerImpl();
consumer.setMaxAuthenticationAge(5000);
return consumer;
}
}
或Xml real项目
可悲的是,它还没有发布,您可能需要重新编写您的版本,或者只是从git repo复制粘贴新版本并使用它。这正是我所希望的解决方案。遗憾的是,它需要从master复制和粘贴WebsProfileConsumerImpl,但它可以工作!谢谢有一件事:奇怪的是,samlconfiguer.websoprofileconsumer和master中的属性本身接受websoprofileconsumeripl,而不是接口websoprofileconsumer。因此,GetWebsProfileConsumerImpl的返回类型不能是接口。有了这种调整,它似乎工作得很完美。@jchamberlain是的,在回答中修正了这个问题
<bean class="org.springframework.security.saml.websso.WebSSOProfileConsumerImpl"
id="myWebSSOProfileConsumer">
<property name="maxAuthenticationAge" value="5000"/>
</bean>
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/saml*").permitAll()
.anyRequest().authenticated()
.and()
.apply(saml())
.webSSOProfileConsumer(getWebSSOProfileConsumerImpl())// <= here
// ... rest of the setup
}
public WebSSOProfileConsumerImpl getWebSSOProfileConsumerImpl() {
WebSSOProfileConsumerImpl profileConsumer = new WebSSOProfileConsumerImpl();
profileConsumer.setMaxAuthenticationAge(5000);
return profileConsumer;
}