[GeoNetwork-devel] Integrating Geonetwork with External application

Hello,

We have an external application which lists metadata as hyper links and when the user clicks a metadata link it should open the geonetwork metadata edit page

I tried a sample code to test this approach and always get You may not have the privileges to do this operation.ServiceNotAllowedEx : Service not allowed.

I am passing the admin/admin as default username and password to the below code.

//Geonetwork Login code

……

Cookie loginCookie = httpClient.getState().getCookies()[0];

String cookieName = loginCookie.getName();

String cookieValue = loginCookie.getValue();

System.out.println("cookieName : "+cookieName);

System.out.println("cookieValue : "+cookieValue);

// encode user name and password

// set default authenticator

//javax.servlet.http.Cookie gnCookie = new javax.servlet.http.Cookie(cookieName, cookieValue);

response.addHeader(“Accept”, “text/plain,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”);

response.addHeader(“Content-Type”, “application/x-www-form-urlencoded”);

response.addHeader(“Connection”, “Keep-Alive”);

response.addHeader(“Keep-Alive”, “300”);

response.addHeader(“Cookie”, cookieValue);

//response.addCookie(gnCookie);

response.sendRedirect(“http://localhost:8081/geonetwork/srv/en/metadata.edit?id=1”);

For example after Login the following is printed

cookieName : JSESSIONID

cookieValue : 88F9E1ECB7F6BAADC6CF429DCE01A9EF

and when the http://localhost:8081/geonetwork/srv/en/metadata.edit?id=1 is been called I note a different session Id printed in Jeeves Log. Why is that the session id being passed being not considered?

Any inputs on this will be really helpful.

Geonetwork Log

2012-01-30 16:16:31,202 INFO [jeeves.request] - ==========================================================

2012-01-30 16:16:31,202 INFO [jeeves.request] - HTML Request (from 127.0.0.1) : /geonetwork/srv/en/xml.user.login

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Method : POST

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Content type : application/xml; charset=UTF8

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Accept : null

2012-01-30 16:16:31,374 DEBUG [jeeves.request] - Session id is 88F9E1ECB7F6BAADC6CF429DCE01A9EF

2012-01-30 16:16:31,374 DEBUG [jeeves.request] - Session created for client : 127.0.0.1

2012-01-30 16:16:31,390 INFO [jeeves.service] - Dispatching : xml.user.login

2012-01-30 16:16:31,390 DEBUG [jeeves.service] - → parameters are :

admin

admin

2012-01-30 16:16:31,421 INFO [jeeves.webapp.xml.user.login] - User ‘admin’ logged in using an old scrambled password.

2012-01-30 16:16:31,421 INFO [jeeves.webapp.xml.user.login] - User ‘admin’ logged in as ‘Administrator’

2012-01-30 16:16:31,421 INFO [jeeves.service] - → dispatching to output for : xml.user.login

2012-01-30 16:16:31,421 INFO [jeeves.service] - → writing xml for : xml.user.login

2012-01-30 16:16:31,421 DEBUG [jeeves.service] - Service xml is :

2012-01-30 16:16:31,421 INFO [jeeves.service] - → output ended for : xml.user.login

2012-01-30 16:16:31,421 INFO [jeeves.service] - → dispatch ended for : xml.user.login

cookieName : JSESSIONID

cookieValue : 88F9E1ECB7F6BAADC6CF429DCE01A9EF

2012-01-30 16:16:31,468 INFO [jeeves.request] - ==========================================================

2012-01-30 16:16:31,468 INFO [jeeves.request] - HTML Request (from 127.0.0.1) : /geonetwork/srv/en/metadata.edit

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Method : GET

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Content type : null

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Accept : text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

2012-01-30 16:16:31,484 DEBUG [jeeves.request] - Session id is 423DFC79E1A4B490D571CFD13BD245C1

2012-01-30 16:16:31,484 DEBUG [jeeves.request] - Session created for client : 127.0.0.1

2012-01-30 16:16:31,515 INFO [jeeves.service] - Dispatching : metadata.edit

2012-01-30 16:16:31,515 DEBUG [jeeves.service] - → parameters are :

1

2012-01-30 16:16:31,515 ERROR [jeeves.service] - Service not allowed : metadata.edit

2012-01-30 16:16:31,515 DEBUG [jeeves.service] - Raised exception while executing service

Service not allowed

ServiceNotAllowedEx

Regards

Kumaran

I would look into httpclient’s cookie handling. It does an acceptable job, you shouldn’t have to add the header explicitely.

Also are there proxies in the way?
Jesse

On Mon, Jan 30, 2012 at 11:55 AM, Kumaran Narayanaswamy <kumaran.narayanaswamy@…745…> wrote:

Hello,

We have an external application which lists metadata as hyper links and when the user clicks a metadata link it should open the geonetwork metadata edit page

I tried a sample code to test this approach and always get You may not have the privileges to do this operation.ServiceNotAllowedEx : Service not allowed.

I am passing the admin/admin as default username and password to the below code.

//Geonetwork Login code

……

Cookie loginCookie = httpClient.getState().getCookies()[0];

String cookieName = loginCookie.getName();

String cookieValue = loginCookie.getValue();

System.out.println("cookieName : "+cookieName);

System.out.println("cookieValue : "+cookieValue);

// encode user name and password

// set default authenticator

//javax.servlet.http.Cookie gnCookie = new javax.servlet.http.Cookie(cookieName, cookieValue);

response.addHeader(“Accept”, “text/plain,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”);

response.addHeader(“Content-Type”, “application/x-www-form-urlencoded”);

response.addHeader(“Connection”, “Keep-Alive”);

response.addHeader(“Keep-Alive”, “300”);

response.addHeader(“Cookie”, cookieValue);

//response.addCookie(gnCookie);

response.sendRedirect(“http://localhost:8081/geonetwork/srv/en/metadata.edit?id=1”);

For example after Login the following is printed

cookieName : JSESSIONID

cookieValue : 88F9E1ECB7F6BAADC6CF429DCE01A9EF

and when the http://localhost:8081/geonetwork/srv/en/metadata.edit?id=1 is been called I note a different session Id printed in Jeeves Log. Why is that the session id being passed being not considered?

Any inputs on this will be really helpful.

Geonetwork Log

2012-01-30 16:16:31,202 INFO [jeeves.request] - ==========================================================

2012-01-30 16:16:31,202 INFO [jeeves.request] - HTML Request (from 127.0.0.1) : /geonetwork/srv/en/xml.user.login

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Method : POST

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Content type : application/xml; charset=UTF8

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Accept : null

2012-01-30 16:16:31,374 DEBUG [jeeves.request] - Session id is 88F9E1ECB7F6BAADC6CF429DCE01A9EF

2012-01-30 16:16:31,374 DEBUG [jeeves.request] - Session created for client : 127.0.0.1

2012-01-30 16:16:31,390 INFO [jeeves.service] - Dispatching : xml.user.login

2012-01-30 16:16:31,390 DEBUG [jeeves.service] - → parameters are :

admin

admin

2012-01-30 16:16:31,421 INFO [jeeves.webapp.xml.user.login] - User ‘admin’ logged in using an old scrambled password.

2012-01-30 16:16:31,421 INFO [jeeves.webapp.xml.user.login] - User ‘admin’ logged in as ‘Administrator’

2012-01-30 16:16:31,421 INFO [jeeves.service] - → dispatching to output for : xml.user.login

2012-01-30 16:16:31,421 INFO [jeeves.service] - → writing xml for : xml.user.login

2012-01-30 16:16:31,421 DEBUG [jeeves.service] - Service xml is :

2012-01-30 16:16:31,421 INFO [jeeves.service] - → output ended for : xml.user.login

2012-01-30 16:16:31,421 INFO [jeeves.service] - → dispatch ended for : xml.user.login

cookieName : JSESSIONID

cookieValue : 88F9E1ECB7F6BAADC6CF429DCE01A9EF

2012-01-30 16:16:31,468 INFO [jeeves.request] - ==========================================================

2012-01-30 16:16:31,468 INFO [jeeves.request] - HTML Request (from 127.0.0.1) : /geonetwork/srv/en/metadata.edit

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Method : GET

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Content type : null

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Accept : text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

2012-01-30 16:16:31,484 DEBUG [jeeves.request] - Session id is 423DFC79E1A4B490D571CFD13BD245C1

2012-01-30 16:16:31,484 DEBUG [jeeves.request] - Session created for client : 127.0.0.1

2012-01-30 16:16:31,515 INFO [jeeves.service] - Dispatching : metadata.edit

2012-01-30 16:16:31,515 DEBUG [jeeves.service] - → parameters are :

1

2012-01-30 16:16:31,515 ERROR [jeeves.service] - Service not allowed : metadata.edit

2012-01-30 16:16:31,515 DEBUG [jeeves.service] - Raised exception while executing service

Service not allowed

ServiceNotAllowedEx

Regards

Kumaran


Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

Jesse,

The idea is to forward the response to the browser and open it as a web page. With HttpClient we are able to access the url and the response is returned as html content, but rather than returning the response we want the response to be forwarded to a web browser as if the user accesses the url in web browser

There are no proxies. Thanks.

Regards

Kumaran

From: Jesse Eichar [mailto:jesse.eichar@anonymised.com]
Sent: Monday, January 30, 2012 4:35 PM
To: Kumaran Narayanaswamy
Cc: geonetwork-devel@lists.sourceforge.net
Subject: Re: [GeoNetwork-devel] Integrating Geonetwork with External application

I would look into httpclient’s cookie handling. It does an acceptable job, you shouldn’t have to add the header explicitely.

Also are there proxies in the way?
Jesse

On Mon, Jan 30, 2012 at 11:55 AM, Kumaran Narayanaswamy <kumaran.narayanaswamy@anonymised.com> wrote:

Hello,

We have an external application which lists metadata as hyper links and when the user clicks a metadata link it should open the geonetwork metadata edit page

I tried a sample code to test this approach and always get You may not have the privileges to do this operation.ServiceNotAllowedEx : Service not allowed.

I am passing the admin/admin as default username and password to the below code.

//Geonetwork Login code

……

Cookie loginCookie = httpClient.getState().getCookies()[0];

String cookieName = loginCookie.getName();

String cookieValue = loginCookie.getValue();

System.out.println("cookieName : "+cookieName);

System.out.println("cookieValue : "+cookieValue);

// encode user name and password

// set default authenticator

//javax.servlet.http.Cookie gnCookie = new javax.servlet.http.Cookie(cookieName, cookieValue);

response.addHeader(“Accept”, “text/plain,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”);

response.addHeader(“Content-Type”, “application/x-www-form-urlencoded”);

response.addHeader(“Connection”, “Keep-Alive”);

response.addHeader(“Keep-Alive”, “300”);

response.addHeader(“Cookie”, cookieValue);

//response.addCookie(gnCookie);

response.sendRedirect(“http://localhost:8081/geonetwork/srv/en/metadata.edit?id=1”);

For example after Login the following is printed

cookieName : JSESSIONID

cookieValue : 88F9E1ECB7F6BAADC6CF429DCE01A9EF

and when the http://localhost:8081/geonetwork/srv/en/metadata.edit?id=1 is been called I note a different session Id printed in Jeeves Log. Why is that the session id being passed being not considered?

Any inputs on this will be really helpful.

Geonetwork Log

2012-01-30 16:16:31,202 INFO [jeeves.request] - ==========================================================

2012-01-30 16:16:31,202 INFO [jeeves.request] - HTML Request (from 127.0.0.1) : /geonetwork/srv/en/xml.user.login

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Method : POST

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Content type : application/xml; charset=UTF8

2012-01-30 16:16:31,202 DEBUG [jeeves.request] - Accept : null

2012-01-30 16:16:31,374 DEBUG [jeeves.request] - Session id is 88F9E1ECB7F6BAADC6CF429DCE01A9EF

2012-01-30 16:16:31,374 DEBUG [jeeves.request] - Session created for client : 127.0.0.1

2012-01-30 16:16:31,390 INFO [jeeves.service] - Dispatching : xml.user.login

2012-01-30 16:16:31,390 DEBUG [jeeves.service] - → parameters are :

admin

admin

2012-01-30 16:16:31,421 INFO [jeeves.webapp.xml.user.login] - User ‘admin’ logged in using an old scrambled password.

2012-01-30 16:16:31,421 INFO [jeeves.webapp.xml.user.login] - User ‘admin’ logged in as ‘Administrator’

2012-01-30 16:16:31,421 INFO [jeeves.service] - → dispatching to output for : xml.user.login

2012-01-30 16:16:31,421 INFO [jeeves.service] - → writing xml for : xml.user.login

2012-01-30 16:16:31,421 DEBUG [jeeves.service] - Service xml is :

2012-01-30 16:16:31,421 INFO [jeeves.service] - → output ended for : xml.user.login

2012-01-30 16:16:31,421 INFO [jeeves.service] - → dispatch ended for : xml.user.login

cookieName : JSESSIONID

cookieValue : 88F9E1ECB7F6BAADC6CF429DCE01A9EF

2012-01-30 16:16:31,468 INFO [jeeves.request] - ==========================================================

2012-01-30 16:16:31,468 INFO [jeeves.request] - HTML Request (from 127.0.0.1) : /geonetwork/srv/en/metadata.edit

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Method : GET

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Content type : null

2012-01-30 16:16:31,468 DEBUG [jeeves.request] - Accept : text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

2012-01-30 16:16:31,484 DEBUG [jeeves.request] - Session id is 423DFC79E1A4B490D571CFD13BD245C1

2012-01-30 16:16:31,484 DEBUG [jeeves.request] - Session created for client : 127.0.0.1

2012-01-30 16:16:31,515 INFO [jeeves.service] - Dispatching : metadata.edit

2012-01-30 16:16:31,515 DEBUG [jeeves.service] - → parameters are :

1

2012-01-30 16:16:31,515 ERROR [jeeves.service] - Service not allowed : metadata.edit

2012-01-30 16:16:31,515 DEBUG [jeeves.service] - Raised exception while executing service

Service not allowed

ServiceNotAllowedEx

Regards

Kumaran


Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2


GeoNetwork-devel mailing list
GeoNetwork-devel@anonymised.comsourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork