Drools KnowledgeAgent 和 Guvnor:身份验证失败

发布于 2024-12-10 17:48:01 字数 891 浏览 6 评论 0原文

这真的让我抓狂。

我在 JBoss AS 中有一个 Guvnor(稍后会详细介绍版本)。我编辑了 Components.xml 以启用身份验证(使用 JAAS,我将用户和密码设置得很好)和基于角色的权限。我有一个具有完全权限的“管理员”用户和一个具有只读权限的“代理”用户。到目前为止一切顺利,在 Guvnor 中我可以看到用户和适当的权限,从浏览器我可以使用“admin”用户登录来上传规则等,并且我可以使用“agent”用户下载changeset.xmls和二进制文件。

现在,我从 Java 应用程序中设置了一个知识代理。在 UrlResource 中,我设置了用户名(“agent”)和密码。变更集下载得很好,但是,changeset.xml 引用了其他资源(例如 PKG)。下载失败(HTTP 401)。看来 Drools 忘记了我的凭据。

手动编辑changeset.xml,并添加enableBasicAuthentcation、用户名和密码 - 它工作正常。但这不是正确的方法,真的。

我一直在寻找任一解决方案:a) 在 Guvnor 中查看一些选项面板,以便我可以在部署包时自动设置在changeset.xml 中嵌入的内容 b) 找到一种方法,以便在我的 Java 项目中传递凭据所以一切正常。

现在,我尝试了Drools 5.1.1、5.2.FINAL、5.3.CR1,并浏览了这些版本的文档。我发现的唯一注释是在 5.3 文档中:“更改集中的用户 ID 和密码应与在 elements.xml 中配置的身份验证器的要求一致。” - 谢谢,我明白了,但是该怎么做呢? “更多详细信息,请参阅《管理指南》的“安全 - 身份验证和基本访问”部分。”我做了,但什么也没发现。

所以说真的,我错过了什么,或者我做错了什么?解决这个问题的唯一方法真的是不使用身份验证吗?或者在每次更改时手动编辑changeset.xml?

任何帮助将不胜感激。

This one is really driving me nuts.

I have a Guvnor inside JBoss AS (more on versions later). I have edited the components.xml to enable authentication (with JAAS, I have the users and passwords set up just fine) and role based permission. I have an 'admin' user with full privileges and an 'agent' user, with read-only permissions. So far so good, in Guvnor I can see the users and proper privileges, from browsers I can login with the 'admin' user to upload rules and such, and I can download changeset.xmls and binaries with the 'agent' user.

Now, from a Java application I set up a knowledge agent. In the UrlResource, I set up the username ('agent') and password. The changeset downloads just fine, however, the changeset.xml refers to other resources (such as PKG). Downloading them fails (HTTP 401). Seems like Drools forgets about my credentials in the way.

Editing the changeset.xml by hand, and adding enableBasicAuthentcation, username and password - it works fine. But this is not the way to go, really.

I have been looking for either solution: a) see some option panel in Guvnor, so that I can set up what to embed in changeset.xml automatically when deploying packages b) find a way, so the credentials are passed around in my Java project so everything works.

Now, I tried Drools 5.1.1, 5.2.FINAL, 5.3.CR1, looked through the documentation of these versions. The only remark I found was in the 5.3 docs: "The User ID and Password in the change-set should be consistent with the requirements of the Authenticator configured in components.xml." - thank you, I understand, but how to do that? "Please refer to the "Security - Authentication and basic access" section of the "Administration Guide" for more details." I did and found nothing.

So really, what am I missing, or what am I doing wrong? Is really the only way to solve this is not to use authentication? Or edit changeset.xmls by hand at every change?

Any help would be greatly appreciated.

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

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

发布评论

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

评论(2

请爱~陌生人 2024-12-17 17:48:01

这里发布了一个解决方法

[JBRULES-3465]

https://issues.jboss.org/browse/JBRULES -3465

其约束仅适用于每个代理一个用户名

There's a workaround posted here

[JBRULES-3465]

https://issues.jboss.org/browse/JBRULES-3465

with the constraint it only works for one username per agent

不顾 2024-12-17 17:48:01

我在使用 KnowledgeAgent 时已经遇到这个错误,看来 Url 资源设置不正确(我说的是 5.1.1 版本)
作为解决方法,您可以设置一个新的代理事件侦听器,以便以这种方式强制使用用户名/密码(在我的示例中它是一个内部类):

    private static final class AuthKnowledgeAgentEventListener extends
        DefaultKnowledgeAgentEventListener {
    private final String username;

    private final String password;

    private AuthKnowledgeAgentEventListener(String username, String password) {
        this.username = username;
        this.password = password;
    }

    @Override
    public void beforeChangeSetApplied(BeforeChangeSetAppliedEvent event) {
        // Obliged to do this to get UrlResources done correctly...
        ChangeSet changeSet = event.getChangeSet();
        for (Resource res : changeSet.getResourcesAdded()) {
            if (res instanceof UrlResource) {
                setupUrlResource((UrlResource) res);
            }
        }
        for (Resource res : changeSet.getResourcesModified()) {
            if (res instanceof UrlResource) {
                setupUrlResource((UrlResource) res);
            }
        }
                        // maybe this is needed for deleted resources, i didn't check

    }

    private void setupUrlResource(UrlResource resource) {
        if (starter.droolsAuthenticationEnabled) {
            resource.setBasicAuthentication("enabled");
            resource.setUsername(username);
            resource.setPassword(password);
        }
    }
}

然后将此事件侦听器设置为您的代理:

agent.addEventListener(new AuthKnowledgeAgentEventListener("myusername","mypassword"));

就是这样!

I already got this bug while using KnowledgeAgent, It seems that Url resources are not set correctly (i'm talking about 5.1.1 version)
As a workaround, you can set up a new Agent Event Listener so force use of username/password this way (it's an inner class in my exemple):

    private static final class AuthKnowledgeAgentEventListener extends
        DefaultKnowledgeAgentEventListener {
    private final String username;

    private final String password;

    private AuthKnowledgeAgentEventListener(String username, String password) {
        this.username = username;
        this.password = password;
    }

    @Override
    public void beforeChangeSetApplied(BeforeChangeSetAppliedEvent event) {
        // Obliged to do this to get UrlResources done correctly...
        ChangeSet changeSet = event.getChangeSet();
        for (Resource res : changeSet.getResourcesAdded()) {
            if (res instanceof UrlResource) {
                setupUrlResource((UrlResource) res);
            }
        }
        for (Resource res : changeSet.getResourcesModified()) {
            if (res instanceof UrlResource) {
                setupUrlResource((UrlResource) res);
            }
        }
                        // maybe this is needed for deleted resources, i didn't check

    }

    private void setupUrlResource(UrlResource resource) {
        if (starter.droolsAuthenticationEnabled) {
            resource.setBasicAuthentication("enabled");
            resource.setUsername(username);
            resource.setPassword(password);
        }
    }
}

and then you set this event listener to you agent:

agent.addEventListener(new AuthKnowledgeAgentEventListener("myusername","mypassword"));

And that's it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文