JBPM控制台通过Java进行远程认证

编程入门 行业动态 更新时间:2024-10-04 07:18:03
本文介绍了JBPM控制台通过Java进行远程认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经在本地主机上部署了jbpm-cosole,并且创建了一个Java应用程序来为流程事务进行REST调用.所以,我的问题是.

I have deployed jbpm-cosole on my localhost, and I have created a java application to make REST calls for process transaction. So, my question is.

  • 由于jbpm-console使用spring-security,如何将身份验证请求发送到JBPM?

  • As jbpm-console uses spring-security, how to send authentication request to JBPM?

    成功进行身份验证后,我想将身份验证令牌存储为java对象,以进行进一步的事务而无需登录.

    After successful authentication I want to store authentication token as a java object to make further transactions without login.

    还是有其他方法可以做到这一点,请告诉我.

    or is there any another way to do that please let me know.

    推荐答案

    这是返回用户任务列表的示例代码.您只需要在请求标头中设置身份验证详细信息,如此代码所示.这适用于 jbpm-6.1.0.Final .

    This is a sample code which returns the tasks list of a user. You just need to set the authentication details in request header as shown in this code. This works with jbpm-6.1.0.Final.

    import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; public class JBPMRest { public static void getTaskSummaryList() throws Exception { String status = "Reserved"; String actor = "krisv"; String addr = "localhost:8080/jbpm-console/rest/task/query?status=" + status + "&potentialOwner=" + actor; try { HttpClient client = HttpClientBuilder.create().build(); HttpGet get = new HttpGet(addr); String authData = "krisv" + ":" + "krisv"; String encoded = new sun.misc.BASE64Encoder().encode(authData.getBytes()); get.setHeader("Content-Type", "application/json"); get.setHeader("Authorization", "Basic " + encoded); get.setHeader("ACCEPT", "application/xml"); HttpResponse cgResponse = client.execute(get); String content = EntityUtils.toString(cgResponse.getEntity()); System.out.println(content); } catch (Exception e) { throw new Exception("Error consuming service.", e); } } }
  • 更多推荐

    JBPM控制台通过Java进行远程认证

    本文发布于:2023-11-29 15:24:00,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1646789.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:控制台   JBPM   Java

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!