You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Thorsten Scherler <th...@apache.org> on 2011/10/26 14:00:42 UTC
Spring TextConfigurationRealm problems
Hi all,
I followed http://shiro.apache.org/spring.html to integrate Shiro into
Apache Cocoon3.
Basically the filterChainDefinitions are working fine since I get redirected
to the login page when I try to request a secure page.
However I am having problem with the realm it seems. I have
<bean id="myRealm"
class="org.apache.shiro.realm.text.TextConfigurationRealm">
<property name="userDefinitions">
<value>
thor = test, admin
x = x, user
</value>
</property>
<property name="roleDefinitions">
<value>
admin = *
user = user:*
</value>
</property>
</bean>
Then in my c3 login REST service I do
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
Subject subject = SecurityUtils.getSubject();
subject.login(token);
However the login never works I always get
2011-10-26 13:23:12,880 btpool0-1 ERROR servlet.XMLSitemapServlet - Cocoon
can't process the request.
org.apache.cocoon.sitemap.InvocationException:
org.apache.shiro.authc.UnknownAccountException: Realm
[org.apache.shiro.realm.text.TextConfigurationRealm@79414306] was unable to
find account data for the submitted AuthenticationToken
[org.apache.shiro.authc.UsernamePasswordToken - thor, rememberMe=false].
If I debug the service I find that
org.apache.shiro.realm.text.TextConfigurationRealm has in rolesDefinition
"\n admin = *\n user = user:*\n "
and userDefinition
"\n thor = test, admin\n x = x, user\n "
BUT both users and roles maps are empty.
I just started to use Shiro and would be very grateful if somebody can give
me a hint what I am doing wrong.
TIA for any feedback
--
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-TextConfigurationRealm-problems-tp6932391p6932391.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Spring TextConfigurationRealm problems
Posted by Thorsten Scherler <th...@apache.org>.
ups it was too late last night, I saw I added a reference. Basically it is
the same as it comes in the docu.
Thanks.
# =======================
# Shiro INI configuration
# =======================
[main]
# Objects and their properties are defined here,
# Such as the securityManager, Realms and anything
# else needed to build the SecurityManager
[users]
# The 'users' section is for simple deployments
# when you only need a small number of statically-defined
# set of User accounts.
thor = xxx, admin
x = x, user
[roles]
# The 'roles' section is for simple deployments
# when you only need a small number of statically-defined
# roles.
admin = *
user = user:*
[urls]
# The 'urls' section is used for url-based security
# in web applications. We'll discuss this section in the
# Web documentation
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-TextConfigurationRealm-problems-tp6932391p6935440.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Spring TextConfigurationRealm problems
Posted by Manoj Khangaonkar <kh...@gmail.com>.
Hi Thor,
Can you paste your ini file here ?
thanks
On Wed, Oct 26, 2011 at 4:54 PM, Thorsten Scherler <th...@apache.org> wrote:
> Ok I did not used a shiro.ini file, however I created one and tried with
> <bean id="myRealm" class="org.apache.shiro.realm.text.IniRealm">
> <property name="resourcePath" value="classpath:META-INF/shiro.ini"/>
> </bean>
>
> I now can see by debugging that the resourcePath is correctly set but it
> seems that it is not parsed since both users and rules are empty.
>
> Can it be that I need to call onInit() myself?
>
> Thanks for your hint some more thoughts?
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-TextConfigurationRealm-problems-tp6932391p6934694.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>
--
http://khangaonkar.blogspot.com/
Re: Spring TextConfigurationRealm problems
Posted by Thorsten Scherler <th...@apache.org>.
<bean id="myRealm" class="org.apache.shiro.realm.text.IniRealm">
<constructor-arg value="classpath:META-INF/shiro.ini"
type="java.lang.String"/>
</bean>
As I thought the prior never got init(). Now I have it working.
Cheers. :)
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-TextConfigurationRealm-problems-tp6932391p6935713.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Spring TextConfigurationRealm problems
Posted by Thorsten Scherler <th...@apache.org>.
Ok I did not used a shiro.ini file, however I created one and tried with
<bean id="myRealm" class="org.apache.shiro.realm.text.IniRealm">
<property name="resourcePath" value="classpath:META-INF/shiro.ini"/>
</bean>
I now can see by debugging that the resourcePath is correctly set but it
seems that it is not parsed since both users and rules are empty.
Can it be that I need to call onInit() myself?
Thanks for your hint some more thoughts?
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-TextConfigurationRealm-problems-tp6932391p6934694.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Spring TextConfigurationRealm problems
Posted by Manoj Khangaonkar <kh...@gmail.com>.
Hi Thor,
If you are using the standard shiro.ini file to specify users, roles then use
org.apache.shiro.text.IniRealm as the Realm.
IniRealm is the default. I don'nt think it even needs to be specified.
See the shiro web Sample.
If your ini format is different, then I suspect the file is not being
parsed correctly.
Manoj
On Wed, Oct 26, 2011 at 5:00 AM, Thorsten Scherler <th...@apache.org> wrote:
> Hi all,
>
> I followed http://shiro.apache.org/spring.html to integrate Shiro into
> Apache Cocoon3.
>
> Basically the filterChainDefinitions are working fine since I get redirected
> to the login page when I try to request a secure page.
>
> However I am having problem with the realm it seems. I have
>
> <bean id="myRealm"
> class="org.apache.shiro.realm.text.TextConfigurationRealm">
> <property name="userDefinitions">
> <value>
> thor = test, admin
> x = x, user
> </value>
> </property>
> <property name="roleDefinitions">
> <value>
> admin = *
> user = user:*
> </value>
> </property>
> </bean>
>
> Then in my c3 login REST service I do
>
> UsernamePasswordToken token = new UsernamePasswordToken(username, password);
> Subject subject = SecurityUtils.getSubject();
> subject.login(token);
>
> However the login never works I always get
> 2011-10-26 13:23:12,880 btpool0-1 ERROR servlet.XMLSitemapServlet - Cocoon
> can't process the request.
> org.apache.cocoon.sitemap.InvocationException:
> org.apache.shiro.authc.UnknownAccountException: Realm
> [org.apache.shiro.realm.text.TextConfigurationRealm@79414306] was unable to
> find account data for the submitted AuthenticationToken
> [org.apache.shiro.authc.UsernamePasswordToken - thor, rememberMe=false].
>
> If I debug the service I find that
> org.apache.shiro.realm.text.TextConfigurationRealm has in rolesDefinition
> "\n admin = *\n user = user:*\n "
> and userDefinition
> "\n thor = test, admin\n x = x, user\n "
>
> BUT both users and roles maps are empty.
>
> I just started to use Shiro and would be very grateful if somebody can give
> me a hint what I am doing wrong.
>
> TIA for any feedback
>
> --
> Thorsten Scherler <thorsten.at.apache.org>
> codeBusters S.L. - web based systems
> <consulting, training and solutions>
> http://www.codebusters.es/
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-TextConfigurationRealm-problems-tp6932391p6932391.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>
--
http://khangaonkar.blogspot.com/