You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eric Reagan <re...@gmail.com> on 2010/08/09 18:04:52 UTC

Spring Security 3 with Wicket Auth Roles Problem

Hello,
     I tried following
https://cwiki.apache.org/WICKET/spring-security-and-wicket-auth-roles.htmlto
setup spring security 3.0 and wicket auth roles in my application and
I
ran into a few problems that I was wondering if anyone else had seen. I am
currently getting a java.lang.IllegalStateException: bean of type
[org.springframework.security.authentication.AuthenticationManager] not
found. Below is my web.xml, security xml file and a snippet of where the
class is being called. Thanks for the help

[web.xml]
.........
    <context-param>
        <param-name>contextConfigLocation</param-name>

<param-value>classpath:/app-context/springApplicationContext.xml</param-value>
        <param-name>contextConfigLocation</param-name>

<param-value>classpath:/app-context/applicationContext-security.xml</param-value>
    </context-param>
...........

      <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>

[applicationContext-security.xml]
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/security

http://www.springframework.org/schema/security/spring-security-3.0.xsd"
>


    <!-- security -->
    <security:http create-session="never" auto-config="true" >
        <security:remember-me/>
        <security:intercept-url pattern="/**"/>
    </security:http>


    <security:authentication-manager alias="authenticationManager">
        <security:authentication-provider>
            <!--  TODO change this to reference our real user service -->
            <security:user-service>
                <security:user name="admin" password="admin"
                    authorities="ROLE_ADMIN, ROLE_USER" />
                <security:user name="user" password="user"
                    authorities="ROLE_USER" />
            </security:user-service>
        </security:authentication-provider>
    </security:authentication-manager>



    <security:global-method-security secured-annotations="enabled" />
</beans>

[MySession.java]
    @SpringBean
    private AuthenticationManager authenticationManager;

   public MySession()
    {
        super(request);
        injectDependencies();
        ensureDependenciesNotNull();
    }

    private void injectDependencies()
    {
        InjectorHolder.getInjector().inject(this); //When this method is
tried the IllegalStateException error is thrown.
    }

-- 
Eric Reagan

Re: Spring Security 3 with Wicket Auth Roles Problem

Posted by Eric Reagan <re...@gmail.com>.
> I have in my Web Application
>     addComponentInstantiationListener(getSpringInjector());
>
>     protected SpringComponentInjector getSpringInjector()
>     {
>         return new SpringComponentInjector(this);
>
>     }
>
> On Mon, Aug 9, 2010 at 11:16 AM, Martin Grigorov <mg...@apache.org>wrote:
>
>> It seems you need to configure Spring Injector in YourApp#init()
>>
>>
>> On Mon, Aug 9, 2010 at 6:04 PM, Eric Reagan <re...@gmail.com> wrote:
>>
>>> Hello,
>>>     I tried following
>>>
>>> https://cwiki.apache.org/WICKET/spring-security-and-wicket-auth-roles.htmlto
>>> setup spring security 3.0 and wicket auth roles in my application and
>>> I
>>> ran into a few problems that I was wondering if anyone else had seen. I
>>> am
>>> currently getting a java.lang.IllegalStateException: bean of type
>>> [org.springframework.security.authentication.AuthenticationManager] not
>>> found. Below is my web.xml, security xml file and a snippet of where the
>>> class is being called. Thanks for the help
>>>
>>> [web.xml]
>>> .........
>>>    <context-param>
>>>        <param-name>contextConfigLocation</param-name>
>>>
>>>
>>> <param-value>classpath:/app-context/springApplicationContext.xml</param-value>
>>>        <param-name>contextConfigLocation</param-name>
>>>
>>>
>>> <param-value>classpath:/app-context/applicationContext-security.xml</param-value>
>>>    </context-param>
>>> ...........
>>>
>>>      <listener>
>>>
>>>
>>> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>>>      </listener>
>>>
>>> [applicationContext-security.xml]
>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>       xmlns:security="http://www.springframework.org/schema/security"
>>>       xsi:schemaLocation="http://www.springframework.org/schema/beans
>>>
>>> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>>>                           http://www.springframework.org/schema/security
>>>
>>> http://www.springframework.org/schema/security/spring-security-3.0.xsd"
>>> >
>>>
>>>
>>>    <!-- security -->
>>>    <security:http create-session="never" auto-config="true" >
>>>        <security:remember-me/>
>>>        <security:intercept-url pattern="/**"/>
>>>    </security:http>
>>>
>>>
>>>    <security:authentication-manager alias="authenticationManager">
>>>        <security:authentication-provider>
>>>            <!--  TODO change this to reference our real user service -->
>>>            <security:user-service>
>>>                <security:user name="admin" password="admin"
>>>                    authorities="ROLE_ADMIN, ROLE_USER" />
>>>                <security:user name="user" password="user"
>>>                    authorities="ROLE_USER" />
>>>            </security:user-service>
>>>        </security:authentication-provider>
>>>    </security:authentication-manager>
>>>
>>>
>>>
>>>    <security:global-method-security secured-annotations="enabled" />
>>> </beans>
>>>
>>> [MySession.java]
>>>    @SpringBean
>>>    private AuthenticationManager authenticationManager;
>>>
>>>   public MySession()
>>>    {
>>>        super(request);
>>>        injectDependencies();
>>>        ensureDependenciesNotNull();
>>>    }
>>>
>>>    private void injectDependencies()
>>>    {
>>>        InjectorHolder.getInjector().inject(this); //When this method is
>>> tried the IllegalStateException error is thrown.
>>>    }
>>>
>>> --
>>> Eric Reagan
>>>
>>
>>
>
>
> --
> Eric Reagan
>



