01: package dinamica.security;
02:
03: import dinamica.*;
04: import javax.sql.DataSource;
05: import java.sql.*;
06:
07: /**
08: * Retrieve user profile record.
09: * <br><br>
10: * (c) 2004 Martin Cordova<br>
11: * This code is released under the LGPL license<br>
12: * Dinamica Framework - http://www.martincordova.com
13: * @author Martin Cordova (dinamica@martincordova.com)
14: * */
15: public class GetLoginHistory extends GenericTransaction {
16:
17: /* (non-Javadoc)
18: * @see dinamica.GenericTransaction#service(dinamica.Recordset)
19: */
20: public int service(Recordset inputParams) throws Throwable {
21:
22: super .service(inputParams);
23:
24: //get security datasource
25: String jndiName = (String) getContext().getAttribute(
26: "dinamica.security.datasource");
27: if (jndiName == null)
28: throw new Throwable(
29: "Context attribute [dinamica.security.datasource] is null, check your security filter configuration.");
30:
31: //get datasource and DB connection
32: DataSource ds = Jndi.getDataSource(jndiName);
33: Connection conn = ds.getConnection();
34: this .setConnection(conn);
35:
36: try {
37:
38: //get db channel
39: Db db = getDb();
40:
41: //get user profile
42: Recordset rs = db.get(getSQL(getResource("query.sql"),
43: inputParams));
44:
45: publish("query.sql", rs);
46:
47: } catch (Throwable e) {
48: throw e;
49: } finally {
50: if (conn != null)
51: conn.close();
52: }
53:
54: return 0;
55:
56: }
57:
58: }
|