shiro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SimeĆ³ Reig <>
Subject rememberMe not working after creating own realm
Date Wed, 22 Feb 2017 19:16:44 GMT
Hello All 

  We had a shiro web JSF app working smoothless, but we need to have an
own Realm, therefore we extended AuthorizingRealm. The system works but
now rememberMe function does not work, shiro does not create the cookie.

Must we implement rememberMe function too if we implemented our Realm??

Many thanks in advance 


Our custom realm 


public class myRealm extends AuthorizingRealm {

    protected AuthorizationInfo
doGetAuthorizationInfo(PrincipalCollection principals) {
        Set<String> roles = new HashSet<>();
        Collection<User> principalsList = principals.byType(User.class);

        if (principalsList.isEmpty())  throw new
AuthorizationException("Empty principals list!");

        for (User userPrincipal : principalsList) {
            try {
                User user = new
                List<Role> userRoles = user.getRoles();
                for (Role r : userRoles) {roles.add(r.getName());
            } catch (Exception rEx) {
                throw new AuthorizationException(rEx);

        SimpleAuthorizationInfo info = new
        info.setRoles(roles); //fill in roles 
        return info;

    protected AuthenticationInfo
doGetAuthenticationInfo(AuthenticationToken token) throws
AuthenticationException {

        UsernamePasswordToken upToken = (UsernamePasswordToken) token;

        System.out.println("isRememberMe Activated ===> " +

        User user = new User(1,upToken.getUsername(),"password");

        if (user == null) {throw new AuthenticationException("Login name
[" + upToken.getUsername() + "] not found!");}

        return new SimpleAuthenticationInfo(user, user.getPassword(),
ByteSource.Util.bytes(user.getSalt()), getName());





authc.loginUrl = /faces/login.xhtml
user.loginUrl = /faces/login.xhtml

adronicaRealm = com.adronica.shirofaces.myRealm

authc = org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter = shiroTest
securityManager.realms = $adronicaRealm

/faces/admin/protected.xhtml = user,roles[admin]












View raw message