automatically adding <user .../> elements to tomcat-users.xml

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

automatically adding <user .../> elements to tomcat-users.xml

Vlad
Hi,
I tried to create an authentication system for an application like this :

- I complete the data (a user profile) in XForms
- I submit it to a pipeline which writes it to eXist and then to tomcat-users.xml (so the new user will automatically have access to the web application)

...and I almost made it ; I applied the xml-converter processor to the data (which is :  aggregate('tomcat-users' , #users#xpointer(/tomcat-users/*) , #new_user) )

The element that #new_user points to is something like this:

<user username="xxxxx" password="xxxxxxx" roles="role"/>

BUT the problem is that I have to set <append>false</append> in the config input of file-serializer and I get the following error :

Can't delete file: C:\xampp\tomcat\conf\tomcat-users.xml


If I use <append>false</append> everything works fine (no errors) , but the XML in tomcat-users becomes syntactically incorrect , that's not what I need.


Is there a way to simple add an element to a XML file (in a specified part of its structure , like with XPointer) ? (I would insert the new <user> element under <tomcat-users>)


On the other hand , if this is not possible (and however I know it's not recommended to write to a configuration file like tomcat-users) , what kind of programming logic would you recommend me for the authentication system ?  would it be OK to use digest() to hash the password and store it in eXist , then authenticate against the database ?
Reply | Threaded
Open this post in threaded view
|

Re: automatically adding <user .../> elements to tomcat-users.xml

Vlad
I made it , I got rid of the "Can't delete file: C:\xampp\tomcat\conf\tomcat-users.xml" error.
It was a permissions issue.

However , the problem remains open and any answer on the other questions is welcome.

Thanks.