PDA

View Full Version : ExtJs and XML schema



sachintaware
9 Dec 2011, 4:04 AM
Hello
In need of help again./:)
Well I wanted to write a authentication mechanism using ext-js and xml schema.
That is I will have a few users in an xml schema,with username and password


<?xml version="1.0" encoding="UTF-8"?>
<message success="true">
<contact>
<username>Admin</username>
<password>Some encrypted password</password>
.
.(other fields)

</contact>
</message>


What I want to implement is:
1) Have a form to add a user,which on adding saves the username and password(encrypted) to the xml files.
Encryption can be using standard base64 encoding using java.
2) use the same username password to authenticate the user.i.e if the username password matches he is allowed to enter the application else not.How to check if the username posted from form matches the one in the xml file.


Problem I am facing:
I am able to read from xml files(referred to sample examples) but how to save them to the xml? Is it possible
Can you point to some examples??

Any help would be appreciated.

Regards
Sachin

skirtle
9 Dec 2011, 4:11 AM
Unless I've misunderstood, this is not an ExtJS question.

sachintaware
9 Dec 2011, 4:23 AM
Hello skirtle
Why it isn't??Can't we do this in extjs??A login mechanism where user is authenticated.
I have a form in extjs,which will be posting values.I need to read the xml records and check if its der.
Yes->Success No->Invalid.
But,i have to add records to the Xml first using a kind of register form and save those to the xml.(in short write to xml)
I have a DB to store it but it holds critical data and I cannot tweak in tables for this in it now.
So as a work around i want xml files with encrypted pwd to hold the data for me.i am not sure encryption can be done using extjs,if yes please point me to some links or examples.

i hope i got it right and clear this time.

Regards
Sachin

skirtle
9 Dec 2011, 5:10 AM
I'm afraid this makes no sense to me at all. Almost everything you're describing (creating XML files, authenticating users) needs to be done on the server.

From an ExtJS perspective it's just a couple of form fields and an Ajax request. Your question implied that this wasn't the bit you were struggling with.

These two lines are particularly worrying:


Encryption can be using standard base64 encoding using java.


i am not sure encryption can be done using extjs

The first implies that you think base64 is a form of encryption, it isn't. The second implies that you're attempting the authentication on the client, which offers no security whatsoever.

sachintaware
9 Dec 2011, 7:51 AM
@skirtle
I was wrong there it has to be encoding and decoding using base64.Doing it as I am not using a strong database.Encryptions has to be MD5 or SHA .But thats a later part.

At first I would only like to know how can I write records to XML files as we use either json or xml in extjs.I did not find an example to add/edit records and save them to xml files.

Regards
Sachin

skirtle
9 Dec 2011, 8:05 AM
Theoretically it is possible to build the XML in ExtJS using an XML writer. However, I don't think that's the correct way to do what you're trying to do.

Writing the XML files to disk will obviously need to happen on the server. The only secure way to create the files is for them to be created on the server. If you build them in the client then you'd need to do some complex checks on the server-side to validate them, it isn't worth it.

Instead just pass the fields to the server as request parameters and build the XML files there.

sachintaware
9 Dec 2011, 8:39 AM
@skirtle
Thanks for the inputs.What I understand by your comments is,I should get the form values by doing


request.getParameter('username');


save it on the server itself in xml files.And then use them for authentication.
Am I right?
If not please correct

Regards
Sachin