DBPasswordAlter.jsp
7.41 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.general.GCONST" %>
<%@ page import="weaver.general.AES" %>
<%@ page import="weaver.file.Prop" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.sm.SM4Utils"%>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="AESCoder" class="weaver.file.AESCoder" scope="page" />
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<html>
<head>
<LINK href="/css/Weaver_wev8.css" type=text/css rel=STYLESHEET>
<SCRIPT language="javascript" src="../../js/weaver_wev8.js"></script>
</head>
<%
if(user.getUID() != 1){
response.sendRedirect("/notice/noright.jsp");
return;
}
String imagefilename = "/images/hdMaintenance.gif";
String titlename = SystemEnv.getHtmlLabelNames("103,15024,724,87",user.getLanguage());
boolean isfromtab = Util.null2String(request.getParameter("isfromtab")).equals("true")?true:false;
String needfav ="1";
String needhelp ="";
String id = String.valueOf(user.getUID());
String message = Util.null2String(request.getParameter("message"));
String reversible_enc_type = Util.null2String(RecordSet.getPropValue("weaver_security_type", "reversible_enc_type"));
reversible_enc_type = "sm4".equals(reversible_enc_type)?reversible_enc_type:"aes";
String operation = Util.null2String(request.getParameter("operation"));
String keyCode = Util.null2String(RecordSet.getPropValue("DBEncoder", "key"));
if("changeDBpassword".equals(operation)){
try{
Prop prop = Prop.getInstance();
String passwordold = Util.null2String(request.getParameter("passwordold"));
String passwordnew = Util.null2String(request.getParameter("passwordnew"));
String ecology_password = prop.getPropValueBase(GCONST.getConfigFile() , "ecology.password");
if("sm4".equals(reversible_enc_type)){
SM4Utils sm4 = new SM4Utils();
ecology_password = sm4.decrypt(ecology_password,keyCode,SM4Utils.ENC_SM4);
}else{
ecology_password = AESCoder.decrypt(ecology_password, keyCode);
}
if(!ecology_password.equals(passwordold)){
response.sendRedirect("DBPasswordAlter.jsp?message=2");
}else{
String username = Util.null2String(request.getParameter("username"));
boolean flag = false;
boolean flag2 = false;
if("sm4".equals(reversible_enc_type)){
SM4Utils sm4 = new SM4Utils();
flag = prop.setPropValue(GCONST.getConfigFile(),"ecology.password",sm4.encrypt(passwordnew,keyCode,SM4Utils.ENC_SM4));
flag2 = prop.setPropValue(GCONST.getConfigFile(),"ecology.user",sm4.encrypt(username,keyCode,SM4Utils.ENC_SM4));
}else{
flag = prop.setPropValue(GCONST.getConfigFile(),"ecology.password",AESCoder.encrypt(passwordnew, keyCode));
flag2 = prop.setPropValue(GCONST.getConfigFile(),"ecology.user",AESCoder.encrypt(username, keyCode));
}
if(flag && flag2){
response.sendRedirect("DBPasswordAlter.jsp?message=1");
}else{
response.sendRedirect("DBPasswordAlter.jsp?message=3");
}
}
}catch(Exception e){
RecordSet.writeLog("changeDBpassword:"+e.getMessage());
response.sendRedirect("DBPasswordAlter.jsp?message=3");
}
}
%>
<body>
<%@ include file="/systeminfo/TopTitle_wev8.jsp" %>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp" %>
<%
RCMenu += "{"+SystemEnv.getHtmlLabelName(86,user.getLanguage())+",javascript:submitData(),_self} " ;
RCMenuHeight += RCMenuHeightStep ;
%>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp" %>
<table width=100% height=100% border="0" cellspacing="0" cellpadding="0">
<colgroup>
<col width="10">
<col width="">
<col width="10">
<tr>
<td height="10" colspan="3"></td>
</tr>
<tr>
<td ></td>
<td valign="top">
<%if(isfromtab) {%>
<TABLE width='100%'>
<%}else {%>
<TABLE class=Shadow>
<%} %>
<tr>
<td valign="top">
<% if(message.equals("1")) {%>
<font color="#FF0000"><%=SystemEnv.getHtmlLabelNames("103,15242",user.getLanguage())%></font>
<%}%>
<% if(message.equals("2")) {%>
<font color="#FF0000"><%=SystemEnv.getHtmlLabelNames("15024,32738,27685",user.getLanguage())%></font>
<%}%>
<% if(message.equals("3")) {%>
<font color="#FF0000"><%=SystemEnv.getHtmlLabelName(22891,user.getLanguage())%></font>
<%}%>
<FORM id=password name=frmMain style="MARGIN-TOP: 3px" action=DBPasswordAlter.jsp method=post>
<table id="topTitle" cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td class="rightSearchSpan" style="text-align:right;">
<input type=button class="e8_btn_top" onclick="submitData();" value="<%=SystemEnv.getHtmlLabelName(86,user.getLanguage())%>"></input>
<span title="<%=SystemEnv.getHtmlLabelName(23036,user.getLanguage())%>" class="cornerMenu"></span>
</td>
</tr>
</table>
<input type=hidden name=operation value="changeDBpassword">
<wea:layout type="2col">
<wea:group context='<%=SystemEnv.getHtmlLabelNames("103,15024,724,87",user.getLanguage())%>' >
<wea:item><%=SystemEnv.getHtmlLabelName(33149,user.getLanguage())%></wea:item>
<wea:item>
<span id=reversible_enc_type name=reversible_enc_type ><%=reversible_enc_type %></span>
</wea:item>
<wea:item><%=SystemEnv.getHtmlLabelName(32348,user.getLanguage())%></wea:item>
<wea:item>
<span id=keycode name=keycode ><%=keyCode %></span>
</wea:item>
<wea:item><%=SystemEnv.getHtmlLabelNames("15024,2072",user.getLanguage())%></wea:item>
<wea:item><INPUT class=inputstyle id=user type=text style="width: 150px;"
name=username onchange='checkinput("username","usernameimage")'>
<SPAN id=usernameimage><IMG src="/images/BacoError_wev8.gif" align=absMiddle></SPAN>
</wea:item>
<wea:item><%=SystemEnv.getHtmlLabelNames("15024,32738",user.getLanguage())%></wea:item>
<wea:item><INPUT class=inputstyle id=passwordold type=password style="width: 150px;"
name=passwordold onchange='checkinput("passwordold","passwordoldimage")'>
<SPAN id=passwordoldimage><IMG src="/images/BacoError_wev8.gif" align=absMiddle></SPAN>
</wea:item>
<wea:item><%=SystemEnv.getHtmlLabelNames("15024,27303",user.getLanguage())%></wea:item>
<wea:item><INPUT class=inputstyle id=passwordnew type=password style="width: 150px"
name=passwordnew onchange='checkinput("passwordnew","passwordnewimage")'> <span id=passwordnewimage><img src="/images/BacoError_wev8.gif" align=absMiddle></span>
</wea:item>
<wea:item><%=SystemEnv.getHtmlLabelNames("16631,15024,27303",user.getLanguage())%></wea:item>
<wea:item><INPUT class=inputstyle id=confirmpassword type=password style="width: 150px"
name=confirmpassword onchange='checkinput("confirmpassword","confirmpasswordimage")'>
<span id=confirmpasswordimage><img src="/images/BacoError_wev8.gif" align=absMiddle></span></wea:item>
<wea:item></wea:item>
</wea:group>
</wea:layout>
</FORM>
<script type="text/javascript">
function submitData(){
if(checkpassword()){
frmMain.submit();
}
}
function checkpassword() {
if("<%=keyCode%>" == ""){
top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(32348,user.getLanguage())+SystemEnv.getHtmlLabelName(82241,user.getLanguage())%>");
return false;
}
if(!check_form(password,"username,passwordold,passwordnew,confirmpassword"))
return false;
if(password.passwordnew.value != password.confirmpassword.value) {
top.Dialog.alert("<%=SystemEnv.getHtmlNoteName(16,user.getLanguage())%>");
return false;
}
return true;
}
</script>
</td>
</tr>
</TABLE>
</td>
<td></td>
</tr>
<tr>
<td height="10" colspan="3"></td>
</tr>
</table>
</body>
</html>