You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by jleleu <le...@gmail.com> on 2012/06/21 20:14:33 UTC
Re: TextConfigurationRealm question
Hi,
You're right, you don't need an .ini file, you can do everything
programmatically.
In your case, you need to call the init() method to make things work :
/ TextConfigurationRealm realm = new TextConfigurationRealm();
realm.setUserDefinitions("root = secret, admin");
realm.setRoleDefinitions("admin = *");
*realm.init();*
DefaultSecurityManager securityManager = new
DefaultSecurityManager(realm);
SecurityUtils.setSecurityManager(securityManager);
Subject currentUser = SecurityUtils.getSubject();
if (!currentUser.isAuthenticated()) {
UsernamePasswordToken token = new UsernamePasswordToken("root",
"secret");
currentUser.login(token);
}/
Best regards,
Jérôme
--
View this message in context: http://shiro-user.582556.n2.nabble.com/TextConfigurationRealm-question-tp7577498p7577536.html
Sent from the Shiro User mailing list archive at Nabble.com.