0

ZK + Hibernate + Spring Security Login

asked 2012-11-17 08:06:00 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Is there any step by step tutorial available for ZK + Hibernate + Spring Security Login

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2014-01-20 18:20:16 +0800

gyowanny gravatar image gyowanny
283 1 2 6

updated 2014-01-20 18:30:14 +0800

Like this or this ?

In order to use Hibernate to retrieve and validate the user, you may want to implement the org.springframework.security.authentication.AuthenticationProvider interface.

E.g.:

@Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        Authentication auth = null;
        String login = authentication.getName();
        String password = authentication.getCredentials().toString();
        MyUser user = myHibernateSession.findByLogin();
        ....
        if (user == null || !MyPasswordChecker.passwordMatches(user, password)){
             return null;
        }else{
             List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>();
             grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER"));
             return new Authentication(user, null, grantedAuths);
        }
   }

PS: The code above is super simple and it's purpose is just to clarify how to implement a custom spring security authenticator.

I hope this help.

Gyo

link publish delete flag offensive edit

answered 2014-01-21 00:11:58 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Thank you. But it is very old question of mine. After , i created several examples and you can check here

link publish delete flag offensive edit

answered 2014-01-22 12:39:31 +0800

gyowanny gravatar image gyowanny
283 1 2 6

Then you could have this question updated with that answer right after figuring it out.

link publish delete flag offensive edit

answered 2015-09-11 00:48:53 +0800

CodeLover gravatar image CodeLover
1

Hello, may be this thread is old, but I face some problem here.

I do my code using ZK Spring Core 3.1.1, ZK Spring Security 3.1.1 and finally ZK EE 7.0.6.1.

I've been looking for same question, but didn't find what I looking for.

Then I found this forum, like gywanny answered above, we can implement this class: org.springframework.security.authentication.AuthenticationProvider.

But, I don't find that mentioned class.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-11-17 08:06:00 +0800

Seen: 156 times

Last updated: Sep 11 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More