0

I started working on a project where I need to read and parse an xml file from a url. This url needs a credentials to successfully read the data from it, so I'm thinking while reading the file there will be a modal window that will accept a username and password to authenticate the source.

This url is from the outside source and needed a credential to authenticate the connection for us to successfully connect and read the xml file. Also this is only available privately on request.

My concern is how could I prevent a user to see the credential being passed in the modal form then processed it in the background? It's like instead of getting the actual password I'm thinking like hash it? But by doing that the authentication would fail? Any suggestion if there is a better approach for this?

  • 1
    Do you need the credentials of the current user using the application or are they a single set of credentials that you received from the owner of the URL? Also, who do you want to prevent from seeing the credentials, the user entering them or someone else? – Bart van Ingen Schenau Jan 18 '16 at 11:39
  • 1
    Since the user has already logged-in to the system with valid credentials, then why do we need to perform authentication again ? Please share, if this URL is shared publicly or available only privately on request ? And how are you pulling the XML file before starting its parsing.. Is it via some kind of web service or via a URL only as stated in the question. Please add some more info. – Karan Jan 18 '16 at 11:42
  • already updated my question. – rpm07 Jan 18 '16 at 11:50
1

if you are open to a different option: you could try having a response/request pattern, where you[the request] calls a service[the response] and pass a network credential object [built into .net] then upon successful authentication pass back the xml though the service call

public XElement GetXml(IProviderInformation input)
{
    using (var svc = new Service())
    {
        svc.PreAuthenticate = true;
        svc.UseDefaultCredentials = false;
        svc.Credentials = new NetworkCredential
        {
            UserName = input.ProviderAccountInfo.AccountUserName,
            Password = input.ProviderAccountInfo.AccountPassword
        };

        var rslt = svc.GetXmlFromService();
        var result = XElement.Parse(rslt);
        return result;
    }
}
  • do you have a reference I can use for building it in .NET? – rpm07 Jan 27 '16 at 16:06
  • what are these Service() and IProviderInformation? – rpm07 Feb 9 '16 at 8:26
  • Service is the service that you setup WCF example and IProviderInfo is just some data transfer objet that you pass in the the password / username / or other data you need – user3333735 Feb 9 '16 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.