Maurice de Chateau [https://community.jboss.org/people/MohReece] created the 
discussion

"Re: Problem with jbpm-console (business-central) in BRMS server"

To view the discussion, visit: https://community.jboss.org/message/796892#796892

--------------------------------------------------------------
Hi Jose,

Maybe not the answer to the question you're asking, but it may be one that 
addresses your problem: you can access the Business Central REST API, but it's 
a little 'tricky' to getting around the form authentication to get there.

When you first access the API with e.g. the Apache DefaultHttpClient, the 
response will contain the HTML containing the form. Upon that response, you 
need to POST the credentials:


        final DefaultHttpClient httpClient = new DefaultHttpClient();
        final String url = BUSINESS_CENTRAL_REST_BASE_URL + RESOURCE_PATH + 
"/j_security_check";

        final List<NameValuePair> formParms = new ArrayList<NameValuePair>();
        formParms.add(new BasicNameValuePair("j_username", 
BUSINESS_CENTRAL_USER_NAME));
        formParms.add(new BasicNameValuePair("j_password", 
BUSINESS_CENTRAL_PASSWORD));

        String responseString = null;
        try {
            final HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(new UrlEncodedFormEntity(formParms, "UTF-8"));

            final HttpResponse response = httpClient.execute(httpPost);
            responseString = EntityUtils.toString(response.getEntity());
            EntityUtils.consume(response.getEntity());
        } catch (final Exception e) {
            e.printStackTrace();
        }



When this returns with an HTTP 200 response you can retry your original request 
- which should succeed.

Basically, this is the same scenario that a browser goes through in the case of 
form authentication. Now one can certainly argue that this kind of 
authentication doesn't belong on a (true) REST interface, as it relies on 
server state (you only log in once per session, and the server remembers your 
credentials for that session) which goes against REST's principle of 
stateless-ness. But I guess for now we just have to make do with the 
implementation the Business Central server is providing us...
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/796892#796892]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to