Thanks for your time Rob, in the end I get an entity manager inside my realm to connect with my JPA model. Maybe it wasn't the best solution but I'm not seeing any drawback on it. And exact, this is the problem: Shiro knows nothing about CDI,that was the problem
Thanks again! Simeó Reig A 10-12-2017 15:35, Rob Young escrigué: > Hi Simeo, > > I (finally!) took a look at this, sorry for the delay. I've never got > injection working in an authorizing realm. In our JSF/Shiro/JPA web > application, I had to write an authorizing realm for shiro. What we ended up > doing was using JNDI to retrieve a basic JDBC connection from the container, > and do a basic query on user attributes with it. > > I could be mistaken, but I don't think that shiro core knows anything about > CDI, and isn't managed by WELD. (If I am incorrect, I would love to be > corrected!) :) > > We had some fun getting the JNDI connection set up correctly in glassfish - > it's all wrapped up in a docker container. > > Here's a gist with some pseudo-java for what I'm talking about. > https://gist.github.com/bobbotron/c1d2282069a57b2b5b58541b6540de33 > > On Fri, Dec 1, 2017 at 11:42 AM, Simeó Reig <simeo.r...@grupoincofisa.com> > wrote: > > Hi Brian, > > The real application should collect users from JPA, but I made this version > without JPA and I simply inject a CDI that has info hardcoded on it, to do as > simple as possible: > > public class JpaRealm EXTENDS AUTHORIZINGREALM { > > @Inject > private BEANLOGIN myBeanLogin; > > .. > > } > > public class BEANLOGIN implements Serializable { > > public User returnUserInfo(String userName) { > > User user; Role roleAdmin; > > roleAdmin = new Role("Role_Admin"); > roleAdmin.addPermission("all"); > > user = new User(1, userName, "foobar", "Foo company"); > user.addRol(roleAdmin); > > return user; > > } > > } > > I don't have a mock version of non CDI system but I could do it in a few > hours. > > Thanks again > > A 01-12-2017 15:04, Brian Demers escrigué: > > I just took a quick look, so I very well might have missed something. but > where are you dealing with the user's password? > > You mentioned you have a non-CDI version that works? can you point us to that > too? > > On Fri, Dec 1, 2017 at 8:21 AM, Simeó Reig <simeo.r...@grupoincofisa.com> > wrote: > > Hi all, > > has anybody been able to take a look on it? It's a minimal maven JSF2 project > to use CDI on authentification under shiro but I wasn't be able to make it > work. CDI is working fine but SimpleAuthenticationInfo it's always raising > up IncorrectCredentialsException despite credentials are Ok > > https://github.com/simeoreig/shiro-JPA [1] > > Thanks again > > Simeó Reig > > A 29-11-2017 10:52, Simeó Reig escrigué: > > Thanks a lot! > > A 29-11-2017 05:01, Rob Young escrigué: > > Hi Simeo, > > I'm swamped with work but could take a look in a few days, sounds like you're > close! > > On Tuesday, November 28, 2017, Simeó Reig <simeo.r...@grupoincofisa.com> > wrote: > > Hi > > If someone can review it, I've just uploaded a minimal maven JSF 2 project on > https://github.com/simeoreig/shiro-JPA [1] > > CDI Injection is working but now SimpleAuthenticationInfo it's always raising > up IncorrectCredentialsException despite credentials are Ok (without JPA is > working well) > > Just test with user john, pass foobar > > Thanks a lot > > Simeó Reig > > A 28-11-2017 22:00, Simeó Reig escrigué: > > Thanks Brian I'm going to recheck it > > A 28-11-2017 20:31, Brian Demers escrigué: > Are you sure you are injecting all of your components correctly? Sounds like > that might be the issue > > On Tue, Nov 28, 2017 at 1:37 PM, Simeó Reig <simeo.r...@grupoincofisa.com> > wrote: > > Dear alls, > > Is it possible to use a Inject a DAO reference inside a class extending > AuthorizingRealm ? > > I've followed > https://stackoverflow.com/questions/15605038/unable-to-inject-my-dao-in-a-custom-apache-shiro-authorizingrealm > [2] without success. JPA injection works but SimpleAuthenticationInfo in > doGetAuthenticationInfo method always return ' token > [org.apache.shiro.authc.UsernamePasswordToken - john,rememberMe=false] did > not match the expected credentials" > > Shiro 1.3.2 in a JSF application, shiro works without JPA as expected > > Thanks > > Simeó Reig -- Rob Young robertjohnyo...@gmail.com -- Rob Young robertjohnyo...@gmail.com Links: ------ [1] https://github.com/simeoreig/shiro-JPA [2] https://stackoverflow.com/questions/15605038/unable-to-inject-my-dao-in-a-custom-apache-shiro-authorizingrealm