commit | author | age
|
c65695
|
1 |
package de.uhilger.um.api; |
U |
2 |
|
|
3 |
import de.uhilger.baselink.GenericRecord; |
|
4 |
import de.uhilger.baselink.Record; |
|
5 |
import de.uhilger.um.App; |
|
6 |
import de.uhilger.um.daten.User; |
725d10
|
7 |
import java.util.List; |
c65695
|
8 |
import org.apache.catalina.realm.RealmBase; |
U |
9 |
|
|
10 |
/** |
59f8b3
|
11 |
* Klasse zur Verwaltung von Benutzern in einer Datenbank |
U |
12 |
* |
c65695
|
13 |
* @author Ulrich Hilger |
U |
14 |
*/ |
|
15 |
public class UserMgr { |
|
16 |
|
|
17 |
private static final String MD5 = "MD5"; |
|
18 |
|
|
19 |
private static final Record UserMapper = new GenericRecord(User.class); |
|
20 |
|
725d10
|
21 |
public static final String SQL_GET_USER_LIST = "getUserList"; |
U |
22 |
public static final String SQL_GET_USER_NAME_LIST = "getUserNameList"; |
72c5c3
|
23 |
public static final String SQL_DELETE_USER = "deleteUser"; |
725d10
|
24 |
|
be9fa2
|
25 |
/* ----------- Benutzer -------------- */ |
U |
26 |
|
c65695
|
27 |
public User createUser(User user) { |
U |
28 |
String kw = user.getPw(); |
|
29 |
String digestedPw = RealmBase.Digest(kw, MD5, null); |
|
30 |
user.setPw(digestedPw); |
|
31 |
App.getDatabase().insert(user, UserMapper); |
|
32 |
return user; |
|
33 |
} |
|
34 |
|
725d10
|
35 |
public List getUserNameList() { |
U |
36 |
String sql = App.getSqlStatement(SQL_GET_USER_NAME_LIST); |
|
37 |
List userNames = App.getDatabase().select(sql, App.WITHOUT_BLOBS); |
|
38 |
return userNames; |
|
39 |
} |
|
40 |
|
72c5c3
|
41 |
public User deleteUser(User user) { |
U |
42 |
return (User) App.getDatabase().delete(user, UserMapper); |
|
43 |
} |
|
44 |
|
725d10
|
45 |
/* |
U |
46 |
public List getUserList() { |
|
47 |
String sql = App.getSqlStatement(SQL_GET_USER_LIST); |
|
48 |
List users = App.getDatabase().select(sql, UserMapper, App.WITHOUT_BLOBS); |
|
49 |
return users; |
|
50 |
} |
|
51 |
*/ |
|
52 |
|
be9fa2
|
53 |
/* ------------ Rollen ------------------ */ |
U |
54 |
|
|
55 |
public String grantRole(String userId, String roleName) { |
|
56 |
return "not implemented"; |
|
57 |
} |
|
58 |
|
|
59 |
public String revokeRole(String userId, String roleName) { |
|
60 |
return "not implemented"; |
|
61 |
} |
|
62 |
|
|
63 |
public List getRoleNamesGranted() { |
|
64 |
return null; |
|
65 |
} |
|
66 |
|
|
67 |
/* ------------ sonstige Methoden -------------- */ |
|
68 |
|
f8b605
|
69 |
public String hallo() { |
U |
70 |
return "Hallo Welt"; |
|
71 |
} |
|
72 |
|
c65695
|
73 |
} |