]> git.argeo.org Git - lgpl/argeo-commons.git/blob - DefaultCurrentUserService.java
8e330cb11a1a0062da588fb03f1ab4d2a72e6534
[lgpl/argeo-commons.git] / DefaultCurrentUserService.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.security.core;
18
19 import java.util.Map;
20
21 import org.argeo.security.ArgeoUser;
22 import org.argeo.security.CurrentUserDao;
23 import org.argeo.security.CurrentUserService;
24 import org.argeo.security.UserNature;
25
26 @Deprecated
27 public class DefaultCurrentUserService implements CurrentUserService {
28 private CurrentUserDao currentUserDao;
29
30 public DefaultCurrentUserService() {
31 }
32
33 public ArgeoUser getCurrentUser() {
34 ArgeoUser argeoUser = ArgeoUserDetails.securityContextUser();
35 if (argeoUser == null)
36 return null;
37 if (argeoUser.getRoles().contains(currentUserDao.getDefaultRole()))
38 argeoUser.getRoles().remove(currentUserDao.getDefaultRole());
39 return argeoUser;
40 }
41
42 public void updateCurrentUserPassword(String oldPassword, String newPassword) {
43 currentUserDao.updateCurrentUserPassword(oldPassword, newPassword);
44 }
45
46 public void updateCurrentUserNatures(Map<String, UserNature> userNatures) {
47 // TODO Auto-generated method stub
48
49 }
50
51 public void setCurrentUserDao(CurrentUserDao dao) {
52 this.currentUserDao = dao;
53 }
54 }