简体   繁体   English

Weblogic集成中获取WorklistContext和查询任务

[英]Obtaining WorklistContext and Querying Tasks in Weblogic Integration

In order to get the Weblogic initial context to query the task database i am doing the following: 为了获得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");

I then get the TaskQuery interface with the following code: 然后,使用以下代码获取TaskQuery接口:

WorklistTaskQuery taskQuery = wliContext.getInterfaceForTaskQuery();

and to get the tasks i do: 并得到我做的任务:

taskQuery.getTasks(query);

where query is com.bea.wli.worklist.api.TaskQuery object. 查询是com.bea.wli.worklist.api.TaskQuery对象。

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: 不幸的是,调用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

It seems Weblogic is ignoring the user set on the new initial context and trying to use the one coming from the browser. Weblogic似乎忽略了在新的初始上下文中设置的用户,并尝试使用来自浏览器的用户。 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? 有人能帮忙吗?

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: 由于我通过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));

Your best bet for this is to avoid the above example and this API all together. 最好的选择是避免上面的示例和此API。 Just use the regular MBean Implementation which allows authentication. 只需使用允许身份验证的常规MBean实现即可。

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 将会报告,但是似乎如果您需要在经过身份验证的上下文之外创建任务,则需要采用MBean方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM