In my site i have a link Forgot Password when i click on this link a page will come so we fill emailId and send mail to particular gmailid(in this mail we have to generate a link). when we have click on generated link page open for reset password(like new password ar confirm password).
My problem is that i am successfully able to send mail but when click on link not able to find emailId for reset password. Gmail Link :
http://127.0.0.1:8888/abc.html?gwt.codesvr=127.0.0.1:9997#forgetPassword
client Code
sendButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
greetServer.mailLinkSend(emailId.getText(),"http://"+Window.Location.getHost()+Window.Location.getPath()+Window.Location.getQueryString()+"#forgetPassword", new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
// TODO Auto-generated method stub
System.out.println("success"+result);
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
System.out.println("fail");
}
});
}
});
on server
public String mailLinkSend(String emailText, String link) {
SecretKey key = KeyGenerator.getInstance("DES").generateKey();
// Create encrypter/decrypter class DesEncrypter encrypter = new DesEncrypter(key);
// Encrypt encrypted = encrypter.encrypt(emailText);
// Decrypt String decrypted = encrypter.decrypt(encrypted);
String ss = "true";
String emailMsgTxt = "Hi" + emailText + "\n" + "\n"
+ "Your Password Change Link\n" + link + "?id=" + encrypted
+ "\n Click on the above link to Reset your Password";
String emailSubjectTxt = "Change Password Link";
String emailFromAddress = "[email protected]";
String receipentList = emailText;
try {
MailUtility smtpMailSender = new MailUtility();
smtpMailSender.postMail(receipentList, emailSubjectTxt,emailMsgTxt, emailFromAddress);
} catch (MessagingException messagingException) {}
return ss;
}
MailUtility class
public class MailUtility {
public String postMail(String recipients, String subject,
String message, String from) throws MessagingException {
some code.... }
i have send emailId in encrypted form but i don't know how to save key for decrypted and also how to expire link after one time use and 48 hrs.
So your problem with encryption and decryption
So the below code will help you
Note Constants.GWT_DES_KEY will be same on server and client
for example :
private final static byte[] GWT_DES_KEY = new byte[] { -110, 121, -65, 22, -60, 61, -22, -60, 21, -122, 41, -89, -89, -68, -8, 41, -119, -51, -12, -36, 19, -8, -17, 47 };
on the server: