2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.security
.core
;
21 import org
.argeo
.security
.ArgeoUser
;
22 import org
.argeo
.security
.CurrentUserDao
;
23 import org
.argeo
.security
.CurrentUserService
;
24 import org
.argeo
.security
.UserNature
;
27 public class DefaultCurrentUserService
implements CurrentUserService
{
28 private CurrentUserDao currentUserDao
;
30 public DefaultCurrentUserService() {
33 public ArgeoUser
getCurrentUser() {
34 ArgeoUser argeoUser
= ArgeoUserDetails
.securityContextUser();
35 if (argeoUser
== null)
37 if (argeoUser
.getRoles().contains(currentUserDao
.getDefaultRole()))
38 argeoUser
.getRoles().remove(currentUserDao
.getDefaultRole());
42 public void updateCurrentUserPassword(String oldPassword
, String newPassword
) {
43 currentUserDao
.updateCurrentUserPassword(oldPassword
, newPassword
);
46 public void updateCurrentUserNatures(Map
<String
, UserNature
> userNatures
) {
47 // TODO Auto-generated method stub
51 public void setCurrentUserDao(CurrentUserDao dao
) {
52 this.currentUserDao
= dao
;