Skip to content

Commit 85416a5

Browse files
committed
Server Version 0.3
1 parent 2c86a39 commit 85416a5

File tree

13 files changed

+167
-201
lines changed

13 files changed

+167
-201
lines changed
Binary file not shown.
Binary file not shown.
-939 Bytes
Binary file not shown.

Client & Server Side/WebContent/jsp/ExpiredMessage.jsp

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,14 @@
1-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2-
pageEncoding="ISO-8859-1"%>
1+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1"%>
32
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
43
<html>
54
<head>
65
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
7-
<title>Mail Content</title>
6+
<title>Expired Message</title>
87
<link rel="stylesheet" type="text/css" href="../jsp/css/styles.css">
98
<link rel="shortcut icon" href="../jsp/img/icon.png">
10-
11-
<script type="text/javascript">
12-
function validateForm()
13-
{
14-
var validated1 = validatePlainText(document.getElementById("requestorName"), "Name");
15-
var validated2 = validateEmail(document.getElementById("requestorEmail"), "Email");
16-
var validated3 = validateEmail(document.getElementById("fromMailR"), "fromMailR");
17-
var validated4 = validatePlainText(document.getElementById("requestReason"), "Reason");
18-
19-
if(validated1 && validated2 && validated3 & validated4) document.forms["requestForm"].submit();
20-
else return false;
21-
}
22-
23-
function validatePlainText(htmlField, fieldName)
24-
{
25-
var value = htmlField.value;
26-
if (value == null || value == "")
27-
{
28-
alert(fieldName+" cannot be left blank");
29-
return false;
30-
}
31-
return true;
32-
}
33-
function validateEmail(htmlField, fieldName)
34-
{
35-
var emailValue = htmlField.value;
36-
var atpos = emailValue.indexOf("@");
37-
var dotpos = emailValue.lastIndexOf(".");
38-
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailValue.length)
39-
{
40-
alert(fieldName+" has to be entered in correct format(e.g. [email protected])");
41-
return false;
42-
}
43-
return true;
44-
}
45-
</script>
46-
479
</head>
4810
<body>
49-
<!-- Header -->
11+
<script src="..//jsp/scripts/expiredmessage.js" type="text/javascript"></script>
5012
<div id="header">
5113
<div id="logo">
5214
</div>
@@ -56,30 +18,30 @@ function validateEmail(htmlField, fieldName)
5618
<div id="content_header">
5719
<div id="site_content1">
5820
<div id="content">
59-
<h2><font color="red">For security reasons, this Message has expired.</font></h2>
60-
<p>Please fill in the below form if you wish to issue a request to bring this message back.</p>
61-
<form action="/SafeMail/MessageController?action=requestMessageRevival" method="post" name="requestForm">
21+
<h2><font color="red">For security reasons, this message has expired.</font></h2>
22+
<p>Please fill in the below form to issue a request to bring this message back.</p>
23+
<form action="jsp/SafeMail/MessageController?action=requestMessageRevival" method="post" name="requestForm">
6224
<table cellspacing="0" cellpadding="0" border="0">
6325
<tr>
6426
<td>Your Name: </td>
6527
<td><input type='text' size="50" id="requestorName" name="requestorName"></input></td>
6628
</tr>
6729
<tr>
68-
<td>Sender Email: </td>
30+
<td>From Email: </td>
6931
<td><input type='text' size="50" id="fromMailR" name="fromMailR"></input></td>
7032
</tr>
7133
<tr>
7234
<td>Your Email: </td>
7335
<td><input type='text' size="50" id="requestorEmail" name="requestorEmail"></input></td>
7436
</tr>
75-
<tr>
76-
<td>Message Id: </td>
77-
<td><label><%=session.getAttribute("messageId")%></label></td>
78-
</tr>
7937
<tr>
8038
<td>Reason: </td>
8139
<td><textarea rows="5" cols="100" id="requestReason" name="requestReason"></textarea></td>
8240
</tr>
41+
<tr>
42+
<td>Message Id: </td>
43+
<td><label><%=session.getAttribute("messageId")%></label></td>
44+
</tr>
8345
<tr>
8446
<td colspan="2" align="center">
8547
<div align="center" id="submitDiv">
Lines changed: 37 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2-
pageEncoding="ISO-8859-1"%>
1+
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
32
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
43
<html>
54
<head>
@@ -8,120 +7,43 @@
87
<link rel="stylesheet" type="text/css" href="jsp/css/styles.css">
98
<link rel="shortcut icon" href="jsp/img/icon.png">
109
</head>
11-
<script src="jsp/cryptojs/rollups/aes.js" type="text/javascript"></script>
12-
<script>
13-
function showMailClickHandler()
14-
{
15-
<% String reqMessageKey = request.getAttribute("messageKey").toString(); %>
16-
<% String reqDecodeURI= request.getAttribute("DecodeURIComponent").toString(); %>
17-
var URI = '<%=reqDecodeURI%>';
18-
var eText = document.getElementById("encryptedMailTxt");
19-
var messageKey = '<%=reqMessageKey%>';
20-
var decrypted = CryptoJS.AES.decrypt(eText.value, messageKey);
21-
var decryptedMailTxtArea = document.getElementById("hello");
10+
<script src="jsp/cryptojs/rollups/aes.js" type="text/javascript"></script>
11+
<script>
12+
<% String reqMessageKey = request.getAttribute("messageKey").toString(); %>
13+
var messageKey = '<%=reqMessageKey%>';
14+
</script>
2215

23-
if (URI == 'true'){
24-
var text = decrypted.toString(CryptoJS.enc.Utf8);
25-
decryptedMailTxtArea.innerHTML = decodeURIComponent(text);
26-
showEncryptedDiv(2);
27-
}
16+
<body>
17+
<div id="header"><div id="logo"><div id="logo_text"></div></div></div>
2818

29-
else{
30-
var text =hex2a(text.toString());
31-
decryptedMailTxtArea.value = text;
32-
showEncryptedDiv(1);
33-
}
34-
}
35-
36-
function hex2a(hex)
37-
{
38-
var str = '';
39-
for (var i=0;i < hex.length; i+=2)
40-
{
41-
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
42-
}
43-
return str;
44-
}
19+
<div id="content_header">
20+
<div id="site_content1">
21+
<div id="content">
22+
<h1>Mail Decryption</h1>
4523

46-
function showEncryptedDiv(showEncrypted)
47-
{
48-
var decryptedMailDiv1 = document.getElementById("decryptedMail1");
49-
var decryptedMailDiv2 = document.getElementByid("decyrptedMail2");
50-
var encryptedMailDiv = document.getElementById("encryptedMail");
51-
if(showEncrypted == 2)
52-
{
53-
decryptedMailDiv1.style.display = "none";
54-
decryptedMailDiv2.style.display = "block";
55-
encryptedMailDiv.style.display = "none";
56-
}
57-
if(showEncrypted ==1)
58-
{
59-
decryptedMailDiv1.style.display = "block";
60-
decryptedMailDiv2.style.display = "none";
61-
encryptedMailDiv.style.display = "none";
62-
}
63-
else
64-
{
65-
decryptedMailDiv1.style.display = "none";
66-
decryptedMailDiv2.style.display = "none";
67-
encryptedMailDiv.style.display = "block";
68-
}
69-
}
70-
71-
function hideDecryptedMail()
72-
{
73-
document.getElementById("decryptedMail").style.display = "none";
74-
}
75-
</script>
76-
<body onload="hideDecryptedMail()">
77-
<!-- Header -->
78-
<div id="header">
79-
<div id="logo">
80-
<div id="logo_text">
81-
<!-- <h1><a href="http://www.safegmail.com">Safe<span class="logo_colour">Gmail</span></a></h1>
82-
<h2>PGP encryption for Gmail.</h2> -->
83-
</div>
84-
</div>
85-
</div>
86-
87-
<!-- Content -->
88-
<div id="content_header">
89-
<div id="site_content1">
90-
<div id="content">
91-
<h1>Mail Decryption</h1>
92-
<div id="encryptedMail">
93-
<label><b>Please copy-paste the encrypted message content from Gmail below</b></label><br>
94-
<textarea rows="22" cols="120" id="encryptedMailTxt"></textarea><br>
95-
<div align="center">
96-
<input type="button" value="Show My Mail" onclick="showMailClickHandler()"/>
97-
</div>
98-
</div>
99-
100-
<div id="decryptedMail1">
101-
<label><b>Mail Content:</b></label><br>
102-
<div align="center">
103-
<textarea rows="22" cols="120" id="decryptedMailTxt" readonly="readonly"></textarea>
104-
<input type="button" value="Back To Encrypted Text" onclick="showEncryptedDiv(true)"/>
105-
</div>
106-
107-
<div id="decryptedMail2">
108-
<label><b>Mail Content:</b></label><br><br>
109-
<div id="hello" align="left">
110-
</div>
111-
112-
</div>
113-
</div>
114-
</div>
115-
</div>
116-
<script type="text/javascript">
117-
var _gaq = _gaq || [];
118-
_gaq.push(['_setAccount', 'UA-33255588-1']);
119-
_gaq.push(['_trackPageview']);
120-
(function() {
121-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
122-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
123-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
124-
})();
125-
</script>
126-
</body>
24+
<div id="encryptedMail">
25+
<label><b>Please copy-paste the encrypted message content from Gmail below</b></label><br>
26+
<textarea rows="22" cols="120" id="encryptedMailTxt"></textarea><br>
27+
<div align="center">
28+
<input type="button" value="Show My Mail" onclick="showMailClickHandler()"/>
29+
</div>
30+
</div>
31+
32+
<div id="decryptedMail1" >
33+
<label><b>Mail Content:</b></label><br>
34+
<div align="center">
35+
<textarea rows="22" cols="120" id="decryptedMailTxt" readonly="readonly"></textarea>
36+
</div>
37+
</div>
38+
39+
<div id="decryptedMail2">
40+
<label><b>Mail Content:</b></label><br><br>
41+
<div align="left">
42+
</div>
43+
</div>
44+
</div>
45+
</div>
46+
</div>
47+
<script src="jsp/scripts/mailcontent.js" type="text/javascript"></script>
48+
</body>
12749
</html>

