-
1. Re: Problem with jbpm-console (business-central) in BRMS server
mohreece Feb 9, 2013 12:45 PM (in response to jmiguel77)1 of 1 people found this helpfulHi 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:
{code}
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();
}
{code}
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...
-
2. Re: Problem with jbpm-console (business-central) in BRMS server
rigazilla Apr 11, 2013 10:10 AM (in response to jmiguel77)Hi Jose,
I also need to run the jbpm-console with basic authentication.
Did you find a solution to this problem?
Thanks,
Vittorio
-
3. Re: Problem with jbpm-console (business-central) in BRMS server
jmiguel77 Apr 11, 2013 11:04 AM (in response to rigazilla)Hi Vittorio
Sadly no, i had to build my solution working against the form authentication
I can help you with some code, if you need it
-
4. Re: Problem with jbpm-console (business-central) in BRMS server
rigazilla Apr 12, 2013 4:36 AM (in response to jmiguel77)Hi Jose,
we decided to go for a separated war for our rest services with basic authentication.
So basically this will be our arch:
gwt-console + server as is, with form auth
war with business rest service with basic auth
Thanks for you offer to share you code with us!
Ciao,
Vittorio