Hi,

The best documentation right now is to look at existing authenticators
like XWikiLDAPAuthServiceImpl which create/update users and add/remove
users from groups.

On Tue, Feb 3, 2009 at 3:25 PM, Juergen Lorenz Simon <[email protected]> wrote:
> Hi,
>
> sorry for being thick, but I can't find any documentation at all how
> to do this in Java and I still
> need some help with this.
>
> In our authenticator I'd like to check if users coming from a certain
> angle (i can check on that
> through cookies) are in a special group. If they are not, I'd like to
> add the to this group.
>
> Furthermore this group needs to asserted of, so I need to be able to
> reliably find out if it
> does exist and if not, create it.
>
> So far I've been frustrated by failure by attempting to use the
> XWikiGroupService to achieve this.
> Also I don't seem to be able to find a clean documentation on how
> users and groups and done
> in XWikI (in java, especially). Is there such documentation?
>
> The following code, to much bewilderment, creates a USER?!
>
> public void checkPortalGroup(XWikiContext context) {
>   if (!_portalGroupChecked) {
>     try {
>        boolean groupExists = false;
>        List<String> groupList =
> context.getWiki().getGroupService(context).listAllGroups(context);
>        for (ListIterator<String> groups = groupList.listIterator();
> groups.hasNext() && !groupExists;) {
>            groupExists = groups.next().equals(PORTAL_GROUP_NAME);
>        }
>        if (!groupExists) {
>            log.info("Group "+PORTAL_GROUP_NAME+" does not exist and
> will be created.");
>            BaseCollection portalGroup =
> context.getWiki().getGroupClass(context).newObject(context);
>            portalGroup.setName(PORTAL_GROUP_NAME);
>
> context.getWiki().getHibernateStore().saveXWikiObject((BaseObject)
> portalGroup, context, true);
>        }
>     } catch (XWikiException e) {
>         log.error("Exception while locating or creating group
> "+PORTAL_GROUP_NAME+" : "+e.getMessage());
>         e.printStackTrace();
>     }
>     _portalGroupChecked=true;
>   }
> }
>
> I need some serious pointers on how the xwiki objects/classes thing is
> supposed to work
> for users/groups.
>
> Thanks a lot,
> J.L.Simon
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>



-- 
Thomas Mortagne
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to