<%-- 
    Document   : result
    Created on : Jun 15, 2016, 6:33:04 PM
    Author     : java4
--%>
  <%@page import="java.util.ArrayList"%>
<%@page import="Dna.Sources.decryption"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.sql.*"%>
<%@page import="Dna.Sources.Dbconnection"%>
<%@ page session="true" %>

  <%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.sql.*"%>
<%@page import="Dna.Sources.Dbconnection"%>
<%@ page session="true" %>
             
  <%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.sql.*"%>
<%@page import="Dna.Sources.Dbconnection"%>
<%@ page session="true" %>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>SECURING AGGREGATE</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
       
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" href="css/bootstrap-responsive.css">
        <link rel="stylesheet" href="css/custom-styles.css">
        <link rel="stylesheet" href="css/font-awesome.css">
        <link rel="stylesheet" href="css/component.css">
        <link rel="stylesheet" href="css/font-awesome-ie7.css">
        
        
        <script src="js/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    </head>
    
      <%
if(request.getParameter("msg")!=null){%>
    
    <script>alert('Privatekey Sucessfully Generated...!')</script>
}  

<%}
if(request.getParameter("g")!=null){%>

<script>alert('Privatekey Already Generated..!')</script>
 <%
}
%>
      <%
if(request.getParameter("m")!=null){%>
    
    <script>alert('Request Sent to Cloud1...!')</script>
}  

<%}
if(request.getParameter("c")!=null){%>

<script>alert('Request Already Sent..!')</script>
 <%
}
%>
    <body>
        <!--[if lt IE 7]>
            <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
        <![endif]-->

        <!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html -->

        <!-- Site header starts here -->

            


             <!-- main content starts here -->

            <div class="container b-radius-top">
                <div class="top-bar b-radius">
                   
                    <div class="social">
                        <ul>
                           
                        </ul>
                    </div>
                </div>
                <div class="site-header">


                     <!-- Site Name starts here -->

                    <div class="site-name">
                        <h1>SECURING AGGREGATE QUERIES FOR DNA DATABASES</h1>
                    
                    </div>

                    <!-- Site Name ends -->

                     <!-- Menu starts here -->
                    <div class="menu">
                        <div class="navbar">
                            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                               <i class="fw-icon-th-list"></i>
                            </a>
                            <div class="nav-collapse collapse">
                                <ul class="nav">
                                   <li><a href="userhome.jsp">Home</a></li>
                                    
            
                                      <li><a href="userviewfiles.jsp">DNA Files</a></li> 
                                    <li class="active"><a href="download.jsp">View Data</a></li>  
                                    
                                    
                                    <li><a href="user.jsp">logout</a></li>
                                </ul>
                             
                            </div>
                        </div>
                    </div>

                    <!-- Menu ends -->
                </div><br><br>
	         <!--<img src="img/admin2.jpg" style="height: 400px; width: 920px" alt="">-->
                   <!-- start body---->
   <!-- /.container -->
          <%
                      String pid = request.getParameter("pid");
                        String privatekey = request.getParameter("privatekey");
                        System.out.println("get the search"+privatekey);
                        session.setAttribute("privatekey", privatekey);
                       // String dna1 = null;
                       // String dna2 = null;
                       // String dna3 = null;
                       // String dna4 = null;
                    %>
                          
                          
                               <%
                                Connection con = null;
                                Statement st = null;
                                ResultSet rs = null;
                                String[] dna_data = new String[4];
                                ArrayList<String> dec_data=new ArrayList<>();
                                try {
                                    con = Dbconnection.getConnection();
                                    st = con.createStatement();
                                   rs = st.executeQuery("select * from request where pid='" + pid + "'");
                                   
                                   
                                     while( rs.next())
                                     {  
                                         
                                         if ( rs.getString("privatekey").equals(privatekey))
                                         {
                                              dna_data[0] = rs.getString("dna1");
                                                dna_data[1] = rs.getString("dna2");
                                                  dna_data[2] = rs.getString("dna3");
                                                    dna_data[3] = rs.getString("dna4");
                                                    decryption dec_obj = new decryption();
                                                 dec_data=   dec_obj.decrypt(dna_data);
                                                  
                                               //  dec_data.get(0);
                                                    
                                           %>      
                                                 <div>
                                                     <center>        
       <h5><font size="5"   style="color: #00A6EB" >Patient Information</font></h5>
       <br><br>
       <input type="text" value="<%=rs.getString("pid")%>" readonly="" placeholder="Patient ID">
       <input type="text" value="<%=rs.getString("date")%>" readonly="" placeholder="Patient Name"><br><br>
       <input type="text" value="<%=dec_data.get(0)%>" readonly="" placeholder="Gender">
       <input type="text" value="<%=dec_data.get(1)%>" readonly="" placeholder="Patient Age"><br><br>
       <input type="text" value="<%=dec_data.get(2)%>" readonly="" placeholder="Patient DOB">
       <input type="email" value="<%=dec_data.get(3)%>" readonly="" placeholder="Email"><br><br>
      
    

  </form>
                            </div> 
                                           
                                         <%
                                                
                                         }
                                         else 
                                             {
                                            response.sendRedirect("download.jsp?m3=vefication failed key not matched");
                                                }
                                     }
                                    
                                   
                                    
                      
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                            %>
                            <br><br>


<!-- end body---->
               </div>
                
            </div>
            

	</div>

    <div id="body" class="width">



		<section id="content" class="two-column with-right-sidebar">

	    
		
        </section>
        
       
    	<div class="clear"></div>
    </div>
    <footer class="width">

        <div class="footer-bottom">
           
         </div>
    </footer>
</div>
</body>
</html>
