add user with Struts

Jean-Damien Bouvier <[email protected]>
Newsgroups gmane.comp.jakarta.slide.user
Message-ID <OF867E961C.81FE3E8D-ONC1257267.004ECFF3-C1257267.004FBA04@hardis.fr>
Hi !

I wish to create a new user trough a sample Form with Struts. I've got a 
text field for the new user name and then I call the Slide API.

Here is my code AddUserAction : 

    public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws Exception 
{
        String username = ((demo.AddUserForm)form).getUsername();
 
        // prepare the namespace access token (assuming you want the 
default namespace)
        String namespace = Domain.getDefaultNamespace();
 
        SlideToken st = WebdavUtils.getSlideToken(request);
 
        if(!"".equals(username)) {
                NamespaceAccessToken nat = Domain.accessNamespace(new 
SecurityToken(this), namespace);
                // prepare the structure helper
                Structure structureHelper = nat.getStructureHelper();

                try {
                        try {
                                // start namespace tansaction
                                nat.begin();
                                // retrieve the node to be linked
                                SubjectNode user = new SubjectNode(
USERS_REPOSITORY + username);
 
                                structureHelper.create(st, user, 
USERS_REPOSITORY + username);
                                // commit the transaction
                                nat.commit();
                        } catch (AccessDeniedException ex) {
                                ex.printStackTrace();
                                throw ex;
                        } catch (ObjectAlreadyExistsException ex) {
                                ex.printStackTrace();
                                throw ex;
                        } catch (Exception ex) {
                                ex.printStackTrace();
                                throw ex;
                        }
                        // ... SUCCESS ...
                } catch (Exception ex) {
                        try {
                                nat.rollback();
                        } catch (SystemException sysex) { // catch 
silently }

                        }
                }
        }

 
      return mapping.findForward(FORWARD_addUser);
    }

But the security check fails (I've added some logs in LTISecurityImpl that 
inherits from ACLSecurityImpl) :

Check credentials on /users by /users/root for action /actions/bind
Check credentials on /users by /users/root for action /actions/write  (--> 
this is to store the parent object)
Check credentials on /users/johnny by /users/root for action 
/actions/write
org.apache.slide.security.AccessDeniedException: Access denied on 
/users/johnny by user /users/root for action /actions/write
        at org.apache.slide.security.SecurityImpl.checkCredentials(
SecurityImpl.java:427)
        at fr.lti.magic.LTISecurityImpl.checkCredentials(
LTISecurityImpl.java:21)
        at org.apache.slide.structure.StructureImpl.store(
StructureImpl.java:488)
        at org.apache.slide.structure.StructureImpl.store(
StructureImpl.java:458)
        at org.apache.slide.structure.StructureImpl.create(
StructureImpl.java:380)
        at demo.AddUserAction.createUser(AddUserAction.java:80)

From what I understand, the parent object is first stored (here /users) to 
reflect the new added child and then the child is stored. But to store the 
child (here /users/jonnhy), Slide first checks if root has write access on 
/users/johnny ! There is obviously something wrong, but I don't get it.

Thanks for your help !
Jean-Damien Bouvier
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.