Weblogic Integration中获取WorklistContext并查询任务

发布于 2024-10-03 08:23:57 字数 1227 浏览 4 评论 0原文

为了获取 Weblogic 初始上下文来查询任务数据库,我执行以下操作:

Properties h = new Properties();
h.put(Context.SECURITY_PRINCIPAL, "weblogic");
h.put(Context.PROVIDER_URL, "t3://localhost:17101");
h.put(Context.SECURITY_CREDENTIALS, "weblogic");
h.put(Context.SECURITY_AUTHENTICATION, "simple");
WLInitialContextFactory test = new WLInitialContextFactory();
test.getInitialContext(h);

Context ctx = null;
ctx = getInitialContext();
WorklistContext wliContext = WorklistContextFactory.getRemoteWorklistContext(ctx, "MyTaskApplication");

然后使用以下代码获取 TaskQuery 接口:

WorklistTaskQuery taskQuery = wliContext.getInterfaceForTaskQuery();

并获取我执行的任务:

taskQuery.getTasks(query);

其中查询是 com.bea.wli.worklist.api .TaskQuery 对象。

请注意,此代码在运行任务的域内运行。

不幸的是,当我调用 getTasks 方法时,我收到以下错误:

java.lang.SecurityException: [WLI-Worklist:493103]Access denied to resource /taskplans
/Manual:1.0. Applicable policy: Query Caller: principals=[] Method: com.bea.wli.worklist.security.WorklistSecurityManager.assertTaskAccessAllowed

看来 Weblogic 忽略了新初始上下文上设置的用户并尝试使用来自浏览器的用户。碰巧我可能需要在没有浏览器会话的后台工作人员中进行查询搜索(显然)。

谁能帮忙解决这个问题吗?

In order to get the Weblogic initial context to query the task database i am doing the following:

Properties h = new Properties();
h.put(Context.SECURITY_PRINCIPAL, "weblogic");
h.put(Context.PROVIDER_URL, "t3://localhost:17101");
h.put(Context.SECURITY_CREDENTIALS, "weblogic");
h.put(Context.SECURITY_AUTHENTICATION, "simple");
WLInitialContextFactory test = new WLInitialContextFactory();
test.getInitialContext(h);

Context ctx = null;
ctx = getInitialContext();
WorklistContext wliContext = WorklistContextFactory.getRemoteWorklistContext(ctx, "MyTaskApplication");

I then get the TaskQuery interface with the following code:

WorklistTaskQuery taskQuery = wliContext.getInterfaceForTaskQuery();

and to get the tasks i do:

taskQuery.getTasks(query);

where query is com.bea.wli.worklist.api.TaskQuery object.

Please note that this code is running inside the domain running the tasks.

Unfortunally i am getting the following error when i call the getTasks methods:

java.lang.SecurityException: [WLI-Worklist:493103]Access denied to resource /taskplans
/Manual:1.0. Applicable policy: Query Caller: principals=[] Method: com.bea.wli.worklist.security.WorklistSecurityManager.assertTaskAccessAllowed

It seems Weblogic is ignoring the user set on the new initial context and trying to use the one coming from the browser. It so happens that i might need to do query searchs in background workers that don't have a browser session(obviously).

Can anyone help with this?

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

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

发布评论

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

评论(1

妄想挽回 2024-10-10 08:23:57

我已经找到了解决方案,尽管它非常复杂且丑陋。

由于我是通过 EJB 进行这些调用,因此我可以通过从经过身份验证的上下文中获取 EJB 实现来对调用进行身份验证,如下所示:

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.SECURITY_PRINCIPAL,"user");
env.put(Context.PROVIDER_URL,"t3://localhost:7001");
env.put(Context.SECURITY_CREDENTIALS,"password");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
getSessionInterface(interfaceClass, new InitialContext(env));

为此,最好的选择是避免使用上面的示例和此 API。只需使用允许身份验证的常规 MBean 实现即可。

更新这个解决方案似乎并不可行,它会搞砸事务管理。将报告回来,但似乎如果您需要在经过身份验证的上下文之外创建任务,您将需要采用 MBean 方式

I've found a solution for this, though it's convoluted and ugly as hell.

Since i'm making these calls through an EJB i can authenticate the call by grabbing the EJB implementation from an authenticated context like so:

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.SECURITY_PRINCIPAL,"user");
env.put(Context.PROVIDER_URL,"t3://localhost:7001");
env.put(Context.SECURITY_CREDENTIALS,"password");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
getSessionInterface(interfaceClass, new InitialContext(env));

Your best bet for this is to avoid the above example and this API all together. Just use the regular MBean Implementation which allows authentication.

Update this solution doesn't seem to be viable, it will screw up the transaction management. Will report back, but it seems if you need to create tasks outside of an authenticated context you will need to go the MBean way

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