Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package edu.ncsu.csc.itrust.action;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.dao.mysql.AccessDAO;
import edu.ncsu.csc.itrust.exception.DBException;
import edu.ncsu.csc.itrust.exception.FormValidationException;
/**
* Used to change the session timeout, sessionTimeout.jsp. Note that a change to this timeout only gets
* reflected on new sessions.
*
*/
public class ChangeSessionTimeoutAction {
private AccessDAO accessDAO;
/**
* Sets up defualts.
*
* @param factory
*/
public ChangeSessionTimeoutAction(DAOFactory factory) {
this.accessDAO = factory.getAccessDAO();
}
/**
* Changes the session timeout, the complicated logic of this is somewhat regrettably in the DAO,
* {@link AccessDAO}
*
* @param minuteString
* Pass the number of minutes in the form of a string, greater than 0.
* @throws FormValidationException
* @throws DBException
*/
public void changeSessionTimeout(String minuteString) throws FormValidationException, DBException {
try {
Integer minutes = Integer.valueOf(minuteString);
if (minutes < 1)
throw new FormValidationException("Must be a number greater than 0");
accessDAO.setSessionTimeoutMins(minutes);
} catch (NumberFormatException e) {
throw new FormValidationException("That is not a number");
}
}
/**
* Returns the current session timeout in minutes, as reflected in the database
*
* @return the number of minutes it would take for an inactive session to timeout
* @throws DBException
*/
public int getSessionTimeout() throws DBException {
return accessDAO.getSessionTimeoutMins();
}
}