commit | author | age
|
70a614
|
1 |
package de.uhilger.um.pub; |
U |
2 |
|
|
3 |
import de.uhilger.baselink.PersistenceManager; |
|
4 |
import de.uhilger.um.api.Api; |
|
5 |
import static de.uhilger.um.api.UserMgr.MP_USER_DATA; |
|
6 |
import static de.uhilger.um.api.UserMgr.SQL_GET_USER_DATA; |
|
7 |
import static de.uhilger.um.api.UserMgr.WITHOUT_BLOBS; |
|
8 |
import de.uhilger.um.daten.UserData; |
|
9 |
import java.security.Principal; |
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
*/ |
|
15 |
public class SessionManager extends Api { |
|
16 |
|
|
17 |
// /um/pub?c=de.uhilger.um.pub.SessionManager&m=getSessionUser |
|
18 |
public UserData getSessionUser() { |
|
19 |
UserData userData = new UserData(); |
|
20 |
userData.setFirstName("nicht angemeldet"); |
|
21 |
userData.setLastName("nicht angemeldet"); |
|
22 |
userData.setId("nicht angemeldet"); |
|
23 |
userData.setEmail("nicht angemeldet"); |
|
24 |
Object p = getRequest().getUserPrincipal(); |
|
25 |
if(p instanceof Principal) { |
|
26 |
String id = ((Principal) p).getName(); |
|
27 |
PersistenceManager pm = getDb(); |
|
28 |
List userDataList = getDb().select(getSql(SQL_GET_USER_DATA), getMapper(MP_USER_DATA), WITHOUT_BLOBS, id); |
|
29 |
if(userDataList != null && userDataList.size() > 0) { |
|
30 |
Object o = userDataList.get(0); |
|
31 |
if(o instanceof UserData) { |
|
32 |
userData = (UserData) o; |
|
33 |
} |
|
34 |
} |
|
35 |
} |
|
36 |
return userData; |
|
37 |
} |
|
38 |
|
|
39 |
|
|
40 |
} |