package de.champonthis.buntspecht.security;

import jakarta.servlet.http.HttpServletRequest;

import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices;
import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;


public class LocalRememberMeServices extends PersistentTokenBasedRememberMeServices {

	
	public LocalRememberMeServices(String key, UserDetailsService userDetailsService,
			PersistentTokenRepository tokenRepository) {
		super(key, userDetailsService, tokenRepository);
	}

	/*
	 * @see org.springframework.security.web.authentication.rememberme.
	 * AbstractRememberMeServices#rememberMeRequested(javax.servlet.http.
	 * HttpServletRequest, java.lang.String)
	 */
	@Override
	protected boolean rememberMeRequested(HttpServletRequest request, String parameter) {
		Object value = request.getAttribute(parameter);
		if (value != null) {
			String paramValue = value.toString();
			if (paramValue.equalsIgnoreCase("true") || paramValue.equalsIgnoreCase("on")
					|| paramValue.equalsIgnoreCase("yes") || paramValue.equals("1")) {
				return true;
			}
		}

		return super.rememberMeRequested(request, parameter);
	}

}
