Package com.github.zhangkaitao.shiro.chapter18.entity

Examples of com.github.zhangkaitao.shiro.chapter18.entity.User


        return token instanceof UsernamePasswordToken;
    }

    @Override
    public AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        User user = new User("zhang", "123");
        return new SimpleAuthenticationInfo(
                user, //身份 User类型
                "123",   //凭据
                getName() //Realm Name
        );
View Full Code Here


    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

        String username = (String)token.getPrincipal();

        User user = userService.findByUsername(username);

        if(user == null) {
            throw new UnknownAccountException();//没找到帐号
        }

        if(Boolean.TRUE.equals(user.getLocked())) {
            throw new LockedAccountException(); //帐号锁定
        }

        //交给AuthenticatingRealm使用CredentialsMatcher进行密码匹配,如果觉得人家的不好可以自定义实现
        SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
                user.getUsername(), //用户名
                user.getPassword(), //密码
                ByteSource.Util.bytes(user.getCredentialsSalt()),//salt=username+salt
                getName()  //realm name
        );
        return authenticationInfo;
    }
View Full Code Here

        roleService.correlationPermissions(r2.getId(), p1.getId());
        roleService.correlationPermissions(r2.getId(), p2.getId());

        //4、新增用户
        u1 = new User("zhang", password);
        u2 = new User("li", password);
        u3 = new User("wu", password);
        u4 = new User("wang", password);
        u4.setLocked(Boolean.TRUE);
        userService.createUser(u1);
        userService.createUser(u2);
        userService.createUser(u3);
        userService.createUser(u4);
View Full Code Here

    public Callable<Object> callable3() {
        return new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                Thread.sleep(2L * 1000); //暂停两秒
                return new User(1, "zhang");
            }
        };
    }
View Full Code Here

        PreparedQuery pq = ds.prepare(query);
        List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(number).offset(offset));
        List<User> ret = new ArrayList<User>();
        for(Entity e: results)
        {
            ret.add(new User(e));
        }
        //System.out.println("Have " + ret.size());
        return ret;
    }
View Full Code Here

      
        // Get request parameters
        String userEmail = request.getParameter("email");
        String userPassword = request.getParameter("password");
        String result = "";
        User user = null;
       
        UserJpaController jpaController = new UserJpaController();
        user = jpaController.loginUser(userEmail, userPassword);
       
        if(user != null) {
            result = "login_successful";
        }
       
        try {
            // Login successful
            if (result.equals("login_successful")) {
                out.println(user.getId().toString());
                System.out.println("login success");
            }
            // Login failed
            else {
                out.print("-1");
View Full Code Here

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
       
        Integer userID;
        userID = Integer.valueOf(request.getParameter("userID"));
        User user = new User(userID);
       
        Integer courseID;
        courseID = Integer.valueOf(request.getParameter("courseID"));
        Courses course = new Courses(courseID);
       
View Full Code Here

    public User getUser() {
        if(user == null) {
            user = (User)JsfUtil.getObjectFromRequestParameter("jsfcrud.currentUser", converter, null);
        }
        if(user == null) {
            user = new User();
        }
        return user;
    }
View Full Code Here

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value == null) {
            return null;
        }
        if (value instanceof User) {
            User o = (User) value;
            return o.getId() == null ? "" : o.getId().toString();
        } else {
            throw new IllegalArgumentException("object " + value + " is of type " + value.getClass().getName() + "; expected type: entity.User");
        }
    }   
View Full Code Here

    private static final String PERSISTENCEUNITNAME = "EducationXPU";
    private EntityManagerFactory emf;
    private EntityManager em;
   
    public UserTest() throws ParseException {
        this.s1 = new User("anakin", "anakin@skywalker.net", "24ewRTtr", 'S', 500, new SimpleDateFormat("MM/dd/yy").parse("05/18/05"));
        this.s2 = new User("luke", "luke@skywalker.net", "42eeRTew", 'S', 250, new SimpleDateFormat("MM/dd/yy").parse("05/18/05"));
    }
View Full Code Here

TOP

Related Classes of com.github.zhangkaitao.shiro.chapter18.entity.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.