01: package dinamica.security;
02:
03: import dinamica.*;
04:
05: /**
06: * Send email about failed login attempt
07: * <br><br>
08: * (c) 2004 Martin Cordova<br>
09: * This code is released under the LGPL license<br>
10: * Dinamica Framework - http://www.martincordova.com
11: * @author Martin Cordova (dinamica@martincordova.com)
12: * */
13: public class LoginFailedAlert extends GenericTableManager {
14:
15: /* (non-Javadoc)
16: * @see dinamica.GenericTransaction#service(dinamica.Recordset)
17: */
18: public int service(Recordset inputParams) throws Throwable {
19:
20: super .service(inputParams);
21:
22: //get email config
23: String enabled = getConfig().getConfigValue("//mail/enabled");
24:
25: if (enabled.equals("true")) {
26: String host = getConfig().getConfigValue("//mail/host");
27: String subject = getConfig().getConfigValue(
28: "//mail/subject");
29: String from = getConfig().getConfigValue("//mail/from");
30: String fromName = getConfig().getConfigValue(
31: "//mail/from-name");
32: ;
33: String to = getConfig().getConfigValue("//mail/to");
34: String body = getResource("body.txt");
35:
36: //build message
37: TemplateEngine t = new TemplateEngine(getContext(),
38: getRequest(), body);
39: t.replaceDefaultValues();
40: t.replaceLabels();
41: t.replaceRequestAttributes();
42: body = t.toString();
43:
44: //send email
45: SimpleMail s = new SimpleMail();
46: s.send(host, from, fromName, to, subject, body);
47:
48: }
49:
50: //build log message
51: String res = getResource("log-template.txt");
52: TemplateEngine t = new TemplateEngine(getContext(),
53: getRequest(), res);
54: t.replaceDefaultValues();
55: t.replaceLabels();
56: t.replaceRequestAttributes();
57: res = t.toString();
58: System.err.println(res);
59:
60: return 0;
61:
62: }
63:
64: }
|