NOT ACTIVE ANY MORE
Reason
Again, because dynamic IP, behind router, no DNS, my snipsnap could not post and ForgottenPassword Email providing the correct link to update the password. I managed to post a forwarding link, but that caused problems due to the forwarding (mail key was not valid).
Updated org.snipsnap.net.MailPasswordKeyServlet
The Workaround is to get the dynamic IP from a webserver (where it is delivered by a scirpt or a server side include, parse it and include it into the mail-url. I also added a new application.conf entry where you can specify an html page delivering the current ip of the server.
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[...]
String subject = "Forgotten password";
String url =
WMuteAdressGetter.getWintermuteHostAdress()
+ "/exec/changepass.jsp?key="
+ key;
String content =
"To change your password go to <a href=""
+ url
+ "">"
+ url
+ "</a>"
+ " As the server's ip address
is changing regulary, the link may be outdated soon."
+ " If this has happend, you can repeat your request
for a password key any time again. "
+ "Have a nice day! ."
+ configuration.getName(); Mail.getInstance().sendMail(receiver, subject, content);
[...]The WMuteAdressGetter was added to retrieve the IP Address-url.
public class WMuteAdressGetter {
final static String HEADER = "http://";
static String PORT = ":";
public static String getWintermuteHostAdress() {
AppConfiguration configuration = Application.get().getConfiguration();
String ipUrl = configuration.getProperty("app.ipurl"); HttpURLConnection httpCon;
String result = "HOST_ADRESS_FROM_WINTERMUTE.DE/HOME";
try {
URL url = new URL(ipUrl);
httpCon = (HttpURLConnection) url.openConnection();
httpCon.setFollowRedirects(true);
BufferedReader in =
new BufferedReader(
new InputStreamReader(httpCon.getInputStream()));
String line;
StringBuffer sb = new StringBuffer();
while ((line = in.readLine()) != null) {
sb.append(line);
}
in.close();
httpCon.disconnect();
result = HEADER + parseIP(sb.toString()) + PORT +
configuration.getProperty("app.port");
} catch (UnknownHostException e) {
} catch (IOException e) {
}
return result;
}
/**
* Method parseIP.
* @param string
* @return String
*/
private static String parseIP(String string) {
String result = "wintermute.de/home";
Pattern p =
Pattern.compile(
".*\\s((?:[0-9]{1,3}[.]){3}(?:[0-9]{1,3})).*",
Pattern.DOTALL);
Matcher m = p.matcher(string);
boolean b = m.matches();
if (b) {
int start = m.start(1);
int end = m.end(1);
result = string.substring(start, end);
}
return result;
}
}