Hi,I try to integrate shiro into my application. ( JSP + Servlet + EJB3 +
JPA).This is my code 
*shiro.ini :*
[main] 

authc= cismaa.ssae.supervision.ihm.security.VerboseFormAuthenticationFilter
authc.loginUrl = /loginservlet
# name of request parameter with username; if not present filter assumes
'username'
authc.usernameParam = login
# name of request parameter with password; if not present filter assumes
'password' 
authc.passwordParam = password
authc.rememberMeParam = rememberMe
# redirect after successful login
 #authc.successUrl  = /menuficheservlet
JPARealm = cismaa.ssae.supervision.ihm.security.JPARealm
# any object property is automatically configurable in Shiro.ini file 
JPARealm.jndiDataSourceName = UtilisateurService
sha1Matcher = org.apache.shiro.authc.credential.Sha1CredentialsMatcher
JPARealm.credentialsMatcher = $sha1Matcher
securityManager.realms = $JPARealm

[urls]
/loginservlet = authc
/layout/unicorn/resources/** = anon
/** = authc
*JPARealm :*
public class JPARealm extends AuthenticatingRealm {

        @EJB
        private IUtilisateurService users;
        private Utilisateur util;


        public JPARealm() { 
                super();  
                System.out.println("JPARealm()");
        }  

        protected String jndiDataSourceName;

        public String getJndiDataSourceName() { 
                return jndiDataSourceName; 
        } 

                @Override
        public boolean supports(AuthenticationToken token) {
                System.out.println("TOTO");
                boolean response = super.supports(token);
                return response;
        }

        public void setJndiDataSourceName(String jndiDataSourceName) {
                this.jndiDataSourceName = jndiDataSourceName;
                this.users = getDataSourceFromJNDI(jndiDataSourceName);
        }

        private IUtilisateurService getDataSourceFromJNDI(String
jndiDataSourceName) {
                try {
                        InitialContext ic = new InitialContext();
                        return (IUtilisateurService) 
ic.lookup(jndiDataSourceName);
                } catch (NamingException e) {
                        throw new AuthorizationException(e);
                }
        }

        private String getPasswordForUser(String email) throws
AuthenticationException {  
                util = users.findbyEmail(email);
                if(util == null) {
                        throw new AuthenticationException("Utilisateur " + 
email + "
introuvable");
                }
                return util.getMotDePasseUtilisateur();
        }  

        @Override
        protected AuthenticationInfo doGetAuthenticationInfo(                   
AuthenticationToken
token) throws AuthenticationException {
                UsernamePasswordToken upToken = (UsernamePasswordToken) token;  
                String email = upToken.getUsername();
                // Null username is invalid  
                if (email == null) {  
                        throw new AccountException("Null usernames are not 
allowed by this
realm.");  
                }
                String password = getPasswordForUser(email); 
                if (password == null) {  
                        throw new UnknownAccountException("No account found for 
user [" + email +
"]");  
                }  
                return new SimpleAuthenticationInfo(email, password, getName());
        }

}
With this, all urls redirects to /loginservlet as expected but when i try to
connect by validating the form, nothing happen, the login form just reloads
itself. The Logs are empty. The Web.xml is correctly configure. I can see
shiro the logs at startup.



--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/Can-connect-with-Shiro-Silent-fail-tp7579898.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to