X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fcore%2FDefaultUserAdminService.java;fp=security%2Fruntime%2Forg.argeo.security.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fcore%2FDefaultUserAdminService.java;h=0000000000000000000000000000000000000000;hb=fb4f7c451ea7d9025f7cf7fe032020f229df794a;hp=e823124d7c690bf387bdcf5ee6dc3ab1a00daa58;hpb=5266ec50ddbf3247a5033d98a1dbceec6673a5b8;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultUserAdminService.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultUserAdminService.java deleted file mode 100644 index e823124d7..000000000 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/core/DefaultUserAdminService.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2010 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.argeo.security.core; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.argeo.security.ArgeoUser; -import org.argeo.security.UserAdminDao; -import org.argeo.security.UserAdminService; -import org.argeo.security.nature.SimpleUserNature; - -public class DefaultUserAdminService implements UserAdminService { - private String superUsername = "root"; - private UserAdminDao userAdminDao; - - public void newRole(String role) { - userAdminDao.createRole(role, getSuperUsername()); - } - - public void updateUserPassword(String username, String password) { - userAdminDao.updateUserPassword(username, password); - } - - public void newUser(ArgeoUser user) { - // pre-process - SimpleUserNature simpleUserNature; - try { - simpleUserNature = SimpleUserNature - .findSimpleUserNature(user, null); - } catch (Exception e) { - simpleUserNature = new SimpleUserNature(); - user.getUserNatures().put("simpleUserNature", simpleUserNature); - } - - if (simpleUserNature.getLastName() == null - || simpleUserNature.getLastName().equals("")) { - // to prevent issue with sn in LDAP - simpleUserNature.setLastName("empty"); - } - - userAdminDao.createUser(user); - } - - - - public void synchronize() { - // TODO Auto-generated method stub - - } - - public ArgeoUser getUser(String username) { - return userAdminDao.getUser(username); - } - - public Boolean userExists(String username) { - return userAdminDao.userExists(username); - } - - public void updateUser(ArgeoUser user) { - userAdminDao.updateUser(user); - } - - public void deleteUser(String username) { - userAdminDao.deleteUser(username); - - } - - public void deleteRole(String role) { - userAdminDao.deleteRole(role); - } - - public Set listUsersInRole(String role) { - Set lst = new HashSet( - userAdminDao.listUsersInRole(role)); - Iterator it = lst.iterator(); - while (it.hasNext()) { - if (it.next().getUsername().equals(getSuperUsername())) { - it.remove(); - break; - } - } - return lst; - } - - public Set listUsers() { - return userAdminDao.listUsers(); - } - - public List listUserRoles(String username) { - return getUser(username).getRoles(); - } - - public Set listEditableRoles() { - return userAdminDao.listEditableRoles(); - } - - // TODO: expose it via the interface as well? - public String getSuperUsername() { - return superUsername; - } - - public void setUserAdminDao(UserAdminDao userAdminDao) { - this.userAdminDao = userAdminDao; - } - -}