1 19 20 package com.sslexplorer.setup; 21 22 import java.text.DateFormat ; 23 import java.util.Calendar ; 24 import java.util.GregorianCalendar ; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 import com.sslexplorer.core.CoreUtil; 29 import com.sslexplorer.security.SessionInfo; 30 import com.sslexplorer.table.TableItem; 31 32 38 39 public class ActiveSession implements TableItem { 40 41 final static DateFormat dateFormat = DateFormat.getDateInstance(); 42 final static DateFormat timeFormat = DateFormat.getTimeInstance(); 43 44 private SessionInfo info; 46 47 53 public ActiveSession(SessionInfo info) { 54 super(); 55 this.info = info; 56 } 57 58 59 64 public SessionInfo getInfo() { 65 return info; 66 } 67 68 74 public String getLogonTimeText() { 75 Calendar c = getInfo().getLogonTime(); 76 Calendar startOfDay = new GregorianCalendar (); 77 startOfDay.set(Calendar.HOUR, 0); 78 startOfDay.set(Calendar.MINUTE, 0); 79 startOfDay.set(Calendar.SECOND, 0); 80 startOfDay.set(Calendar.MILLISECOND, 0); 81 Calendar endOfDay = new GregorianCalendar (); 82 endOfDay.set(Calendar.HOUR, 23); 83 endOfDay.set(Calendar.MINUTE, 59); 84 endOfDay.set(Calendar.SECOND, 59); 85 endOfDay.set(Calendar.MILLISECOND, 999); 86 if(c.compareTo(endOfDay) <= 0 && c.compareTo(startOfDay) >= 0) { 87 return timeFormat.format(getInfo().getLogonTime().getTime()); 88 } 89 else { 90 return dateFormat.format(getInfo().getLogonTime().getTime()); 91 } 92 } 93 94 97 public Object getColumnValue(int col) { 98 switch(col) { 99 case 0: 100 return getInfo().getUser().getPrincipalName(); 101 case 1: 102 return getInfo().getAddress(); 103 default: 104 return getInfo().getLogonTime(); 105 } 106 } 107 108 public String getSmallIconPath(HttpServletRequest request) { 109 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/user.gif"; 110 } 111 112 } 113
| Popular Tags
|