|
|
@ -17,7 +17,7 @@ import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import jakarta.enterprise.context.RequestScoped; |
|
|
|
import jakarta.faces.view.ViewScoped; |
|
|
|
import jakarta.inject.Named; |
|
|
|
import jakarta.inject.Named; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -28,7 +28,7 @@ import jakarta.inject.Named; |
|
|
|
* @since Jan 31, 2024 |
|
|
|
* @since Jan 31, 2024 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Named |
|
|
|
@Named |
|
|
|
@RequestScoped |
|
|
|
@ViewScoped |
|
|
|
public class CookieBean { |
|
|
|
public class CookieBean { |
|
|
|
|
|
|
|
|
|
|
|
private static final String KEY_DISPLAY_ROWS = "displayRows"; |
|
|
|
private static final String KEY_DISPLAY_ROWS = "displayRows"; |
|
|
@ -44,10 +44,15 @@ public class CookieBean { |
|
|
|
|
|
|
|
|
|
|
|
private Map<String, String> cookieMap; |
|
|
|
private Map<String, String> cookieMap; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Map<String, Object> properties = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor. |
|
|
|
* Constructor. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public CookieBean() { |
|
|
|
public CookieBean() { |
|
|
|
|
|
|
|
properties.put("maxAge", 31536000); |
|
|
|
|
|
|
|
properties.put("path", "/"); |
|
|
|
|
|
|
|
properties.put("SameSite", "Strict"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
@PostConstruct |
|
|
@ -63,11 +68,6 @@ public class CookieBean { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void saveCookies() |
|
|
|
public void saveCookies() |
|
|
|
throws UnsupportedEncodingException { |
|
|
|
throws UnsupportedEncodingException { |
|
|
|
final Map<String, Object> properties = new HashMap<>(); |
|
|
|
|
|
|
|
properties.put("maxAge", 31536000); |
|
|
|
|
|
|
|
properties.put("path", "/"); |
|
|
|
|
|
|
|
properties.put("SameSite", "Strict"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Entry<String, String> e : cookieMap.entrySet()) { |
|
|
|
for (Entry<String, String> e : cookieMap.entrySet()) { |
|
|
|
JSFUtils.outputCookie(e.getKey(), e.getValue(), |
|
|
|
JSFUtils.outputCookie(e.getKey(), e.getValue(), |
|
|
|
properties); |
|
|
|
properties); |
|
|
@ -86,6 +86,13 @@ public class CookieBean { |
|
|
|
|
|
|
|
|
|
|
|
public void setCookieValue(String name, String value) { |
|
|
|
public void setCookieValue(String name, String value) { |
|
|
|
cookieMap.put(name, value); |
|
|
|
cookieMap.put(name, value); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
JSFUtils.outputCookie(name, value, properties); |
|
|
|
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
|
|
|
// Should never happen. But...
|
|
|
|
|
|
|
|
log.error("Unable to encode cookie", e); |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ************************
|
|
|
|
// ************************
|
|
|
@ -97,7 +104,7 @@ public class CookieBean { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setSearchText(String value) { |
|
|
|
public void setSearchText(String value) { |
|
|
|
cookieMap.put(KEY_SEARCH_FOR, value); |
|
|
|
setCookieValue(KEY_SEARCH_FOR, value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// **
|
|
|
|
// **
|
|
|
@ -110,7 +117,8 @@ public class CookieBean { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setSearchType(Integer value) { |
|
|
|
public void setSearchType(Integer value) { |
|
|
|
cookieMap.put(KEY_SEARCH_TYPE, String.valueOf(value)); |
|
|
|
String st = String.valueOf(value); |
|
|
|
|
|
|
|
setCookieValue(KEY_SEARCH_TYPE, st); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// **
|
|
|
|
// **
|
|
|
@ -123,11 +131,13 @@ public class CookieBean { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setDisplayListSize(Integer value) { |
|
|
|
public void setDisplayListSize(Integer value) { |
|
|
|
cookieMap.put(KEY_DISPLAY_ROWS, String.valueOf(value)); |
|
|
|
setCookieValue(KEY_DISPLAY_ROWS, String.valueOf(value)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* IdleMonitor backing methods (session/View timeout) |
|
|
|
* IdleMonitor backing methods (session/View timeout) |
|
|
|
|
|
|
|
* Todo: move to a more general location. Currently |
|
|
|
|
|
|
|
* only used by view editor, not Main! |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void sessionIdleListener() { |
|
|
|
public void sessionIdleListener() { |
|
|
|
log.info("Session Idle Listener fired."); |
|
|
|
log.info("Session Idle Listener fired."); |
|
|
|