Fórumok

jsonws api PrincipalException

thumbnail
Troy Griffitts, módosítva 9 év-val korábban

jsonws api PrincipalException

New Member Bejegyzések: 18 Csatlakozás dátuma: 2011.08.06. Legújabb bejegyzések
Hey guys,

We have an app running on Liferay 6.1, but we're having trouble migrating it to 6.2.

It seems we can no longer access the jsonws api. I've googled everywhere and looked through the docs. I must be missing something basic here. Maybe a flag to turn the feature on.

Here is the strange thing. I can access Liferay's jsonws browser at: /api/jsonws/
I can drill down to the call I want and try to submit it, but I always get:

{"exception":"com.liferay.portal.security.auth.PrincipalException"}

On the curl example tab from the jsonws browser, I can use that command to try to issue the request and it also returns the same:

{"exception":"com.liferay.portal.security.auth.PrincipalException"}

Here is an example request which fails:

curl http://mysite.com/api/jsonws/role/has-user-role -u admin@liferay.com:adminpasswd -d userId=1234 -d companyId=4567 -d name='Administrator' -d inherited=true

I know I'm getting logged in correctly, for if I don't pass a correct admin user and password, I get:

{"exception":"Authenticated access required"}

Any help would be greatly appreciated.

Troy
thumbnail
David H Nebinger, módosítva 9 év-val korábban

RE: jsonws api PrincipalException (Válasz)

Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Out of curiosity, are you on localhost when you do this, or have you updated portal-ext.properties:

##
## Axis Servlet
##

#
# See the properties "main.servlet.hosts.allowed" and
# "main.servlet.https.required" on how to protect this servlet.
#
axis.servlet.hosts.allowed=127.0.0.1,SERVER_IP
thumbnail
Troy Griffitts, módosítva 9 év-val korábban

RE: jsonws api PrincipalException

New Member Bejegyzések: 18 Csatlakozás dátuma: 2011.08.06. Legújabb bejegyzések
My apologies for not responding sooner. This was exactly the answer that I needed.

When moving from Liferay 6.1 to 6.2, it seems all jsonws services are locked down by default and cannot be called, unless this entry is included in the portal-ext.properties file:

axis.servlet.hosts.allowed=127.0.0.1

Thanks to everyone who responded and thank you to David for the answer that helped me get things running.

Again, my apologies for not returning to send my thanks earlier.

Troy
thumbnail
Tomas Polesovsky, módosítva 9 év-val korábban

RE: jsonws api PrincipalException

Liferay Master Bejegyzések: 676 Csatlakozás dátuma: 2009.02.13. Legújabb bejegyzések
Hi Troy,

are you sure the provided userId is correct?

When you provide wrong userId then permission check fails on the userId => the PrincipalException

Do you have any logs?

Thanks.
thumbnail
Barrie Selack, módosítva 9 év-val korábban

RE: jsonws api PrincipalException

New Member Bejegyzések: 3 Csatlakozás dátuma: 2010.10.04. Legújabb bejegyzések
Troy,

It seems I recall (it's been a while) that maybe the URL should be

http://mysite.com/api/secure/jsonws/role/has-user-role

adding the secure to it.

Just a thought
Barrie