Customizing Surf Platform Root-Scoped API

这一生的挚爱 提交于 2019-12-06 07:19:51

Not quite sure what you are trying to accomplish, but the role security model is hardcoded in spring-surf/spring webscripts. There is guest, user and admin. If what you want is another analogous role you'll have to hack the spring-surf libaries, namely:

org/springframework/extensions/surf/mvc/PageView.java
org/springframework/extensions/webscripts/ScriptUser.java
org/springframework/extensions/webscripts/Description.java
org/springframework/extensions/webscripts/connector/User.java

This is what I had to do to implement user.isEmployee. This approach allows you to literally treat your new role just as the others.

you can use

<authentication>employee</authentication>

in page descriptors or

<item type="link" permission="employee" id="people">/people-finder</item>

on the navigation.

Just checking whether the user is in a certain group in a certain webscript is a whole diffrent story and does not provide the same functionality.

If what you want is the latter, you should make a call to

/alfresco/service/api/groups/{shortName}

miss and works through the response.

Update: The item permission attribute requires a little more tweaking. In header.get.js, propagate the new role to it gets processed properly in header.inc.ftl:

model.permissions =
{
    guest: user.isGuest,
    admin: user.isAdmin,
    employee : user.isEmployee
};

you could try (in JavaScript I managed something like) this:

user = Application.getCurrentUser(context);
       String userName = user.getUserName();
       user.isAdmin() >>> result return true if user logining is admin

or in JSP:

#{NavigationBean.currentUser.admin == true}

Sorry, i noticed now you was talking about Surf Platform root objects, but the link you put there, is deprecated for Alfresco versions above 3.3. You still use something so old? If you manage to use JavaScript API's you could use "person" root object, with boolean isAdmin().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!