Hi All,
What I'm trying to get is:
User logs into XWiki through CAS Auth, I also have a webservice to get remote user
credentials (where a User can be in many Groups), and some rights over that groups (only
membership), so what I want is to:
- Create a Space for each remote "Group" (named "remoteGroupSpaceX"),
- Create a Group in XWiki (named "remoteGroupX")
- Assign "edit" right to the "remoteGroupX" over
"remoteGroupSpaceX".
I already have created the Space (/xwiki/bin/view/remoteGroupSpace/), the Group
(XWiki.remoteGroupX) and what I'm trying to get is the XWikiRights from the
remoteGroup, but I can't find where can I get the XWikiRights object.
I tried to duplicate (through XWikiDocument.duplicate(EntityReference) method) an existing
group (XWikiAdminGroup) and search where is the XWikiRight object, and then change the
"levels" field to "edit", and saving the remoteGroup with the modified
rights, but the Edit button is still there.
Here's a sample of my code:
private void assignRights(String spaceName, String groupName, String rights, XWikiContext
context) throws XWikiException {
// Prepare EntityReferences
WikiReference wikiRef = new WikiReference("XWiki");
SpaceReference xwikiSpaceRef = new SpaceReference("XWiki", wikiRef);
SpaceReference remoteSpaceRef = new SpaceReference(spaceName, wikiRef);
DocumentReference refGroup = new DocumentReference(new EntityReference(groupName,
EntityType.DOCUMENT, xwikiSpaceRef));
DocumentReference refRights = new DocumentReference(new
EntityReference("XWikiRights", EntityType.DOCUMENT, remoteSpaceRef));
// Get the XWikiDocument relative to the Group
XWikiDocument docGroup = context.getWiki().getDocument(refGroup, context);
// Get the XWikiRights from the Group
BaseObject groupRights = docGroup.getXObject(refRights);
// Modify rights
groupRights.set("levels", rights, context);
context.getWiki().saveDocument(docGroup, context);
}
Where:
String spaceName = "remoteGroupSpaceX";
String groupName = "remoteGroupX";
String rights = "edit";
I know about relation between XWikiGlobalRights and XWikiRights and also about rights
priority (Page > Space > Wiki / page.XWikiRights > space.XWikiRights >
wiki.XWikiGlobalRights).
So my plan is:
Everybody has "view" (XWiki.XWikiAllUsers) right in the whole wiki, and only
members of each "remoteGroupX" has "edit" right over their own space
"remoteGroupSpaceX".
I'm a little bit lost with this and I hope any help.
Thank you,
Marco A. Gonzalez