-- 
Eric Reagan

Re: Spring Security 3 with Wicket Auth Roles Problem

Posted by Martin Grigorov <mg...@apache.org>.
It seems you need to configure Spring Injector in YourApp#init()

On Mon, Aug 9, 2010 at 6:04 PM, Eric Reagan <re...@gmail.com> wrote:

> Hello,
>     I tried following
>
> https://cwiki.apache.org/WICKET/spring-security-and-wicket-auth-roles.htmlto
> setup spring security 3.0 and wicket auth roles in my application and
> I
> ran into a few problems that I was wondering if anyone else had seen. I am
> currently getting a java.lang.IllegalStateException: bean of type
> [org.springframework.security.authentication.AuthenticationManager] not
> found. Below is my web.xml, security xml file and a snippet of where the
> class is being called. Thanks for the help
>
> [web.xml]
> .........
>    <context-param>
>        <param-name>contextConfigLocation</param-name>
>
>
> <param-value>classpath:/app-context/springApplicationContext.xml</param-value>
>        <param-name>contextConfigLocation</param-name>
>
>
> <param-value>classpath:/app-context/applicationContext-security.xml</param-value>
>    </context-param>
> ...........
>
>      <listener>
>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>      </listener>
>
> [applicationContext-security.xml]
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xmlns:security="http://www.springframework.org/schema/security"
>       xsi:schemaLocation="http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>                           http://www.springframework.org/schema/security
>
> http://www.springframework.org/schema/security/spring-security-3.0.xsd"
> >
>
>
>    <!-- security -->
>    <security:http create-session="never" auto-config="true" >
>        <security:remember-me/>
>        <security:intercept-url pattern="/**"/>
>    </security:http>
>
>
>    <security:authentication-manager alias="authenticationManager">
>        <security:authentication-provider>
>            <!--  TODO change this to reference our real user service -->
>            <security:user-service>
>                <security:user name="admin" password="admin"
>                    authorities="ROLE_ADMIN, ROLE_USER" />
>                <security:user name="user" password="user"
>                    authorities="ROLE_USER" />
>            </security:user-service>
>        </security:authentication-provider>
>    </security:authentication-manager>
>
>
>
>    <security:global-method-security secured-annotations="enabled" />
> </beans>
>
> [MySession.java]
>    @SpringBean
>    private AuthenticationManager authenticationManager;
>
>   public MySession()
>    {
>        super(request);
>        injectDependencies();
>        ensureDependenciesNotNull();
>    }
>
>    private void injectDependencies()
>    {
>        InjectorHolder.getInjector().inject(this); //When this method is
> tried the IllegalStateException error is thrown.
>    }
>
> --
> Eric Reagan
>