Package org.apdplat.module.security.model

Examples of org.apdplat.module.security.model.User


     * 删除角色前,把该角色从所有引用该角色的用户中移除
     * @param ids
     */
    @Override
    public void prepareForDelete(Integer[] ids){
        User loginUser=UserHolder.getCurrentLoginUser();
        for(int id :ids){
            Role role=getService().retrieve(Role.class, id);           
            boolean canDel=true;
            //获取拥有等待删除的角色的所有用户
            List<User> users=role.getUsers();
            for(User user : users){               
                if(PropertyHolder.getBooleanProperty("demo")){
                    if(user.getUsername().equals("admin")){
                        throw new RuntimeException("演示版本不能删除admin用户拥有的角色");
                    }
                }
                if(loginUser.getId()==user.getId()){
                    canDel=false;
                }
            }
            if(!canDel) {
                continue;
View Full Code Here


     * 去除没有分配给用户的模块
     * @param modules
     * @param commands
     */
    public void securityControl(List<Module> modules) {
        User user = UserHolder.getCurrentLoginUser();
        //重新装载用户,消除由于不同会话间延迟加载的问题
        user = serviceFacade.retrieve(User.class, user.getId());
        List<Module> userModules = user.getModule();
        Iterator<Module> moduleIterator = modules.iterator();
        while (moduleIterator.hasNext()) {
            Module m = moduleIterator.next();
            //把没有分配给用户的模块去掉
            boolean contains = false;
View Full Code Here

     * 删除用户组前,把该用户组从所有引用该用户组的用户中移除
     * @param ids
     */
    @Override
    public void prepareForDelete(Integer[] ids){
        User loginUser=UserHolder.getCurrentLoginUser();
        for(int id :ids){
            UserGroup userGroup=getService().retrieve(UserGroup.class, id);
            boolean canDel=true;
            //获取拥有等待删除的角色的所有用户
            List<User> users=userGroup.getUsers();
            for(User user : users){
                if(loginUser.getId()==user.getId()){
                    canDel=false;
                }
            }
            if(!canDel) {
                continue;
View Full Code Here

            Map temp = new HashMap();
            render(temp,user);

            StringBuilder str=new StringBuilder();
            //搜索出来的模型已经被detach了,无法获得延迟加载的数据
            User tmp=getService().retrieve(User.class, user.getId());
            for(Role r : tmp.getRoles()){
                str.append(r.getRoleName()).append(",");
            }
            temp.put("roles", str.length()>1?str.toString().substring(0, str.length()-1):"");

            str=new StringBuilder();
            for(Position p : tmp.getPositions()){
                str.append(p.getPositionName()).append(",");
            }
            temp.put("positions", str.length()>1?str.toString().substring(0, str.length()-1):"");
            result.add(temp);
           
            str=new StringBuilder();
            for(UserGroup p : tmp.getUserGroups()){
                str.append(p.getUserGroupName()).append(",");
            }
            temp.put("userGroups", str.length()>1?str.toString().substring(0, str.length()-1):"");
            result.add(temp);
        }
View Full Code Here

         * 删除岗位前,把该岗位从所有引用该岗位的用户中移除
         * @param ids
         */
        @Override
        public void prepareForDelete(Integer[] ids){
            User loginUser=UserHolder.getCurrentLoginUser();
            for(int id :ids){
                Position position=getService().retrieve(Position.class, id);
                boolean canDel=true;
                //获取拥有等待删除的角色的所有用户
                List<User> users=position.getUsers();
                for(User user : users){
                    if(loginUser.getId()==user.getId()){
                        canDel=false;
                    }
                }
                if(!canDel) {
                    continue;
View Full Code Here

                }catch(Exception e){
                    e.printStackTrace();
                }
                LOG.info("开始检查web service服务端和客户端是否正常");
                LOG.info("userService.login(\"admin\", \"admin\"): "+userService.login("admin", "admin"));
                User user=userService.getUserInfo("admin", "admin");
                if(user!=null){
                    LOG.info("user.getUsername(): "+user.getUsername());
                    LOG.info("user.getPassword(): "+user.getPassword());
                }
               
                LOG.info("userService.login(\"admin\", \"123456\"): "+userService.login("admin", "123456"));
                user=userService.getUserInfo("admin", "123456");
                if(user!=null){
                    LOG.info("user.getUsername(): "+user.getUsername());
                    LOG.info("user.getPassword(): "+user.getPassword());
                }
               
                LOG.info("userService.login(\"administrator\", \"123456\"): "+userService.login("administrator", "123456"));
                user=userService.getUserInfo("administrator", "123456");
                if(user!=null){
                    LOG.info("user.getUsername(): "+user.getUsername());
                    LOG.info("user.getPassword(): "+user.getPassword());
                }
                LOG.info("检查完毕");
            }
        }.start();
    }
View Full Code Here

    private PasswordEncoder passwordEncoder;
   
    @Override
    public String login(String username, String password) {
        try{
            User user=(User)userDetailsServiceImpl.loadUserByUsername(username);
            password=passwordEncoder.encode(password, user);
            if(password.equals(user.getPassword())){
                return "认证成功";
            }else{
                return "密码不正确";
            }
        }catch(UsernameNotFoundException | DataAccessException e){
View Full Code Here

    }

    @Override
    public User getUserInfo(String username, String password) {
        try{
            User user=(User)userDetailsServiceImpl.loadUserByUsername(username);
            if(user!=null){
                password=passwordEncoder.encode(password, user);
                if(password.equals(user.getPassword())){
                    return user;
                }
            }
        }catch(UsernameNotFoundException | DataAccessException e){
            LOG.info("没有获取到用户信息:"+username);
View Full Code Here

        }
    }
   
    private void before(String type){
        LOG.info("准备记录数据库"+type+"日志");
        User user=UserHolder.getCurrentLoginUser();
        String ip=UserHolder.getCurrentUserLoginIp();
        backupLog=new BackupLog();
        if(user != null){
            backupLog.setUsername(user.getUsername());
        }
        backupLog.setLoginIP(ip);
        try {
            backupLog.setServerIP(InetAddress.getLocalHost().getHostAddress());
        } catch (UnknownHostException e) {
View Full Code Here

        }
    }
   
    private void before(){
        LOG.info("准备记录重建索引日志");
        User user=UserHolder.getCurrentLoginUser();
        String ip=UserHolder.getCurrentUserLoginIp();
        indexLog=new IndexLog();
        if(user != null){
            indexLog.setUsername(user.getUsername());
        }
        indexLog.setLoginIP(ip);
        try {
            indexLog.setServerIP(InetAddress.getLocalHost().getHostAddress());
        } catch (UnknownHostException e) {
View Full Code Here

TOP

Related Classes of org.apdplat.module.security.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.