-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTA_MSKRequests1.jsp
59 lines (47 loc) · 2.08 KB
/
TA_MSKRequests1.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%@ page import="java.sql.*,java.util.Random,java.security.KeyPair,java.security.KeyPairGenerator,java.security.NoSuchAlgorithmException,java.security.PrivateKey,javax.crypto.Cipher,javax.crypto.NoSuchPaddingException" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import ="java.util.*"%>
<%@ include file="connect.jsp" %>
<%@page import ="java.util.*,java.security.Key,java.util.Random,javax.crypto.Cipher,javax.crypto.spec.SecretKeySpec,org.bouncycastle.util.encoders.Base64"%>
<%@ page import="java.sql.*,java.util.Random,java.io.PrintStream,java.io.FileOutputStream,java.io.FileInputStream,java.security.DigestInputStream,java.math.BigInteger,java.security.MessageDigest,java.io.BufferedInputStream" %>
<%@page import ="java.util.*,java.text.SimpleDateFormat,java.util.Date,java.io.FileInputStream,java.io.FileOutputStream,java.io.PrintStream"%>
<html><style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<body>
<%
int uid = Integer.parseInt(request.getParameter("usid"));
String fname=request.getParameter("fname");
try {
KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
Cipher encoder = Cipher.getInstance("RSA");
KeyPair kp = kg.generateKeyPair();
PrivateKey privKey = kp.getPrivate();
// RSA produces 1024 bits Key
byte[] priv = privKey.getEncoded();
String s = priv.toString();
Statement st1 = connection.createStatement();
SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");
Date now = new Date();
String strDate = sdfDate.format(now);
String strTime = sdfTime.format(now);
String dt = strDate + " " + strTime;
String query2 ="update cloudserver set sk='"+s+"' where fname='"+fname+"' ";
st1.executeUpdate (query2);
String query1 ="update request set sk='"+s+"',restime='"+dt+"' where id='"+uid+"' ";
st1.executeUpdate (query1);
response.sendRedirect("TA_MSKRequests.jsp");
connection.close();
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</body></html>