commit | author | age
|
70a614
|
1 |
package de.uhilger.um.pub; |
U |
2 |
|
|
3 |
import de.uhilger.um.api.Api; |
|
4 |
import static de.uhilger.um.api.UserMgr.MP_USER_DATA; |
|
5 |
import static de.uhilger.um.api.UserMgr.SQL_GET_USER_DATA; |
|
6 |
import static de.uhilger.um.api.UserMgr.WITHOUT_BLOBS; |
|
7 |
import de.uhilger.um.daten.UserData; |
|
8 |
import java.security.Principal; |
|
9 |
import java.util.List; |
1345f0
|
10 |
import java.util.logging.Logger; |
70a614
|
11 |
|
U |
12 |
/** |
|
13 |
* |
|
14 |
*/ |
|
15 |
public class SessionManager extends Api { |
1345f0
|
16 |
|
U |
17 |
private static final Logger logger = Logger.getLogger(SessionManager.class.getName()); |
70a614
|
18 |
|
U |
19 |
// /um/pub?c=de.uhilger.um.pub.SessionManager&m=getSessionUser |
|
20 |
public UserData getSessionUser() { |
|
21 |
UserData userData = new UserData(); |
|
22 |
userData.setFirstName("nicht angemeldet"); |
|
23 |
userData.setLastName("nicht angemeldet"); |
|
24 |
userData.setId("nicht angemeldet"); |
|
25 |
userData.setEmail("nicht angemeldet"); |
|
26 |
Object p = getRequest().getUserPrincipal(); |
|
27 |
if(p instanceof Principal) { |
|
28 |
String id = ((Principal) p).getName(); |
6fda23
|
29 |
logger.finer("User-ID: " + id); |
70a614
|
30 |
List userDataList = getDb().select(getSql(SQL_GET_USER_DATA), getMapper(MP_USER_DATA), WITHOUT_BLOBS, id); |
U |
31 |
if(userDataList != null && userDataList.size() > 0) { |
|
32 |
Object o = userDataList.get(0); |
|
33 |
if(o instanceof UserData) { |
|
34 |
userData = (UserData) o; |
|
35 |
} |
|
36 |
} |
1345f0
|
37 |
} else { |
6fda23
|
38 |
logger.finer("getUserPrincipal returned null or no Principal"); |
70a614
|
39 |
} |
U |
40 |
return userData; |
|
41 |
} |
|
42 |
|
1345f0
|
43 |
public String expireSession() { |
U |
44 |
getRequest().getSession().invalidate(); |
|
45 |
return "Die aktuelle Sitzung ist nicht mehr gueltig."; |
|
46 |
} |
|
47 |
|
70a614
|
48 |
|
U |
49 |
} |