Liferay’s unauthenticated remote service

Goal

Creating a new Liferay remote service that may be invoked by unauthenticated users

Description

In a recent project, I had the need to expose most of the services of my application through WS. Security is enabled (that is the default in Liferay’s remote services) in all of the exposed methods. However, I had the requirement to make one of them invokable by unauthenticated users. This recipe explains how to achieve that.

How to

I’ll assume that you already have your service portlet modules and the corresponding service.xml as well as the entities defined within that file. In that case, all we need to do is to create the method in our ServiceImpl class and mark it with @AccessControlled(guestAccessEnabled = true), as such and execute the liferay:build-service goal (I’m using maven in this project):

@AccessControlled(guestAccessEnabled = true)
@Override
public String hello(final String name) throws SystemException, PortalException {
  return "Hello " + name;
}

Explanations

No further explanations seem necessary for this recipe.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s