mind serializer and weblog
[ start | index | login ]
start > source-changed-MailPasswordKey

source-changed-MailPasswordKey

Created by case. Last edited by case, 4 years and 261 days ago. Viewed 296 times. #1
[edit] [rdf]
labels
attachments

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; } }

no comments | post comment
Quick Links
WhatIsThis about?
Midlets (mobile apps)
TimeLine
Charley a dog's life
MovieReview
Impressum
Project (internal)

Logged in Users: (1)
… and 2 Guests.

< October 2008 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
262728293031

Icon-Snip more changes...

Blogs
>>++ vox.machina ++
>>Zitate - Sprüche - Aphorismen
>>Wil Wheaton
>>Mathematische Kleinigkeiten
>>William Gibson
>>instant-thinking
>>Over heard in NY

nearby  sites
link=http://www.mozilla.org/products/firefox/central.html
link=http://www.nutellausa.com/
link=http://snipsnap.org
link=http://www.amazon.de/exec/obidos/registry/wishlist/ref=cs_nav_top_2/028-7651535-0049343
RSS Feed RSS Feed
post to del.icio.us

Stats: 1179 snips by 16 users
created 5 years and 270 days ago

Powered by
>>SnipSnap 1.0b2-uttoxeter
with SnipScale 1.1.0



This work is licensed under a
>>Creative Commons License.

SEARCH