JSF1094错误在cluster env中使用闪存时发生了

发布于 2025-01-26 00:52:46 字数 831 浏览 2 评论 0原文

我在集群Env(Alb + Two Wildfly 17 +可分布设置)中使用PrimeFaces 11。 当我使用Flash从Page1传递参数到Page2时,我会收到以下错误,并且不能传递参数。

 [javax.enterprise.resource.webcontainer.jsf.flash] (default task-29) JSF1094: Could not decode flash data from incoming cookie value Invalid characters in decrypted value.  Processing will continue, but the flash is unavailable for this request.

如果我仅在一台服务器中运行它,则可以正常传递参数。

  • 设置数据
  flash flash = faceScontext.getCurrentInstance().getExternalContext()。getflash();
 flash.put(redirect_data_key,rdata);
 
  • 获取数据
  flash flash = faceScontext.getCurrentInstance().getExternalContext()。getflash();
 返回(redirectData)flash.get(redirect_data_key);
 

我如何解决?

I am using primefaces 11 in a cluster env(alb + two wildfly 17 + distributable setting).
when I use Flash to pass parameter from page1 to page2, I got the following error, and the parameters can no be passed.

 [javax.enterprise.resource.webcontainer.jsf.flash] (default task-29) JSF1094: Could not decode flash data from incoming cookie value Invalid characters in decrypted value.  Processing will continue, but the flash is unavailable for this request.

If I run it in only one server, the parameters can be passed normally.

  • set data
 Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
 flash.put(REDIRECT_DATA_KEY, rData);
  • get data
 Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
 return (RedirectData) flash.get(REDIRECT_DATA_KEY);

How I can solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北城挽邺 2025-02-02 00:52:46

来自Red Hat Offical Support:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
...
    <env-entry>
        <env-entry-name>jsf/FlashSecretKey</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <!-- http://www.digitalsanctuary.com/aes-key-generator.php -->
        <env-entry-value>Ya+MAlSDzgC3LAXgfEoPA/J6saEp7MtjjF0P6LP69nGk=</env-entry-value>
    </env-entry>

    <distributable/>
</web-app>

JSF/FlashSecretkey是Base64编码AES 256BIT键,用于加密闪存示波器cookie(例如CSFCFC = K8AUYBA%3D;。
键可以通过以下代码生成:

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class Main {
    public static void main(String ... args) throws NoSuchAlgorithmException {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(256); // key length is 256 byte
        SecretKey secretKey = keyGen.generateKey();
        System.out.println("key: " + Base64.getEncoder().encodeToString(secretKey.getEncoded()));
    }
}

flash cookie值set-cookie:csfcfc = k8auyba%3D;默认情况下是AES加密的。如果未设置jndi键java:comp/env/jsf/jsf/flashsecretkey,则Mojarra将尝试创建一个随机秘密键,该密钥用于flash cookie值中的AES加密中使用。

在群集环境的情况下,该行为将导致每个聚类EAP实例具有不同的秘密密钥。结果,Mojarra无法通过以下错误消息恢复聚类的Flash Cookie值:

20:09:40,317 SEVERE [javax.enterprise.resource.webcontainer.jsf.flash] (default task-1) 
JSF1094: Could not decode flash data from incoming cookie value Invalid characters in decrypted value.  Processing will continue, but the flash is unavailable for this request.

From Red Hat offical support:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
...
    <env-entry>
        <env-entry-name>jsf/FlashSecretKey</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <!-- http://www.digitalsanctuary.com/aes-key-generator.php -->
        <env-entry-value>Ya+MAlSDzgC3LAXgfEoPA/J6saEp7MtjjF0P6LP69nGk=</env-entry-value>
    </env-entry>

    <distributable/>
</web-app>

jsf/FlashSecretKey is base64 encoded AES 256bit key which used for encrypting flash scope cookie like csfcfc=K8auYBA%3D;.
The key can generate by the following code:

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class Main {
    public static void main(String ... args) throws NoSuchAlgorithmException {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(256); // key length is 256 byte
        SecretKey secretKey = keyGen.generateKey();
        System.out.println("key: " + Base64.getEncoder().encodeToString(secretKey.getEncoded()));
    }
}

The flash cookie value Set-Cookie: csfcfc=K8auYBA%3D; is AES encrypted by default. If JNDI key java:comp/env/jsf/FlashSecretKey is not set, Mojarra will try to create a random secret key that is used in AES encryption for the flash cookie value.

In case of cluster environment, that behavior will cause each clustered EAP instance has a different secret key. As a result, Mojarra is unable to restore clustered flash cookie value with the following error message:

20:09:40,317 SEVERE [javax.enterprise.resource.webcontainer.jsf.flash] (default task-1) 
JSF1094: Could not decode flash data from incoming cookie value Invalid characters in decrypted value.  Processing will continue, but the flash is unavailable for this request.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文