Client & Server Side/WebContent/jsp/MessageQuestion.jsp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ function removeSubmitButton()
3232
3333
function canonicalString(str)
3434
{
35-
return trimString(str).toLowerCase();
36-
}
37-
function trimString(str)
38-
{
39-
return str.replace(/\s/g, "");
35+
return str.replace(/\s/g, "").toLowerCase();
4036
}
4137
4238
function checkEnter(e)

Client & Server Side/WebContent/jsp/cryptojs/rollups/md5.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function validateForm()
2+
{
3+
if (validatePlainText(document.getElementById("requestorName"), "Name")){
4+
if (validateEmail(document.getElementById("fromMailR"), "fromMailR")){
5+
if (validateEmail(document.getElementById("requestorEmail"), "Email")){
6+
if (validatePlainText(document.getElementById("requestReason"), "Reason")){
7+
document.forms["requestForm"].submit();
8+
}
9+
}
10+
}
11+
}
12+
}
13+
14+
function validatePlainText(htmlField, fieldName)
15+
{
16+
var value = htmlField.value;
17+
if (value == null || value == "")
18+
{
19+
alert(fieldName+" cannot be left blank");
20+
return false;
21+
}
22+
return true;
23+
}
24+
function validateEmail(htmlField, fieldName)
25+
{
26+
var emailValue = htmlField.value;
27+
var atpos = emailValue.indexOf("@");
28+
var dotpos = emailValue.lastIndexOf(".");
29+
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailValue.length)
30+
{
31+
alert(fieldName+" has to be entered in correct format(e.g. [email protected])");
32+
return false;
33+
}
34+
return true;
35+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
var decryptedMailDiv1 = document.getElementById("decryptedMail1");
2+
var decryptedMailDiv2 = document.getElementById("decryptedMail2");
3+
var encryptedMailDiv = document.getElementById("encryptedMail");
4+
5+
hideDecryptedMail();
6+
7+
8+
function hideDecryptedMail(){
9+
10+
decryptedMailDiv1.style.display = "none";
11+
decryptedMailDiv2.style.display = "none";
12+
}
13+
14+
function showMailClickHandler(){
15+
16+
var eText = document.getElementById("encryptedMailTxt");
17+
var decrypted = CryptoJS.AES.decrypt(eText.value, messageKey);
18+
19+
// if (URI == 'true'){
20+
21+
var text = decrypted.toString(CryptoJS.enc.Utf8);
22+
decryptedMailDiv2.innerHTML = decodeURIComponent(text);
23+
showEncryptedDiv(2);
24+
//}
25+
26+
/*else{
27+
var decryptedMailTxtArea = document.getElementById(decryptedMailTxt);
28+
var text =hex2a(decrypted.toString());
29+
decryptedMailTxtArea.value = text;
30+
showEncryptedDiv(1);
31+
}*/
32+
}
33+
34+
function showEncryptedDiv(showEncrypted){
35+
36+
if(showEncrypted == 2){
37+
decryptedMailDiv2.style.display = "block";
38+
encryptedMailDiv.style.display = "none";
39+
}
40+
else {
41+
decryptedMailDiv1.style.display = "block";
42+
encryptedMailDiv.style.display = "none";
43+
}
44+
45+
}
46+
47+
function hex2a(hex){
48+
var str = '';
49+
for (var i=0;i < hex.length; i+=2){str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));}
50+
return str;
51+
}

Client & Server Side/WebContent/jsp/web.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<description>messagecontroller</description>
99
<display-name>Controller</display-name>
1010
<servlet-name>Controller</servlet-name>
11-
<servlet-class>com.illuminati.safemail.web.Controller</servlet-class>
11+
<servlet-class>web.Controller</servlet-class>
1212
<load-on-startup>1</load-on-startup>
1313
<init-param>
1414
<param-name>sysuser</param-name>

0 commit comments

Comments
 (0)