// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:47:17
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   BlindUsers.java

package project;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.*;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.xerces.framework.XMLParser;
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.*;
import org.xml.sax.InputSource;

// Referenced classes of package project:
//            AccederADatos, EncriptarDesencriptar

class BlindUsers
{

    BlindUsers()
    {
    }

    public static void getBlindUsers(String dni)
    {
        try
        {
            URL proxyurl = new URL(AccederADatos.leer("h.proxyAddress") + "blindUsers.jsp");
            HttpURLConnection connection = (HttpURLConnection)proxyurl.openConnection();
            connection.setRequestProperty("encriptar", AccederADatos.leer("h.encriptar"));
            connection.connect();
            DOMParser parser = new DOMParser();
            BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
            String textoEncriptado = EncriptarDesencriptar.getStringFromInputStream(bis);
            String textoDesencriptado = EncriptarDesencriptar.desencriptar(textoEncriptado);
            InputSource stream = new InputSource(EncriptarDesencriptar.getInputStreamFromString(textoDesencriptado.trim()));
            parser.parse(stream);
            doc = parser.getDocument();
            list = doc.getElementsByTagName("datos");
            connection.getInputStream().close();
            for(int i = 0; i < list.getLength(); i++)
            {
                nextQuestion = (Element)list.item(i);
                if(nextQuestion.getAttribute("dni").compareToIgnoreCase("") != 0)
                {
                    Vector result = new Vector();
                    for(StringTokenizer tokenizer = new StringTokenizer(nextQuestion.getAttribute("dni"), ";"); tokenizer.hasMoreTokens(); result.add(tokenizer.nextToken()));
                    blindUsers = (String[])(String[])result.toArray(new String[result.size()]);
                }
            }

        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

    public static boolean isBlindUser(String dni)
    {
        if(AccederADatos.entraComoDemo)
            break MISSING_BLOCK_LABEL_42;
        for(int i = 0; i < blindUsers.length;)
        {
            if(blindUsers[i].compareToIgnoreCase(dni) == 0)
                return true;
            try
            {
                i++;
            }
            catch(Exception ex)
            {
                return false;
            }
        }

        return false;
    }

    private static Element nextQuestion;
    private static Document doc;
    private static NodeList list;
    public static String blindUsers[];
}