Results 1 to 2 of 2

Thread: Setting Dynamically the token-validitys-seconds of RememberMe

  1. #1
    Join Date
    Aug 2012
    Posts
    104

    Default Setting Dynamically the token-validitys-seconds of RememberMe

    Hi experts,

    I've declared a RememberMe bean in my XML:

    Code:
    	<security:http authentication-manager-ref="authenticationManager">
    .....        
            <security:remember-me 
    			data-source-ref="dataSource"
    			user-service-ref="userDetailsService"/>
            
    	</security:http>
    As far as I understand, this causes PersistentTokenBasedRememberMeServices because data-source is declared.
    I can ass also set 'token-validity-seconds', but life are more complicated than this... I want to set the validity dynamically.

    How can I do this? how can i "autowire" this bean, or how can I get it using the "context.getBean()"? I do not know the name of this bean... Do I have to declare it differently?

    thanks,
    Ohad

  2. #2
    Join Date
    Aug 2012
    Posts
    104

    Default

    Got it!

    All you have to do is autowiring the remember-me service, and set the token validity:

    Code:
    	@Autowired
    	private AbstractRememberMeServices rememberMeService;
    and in your code, where-ever needed:

    Code:
    		rememberMeService.setTokenValiditySeconds(X);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •