You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ChandraB <b_...@yahoo.com> on 2009/04/21 22:39:41 UTC

Error while launching Login page

Service id 'authenticationProvider' is not defined by any module


My appModule.java is as below 

public class AppModule
{
    public static void bind(ServiceBinder binder)
    {
       
    
binder.bind(com.eveo.edetail.reporting.service.UserDetailsService.class,
UserDetailsServiceImpl.class).withId("UserDetailsServiceImpl");
    	binder.bind(SaltSourceService.class,
SaltSourceImpl.class).withId("SaltSourceImpl");

    }
    public static SaltSourceService buildMySaltSource() throws Exception {
        SaltSourceImpl saltSource = new SaltSourceImpl();
        saltSource.setSystemWideSalt("DEADBEEF");
        saltSource.afterPropertiesSet();
        return saltSource;
    }
    
    public static UserDetailsService buildUserDetailsService(UserDao
userDao) {
        return new
com.eveo.edetail.reporting.service.impl.UserDetailsServiceImpl(userDao);
    }
   
   public static void contributeProviderManager(
            OrderedConfiguration<AuthenticationProvider> configuration,
            @InjectService("DaoAuthenticationProvider")
            AuthenticationProvider daoAuthenticationProvider) {
	   
	   
	   
	   	System.out.println("AppModule: contributeProviderManager" +
configuration); 	   
	   	System.out.println("-------->>"+daoAuthenticationProvider);	   
        configuration.add("daoAuthenticationProvider",
daoAuthenticationProvider);
        
        
    }
    public static AuthenticationProcessingFilter
buildMyAuthenticationProcessingFilter(
            @AcegiServices final AuthenticationManager manager,
            @AcegiServices final RememberMeServices rememberMeServices,
            @Inject @Value("${acegi.check.url}") final String authUrl,
            @Inject @Value("${acegi.target.url}") final String targetUrl,
            @Inject @Value("${acegi.failure.url}") final String failureUrl)
    															throws Exception {
    	
    	
    	System.out.println("Auth URL"+ authUrl );
	    AuthenticationProcessingFilter filter = new
AuthenticationProcessingFilter();
	    filter.setAuthenticationManager(manager);
	    filter.setAuthenticationFailureUrl(failureUrl);
	    filter.setDefaultTargetUrl(targetUrl);
	    filter.setFilterProcessesUrl(authUrl);
	    filter.setRememberMeServices(rememberMeServices);
	    filter.afterPropertiesSet();
	    return filter;
	}

	public static void contributeAliasOverrides(
	            @InjectService("MySaltSource")
	            SaltSourceService saltSource,
	            @InjectService("MyAuthenticationProcessingFilter")
	            AuthenticationProcessingFilter authenticationProcessingFilter,
	            Configuration<AliasContribution> configuration) {
		
	  	System.out.println("AppModule: contributeAliasOverrides" +
configuration); 	   
	   
configuration.add(AliasContribution.create(SaltSourceService.class,saltSource));
	   
configuration.add(AliasContribution.create(AuthenticationProcessingFilter.class,authenticationProcessingFilter));
	} 
	
	
    public static LoginHelper
buildLoginHelper(@InjectService("MySaltSource") SaltSourceService
    					saltSource, PasswordEncoder encrypter , AuthenticationManager
authManager) {
            return new AcegiLoginHelper(authManager,saltSource,encrypter);
    	//return new AcegiLoginHelper(authManager);
    } 
    
    
    public static void
contributeApplicationDefaults(MappedConfiguration<String, String>
configuration){      
        configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
        configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
        configuration.add("acegi.failure.url", "/error");
        configuration.add("acegi.password.encoder",
"org.acegisecurity.providers.encoding.PlaintextPasswordEncoder");
        configuration.add("acegi.target.url", "/Program");        
    }
    

    /**
     * This is a service definition, the service will be named
"TimingFilter". The interface,
     * RequestFilter, is used within the RequestHandler service pipeline,
which is built from the
     * RequestHandler service configuration. Tapestry IoC is responsible for
passing in an
     * appropriate Logger instance. Requests for static resources are
handled at a higher level, so
     * this filter will only be invoked for Tapestry related requests.
     * 
     * <p>
     * Service builder methods are useful when the implementation is inline
as an inner class
     * (as here) or require some other kind of special initialization. In
most cases,
     * use the static bind() method instead. 
     * 
     * <p>
     * If this method was named "build", then the service id would be taken
from the 
     * service interface and would be "RequestFilter".  Since Tapestry
already defines
     * a service named "RequestFilter" we use an explicit service id that we
can reference
     * inside the contribution method.
     */    
    public RequestFilter buildTimingFilter(final Logger log)
    {
        return new RequestFilter()
        {
            public boolean service(Request request, Response response,
RequestHandler handler)
                    throws IOException
            {
                long startTime = System.currentTimeMillis();

                try
                {
                    // The responsibility of a filter is to invoke the
corresponding method
                    // in the handler. When you chain multiple filters
together, each filter
                    // received a handler that is a bridge to the next
filter.
                    
                    return handler.service(request, response);
                }
                finally
                {
                    long elapsed = System.currentTimeMillis() - startTime;

                    log.info(String.format("Request time: %d ms", elapsed));
                }
            }
        };
    }
    
   
-- 
View this message in context: http://www.nabble.com/Error-while-launching-Login-page-tp23164519p23164519.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Error while launching Login page

Posted by Otho <ta...@googlemail.com>.
You just set up your security context as usual with spring. Define the beans
you need for userDetailsService (or other authenticationProvider),
saltSource, encoder, rememberMe etc. and fire up the spring security
namespace config. This is described in great detail in the Spring security
docs as well as database table setup.

A simple example with hierarchical roles in one hierarchy and remember me
services  might look like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:s="http://www.springframework.org/schema/security"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/util
       http://www.springframework.org/schema/util/spring-util-2.5.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
       http://www.springframework.org/schema/security

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


    <!-- Security Helper -->
    <bean id="userDetailsService" class="org.foo.dao.impl.SecurityDaoImpl"/>

    <bean id="passwordEncoder"
class="org.springframework.security.providers.encoding.ShaPasswordEncoder">
        <property name="encodeHashAsBase64" value="true"/>
    </bean>

    <bean id="saltSource"

class="org.springframework.security.providers.dao.salt.SystemWideSaltSource">
        <property name="systemWideSalt" value="${system.salt}"/>
    </bean>

    <bean id="rememberMeProcessingFilter"

class="org.springframework.security.ui.rememberme.RememberMeProcessingFilter">
        <property name="rememberMeServices" ref="rememberMeServices"/>
        <property name="authenticationManager" ref="authenticationManager"/>
    </bean>

    <bean id="rememberMeServices"

class="org.springframework.security.ui.rememberme.TokenBasedRememberMeServices">
        <property name="userDetailsService" ref="userDetailsService"/>
        <property name="key" value="foo.org"/>
    </bean>

    <bean id="rememberMeAuthenticationProvider"

class="org.springframework.security.providers.rememberme.RememberMeAuthenticationProvider">
        <property name="key" value="foo.org"/>
    </bean>

    <s:http access-decision-manager-ref="accessDecisionManager">
        <s:intercept-url pattern="/login*" filters="none"/>
        <s:intercept-url pattern="/**" access="ROLE_USER"/>
        <s:form-login login-page="/login" default-target-url="/index"/>
        <s:anonymous username="Anonymous"
granted-authority="ROLE_ANONYMOUS"/>
        <s:http-basic/>
        <s:logout invalidate-session="true" logout-success-url="/index"/>
        <s:concurrent-session-control max-sessions="1"/>
    </s:http>

    <!-- Role hierarchy -->
    <bean id="roleHierarchy"
class="org.springframework.security.userdetails.hierarchicalroles.RoleHierarchyImpl">
        <property name="hierarchy">
            <value>
                ROLE_ADMIN > ROLE_MANAGER
                ROLE_MANAGER > ROLE_EDITOR
                ROLE_EDITOR > ROLE_AUTHOR
                ROLE_AUTHOR > ROLE_USER
                ROLE_USER > ROLE_ANONYMOUS
            </value>
        </property>
    </bean>

    <bean id="roleHierarchyVoter"
class="org.springframework.security.vote.RoleHierarchyVoter">
        <constructor-arg ref="roleHierarchy"/>
    </bean>

    <bean id="accessDecisionManager"
          class="org.springframework.security.vote.UnanimousBased">
        <property name="decisionVoters">
            <list>
                <ref local="roleHierarchyVoter"/>
            </list>
        </property>
    </bean>

    <s:authentication-provider user-service-ref="userDetailsService">
        <s:password-encoder ref="passwordEncoder">
            <s:salt-source system-wide="${system.salt}"/>
        </s:password-encoder>
    </s:authentication-provider>

    <s:authentication-manager alias="authenticationManager"/>
</beans>

You need the passwordEncoder and saltSource beans mainly for encoding the
clear text passwords entered on registering a new user or when setting new
passwords.

Now you only have to use the Tapestry-Spring integration and it works. The
only minor problem - depending on your app - is the login and logout
handling. You can make a form around the cookie cutter Spring security hooks
or dice your own. You can find examples here on the mailinglist.

2009/4/22 Borut Bolčina <bo...@gmail.com>

> Can you give an example?
>
> -Borut
>

Re: Error while launching Login page

Posted by Borut Bolčina <bo...@gmail.com>.
Can you give an example?

-Borut

2009/4/22 Otho <ta...@googlemail.com>:
> It is also straightforward to configure Spring Secuity as usual (aka in
> Spring config), if you should need features which are not yet in the spring
> security module or should use spring data access abstractions anyways.
>
>
> 2009/4/21 Borut Bolčina <bo...@gmail.com>
>
>> Hi,
>>
>> did you have a look at
>> http://www.localhost.nu/java/tapestry-spring-security/?
>>
>> There is also a sample application to download at
>> http://www.localhost.nu/svn/public/tapestry-spring-security-sample/
>>
>> HTH,
>> Borut
>>
>> 2009/4/21 ChandraB <b_...@yahoo.com>:
>> >
>> >
>> > I am a newbie to tapestry, i am getting NullPointerException when i
>> access
>> > authManager.
>> > How do i inject AuthManager?
>> >
>> > Chandra
>> >
>> >
>> >
>> > ChandraB wrote:
>> >>
>> >> Service id 'authenticationProvider' is not defined by any module
>> >>
>> >>
>> >> My appModule.java is as below
>> >>
>> >> public class AppModule
>> >> {
>> >>     public static void bind(ServiceBinder binder)
>> >>     {
>> >>
>> >>
>> >> binder.bind(com.eveo.edetail.reporting.service.UserDetailsService.class,
>> >> UserDetailsServiceImpl.class).withId("UserDetailsServiceImpl");
>> >>       binder.bind(SaltSourceService.class,
>> >> SaltSourceImpl.class).withId("SaltSourceImpl");
>> >>
>> >>     }
>> >>     public static SaltSourceService buildMySaltSource() throws Exception
>> {
>> >>         SaltSourceImpl saltSource = new SaltSourceImpl();
>> >>         saltSource.setSystemWideSalt("DEADBEEF");
>> >>         saltSource.afterPropertiesSet();
>> >>         return saltSource;
>> >>     }
>> >>
>> >>     public static UserDetailsService buildUserDetailsService(UserDao
>> >> userDao) {
>> >>         return new
>> >> com.eveo.edetail.reporting.service.impl.UserDetailsServiceImpl(userDao);
>> >>     }
>> >>
>> >>    public static void contributeProviderManager(
>> >>             OrderedConfiguration<AuthenticationProvider> configuration,
>> >>             @InjectService("DaoAuthenticationProvider")
>> >>             AuthenticationProvider daoAuthenticationProvider) {
>> >>
>> >>
>> >>
>> >>               System.out.println("AppModule: contributeProviderManager"
>> +
>> >> configuration);
>> >>
>> System.out.println("-------->>"+daoAuthenticationProvider);
>> >>         configuration.add("daoAuthenticationProvider",
>> >> daoAuthenticationProvider);
>> >>
>> >>
>> >>     }
>> >>     public static AuthenticationProcessingFilter
>> >> buildMyAuthenticationProcessingFilter(
>> >>             @AcegiServices final AuthenticationManager manager,
>> >>             @AcegiServices final RememberMeServices rememberMeServices,
>> >>             @Inject @Value("${acegi.check.url}") final String authUrl,
>> >>             @Inject @Value("${acegi.target.url}") final String
>> targetUrl,
>> >>             @Inject @Value("${acegi.failure.url}") final String
>> >> failureUrl)
>> >>
>>                                               throws Exception {
>> >>
>> >>
>> >>       System.out.println("Auth URL"+ authUrl );
>> >>           AuthenticationProcessingFilter filter = new
>> >> AuthenticationProcessingFilter();
>> >>           filter.setAuthenticationManager(manager);
>> >>           filter.setAuthenticationFailureUrl(failureUrl);
>> >>           filter.setDefaultTargetUrl(targetUrl);
>> >>           filter.setFilterProcessesUrl(authUrl);
>> >>           filter.setRememberMeServices(rememberMeServices);
>> >>           filter.afterPropertiesSet();
>> >>           return filter;
>> >>       }
>> >>
>> >>       public static void contributeAliasOverrides(
>> >>                   @InjectService("MySaltSource")
>> >>                   SaltSourceService saltSource,
>> >>                   @InjectService("MyAuthenticationProcessingFilter")
>> >>                   AuthenticationProcessingFilter
>> >> authenticationProcessingFilter,
>> >>                   Configuration<AliasContribution> configuration) {
>> >>
>> >>               System.out.println("AppModule: contributeAliasOverrides" +
>> >> configuration);
>> >>
>> >>
>> configuration.add(AliasContribution.create(SaltSourceService.class,saltSource));
>> >>
>> >>
>> configuration.add(AliasContribution.create(AuthenticationProcessingFilter.class,authenticationProcessingFilter));
>> >>       }
>> >>
>> >>
>> >>     public static LoginHelper
>> >> buildLoginHelper(@InjectService("MySaltSource") SaltSourceService
>> >>                                       saltSource, PasswordEncoder
>> encrypter , AuthenticationManager
>> >> authManager) {
>> >>             return new
>> AcegiLoginHelper(authManager,saltSource,encrypter);
>> >>       //return new AcegiLoginHelper(authManager);
>> >>     }
>> >>
>> >>
>> >>     public static void
>> >> contributeApplicationDefaults(MappedConfiguration<String, String>
>> >> configuration){
>> >>         configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
>> >>         configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
>> >>         configuration.add("acegi.failure.url", "/error");
>> >>         configuration.add("acegi.password.encoder",
>> >> "org.acegisecurity.providers.encoding.PlaintextPasswordEncoder");
>> >>         configuration.add("acegi.target.url", "/Program");
>> >>     }
>> >>
>> >>
>> >>     /**
>> >>      * This is a service definition, the service will be named
>> >> "TimingFilter". The interface,
>> >>      * RequestFilter, is used within the RequestHandler service
>> pipeline,
>> >> which is built from the
>> >>      * RequestHandler service configuration. Tapestry IoC is responsible
>> >> for passing in an
>> >>      * appropriate Logger instance. Requests for static resources are
>> >> handled at a higher level, so
>> >>      * this filter will only be invoked for Tapestry related requests.
>> >>      *
>> >>      * <p>
>> >>      * Service builder methods are useful when the implementation is
>> >> inline as an inner class
>> >>      * (as here) or require some other kind of special initialization.
>> In
>> >> most cases,
>> >>      * use the static bind() method instead.
>> >>      *
>> >>      * <p>
>> >>      * If this method was named "build", then the service id would be
>> >> taken from the
>> >>      * service interface and would be "RequestFilter".  Since Tapestry
>> >> already defines
>> >>      * a service named "RequestFilter" we use an explicit service id
>> that
>> >> we can reference
>> >>      * inside the contribution method.
>> >>      */
>> >>     public RequestFilter buildTimingFilter(final Logger log)
>> >>     {
>> >>         return new RequestFilter()
>> >>         {
>> >>             public boolean service(Request request, Response response,
>> >> RequestHandler handler)
>> >>                     throws IOException
>> >>             {
>> >>                 long startTime = System.currentTimeMillis();
>> >>
>> >>                 try
>> >>                 {
>> >>                     // The responsibility of a filter is to invoke the
>> >> corresponding method
>> >>                     // in the handler. When you chain multiple filters
>> >> together, each filter
>> >>                     // received a handler that is a bridge to the next
>> >> filter.
>> >>
>> >>                     return handler.service(request, response);
>> >>                 }
>> >>                 finally
>> >>                 {
>> >>                     long elapsed = System.currentTimeMillis() -
>> startTime;
>> >>
>> >>                     log.info(String.format("Request time: %d ms",
>> >> elapsed));
>> >>                 }
>> >>             }
>> >>         };
>> >>     }
>> >>
>> >>
>> >>
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/Error-while-launching-Login-page-tp23164519p23165434.html
>> > Sent from the Tapestry - User mailing list archive at Nabble.com.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Error while launching Login page

Posted by Otho <ta...@googlemail.com>.
It is also straightforward to configure Spring Secuity as usual (aka in
Spring config), if you should need features which are not yet in the spring
security module or should use spring data access abstractions anyways.


2009/4/21 Borut Bolčina <bo...@gmail.com>

> Hi,
>
> did you have a look at
> http://www.localhost.nu/java/tapestry-spring-security/?
>
> There is also a sample application to download at
> http://www.localhost.nu/svn/public/tapestry-spring-security-sample/
>
> HTH,
> Borut
>
> 2009/4/21 ChandraB <b_...@yahoo.com>:
> >
> >
> > I am a newbie to tapestry, i am getting NullPointerException when i
> access
> > authManager.
> > How do i inject AuthManager?
> >
> > Chandra
> >
> >
> >
> > ChandraB wrote:
> >>
> >> Service id 'authenticationProvider' is not defined by any module
> >>
> >>
> >> My appModule.java is as below
> >>
> >> public class AppModule
> >> {
> >>     public static void bind(ServiceBinder binder)
> >>     {
> >>
> >>
> >> binder.bind(com.eveo.edetail.reporting.service.UserDetailsService.class,
> >> UserDetailsServiceImpl.class).withId("UserDetailsServiceImpl");
> >>       binder.bind(SaltSourceService.class,
> >> SaltSourceImpl.class).withId("SaltSourceImpl");
> >>
> >>     }
> >>     public static SaltSourceService buildMySaltSource() throws Exception
> {
> >>         SaltSourceImpl saltSource = new SaltSourceImpl();
> >>         saltSource.setSystemWideSalt("DEADBEEF");
> >>         saltSource.afterPropertiesSet();
> >>         return saltSource;
> >>     }
> >>
> >>     public static UserDetailsService buildUserDetailsService(UserDao
> >> userDao) {
> >>         return new
> >> com.eveo.edetail.reporting.service.impl.UserDetailsServiceImpl(userDao);
> >>     }
> >>
> >>    public static void contributeProviderManager(
> >>             OrderedConfiguration<AuthenticationProvider> configuration,
> >>             @InjectService("DaoAuthenticationProvider")
> >>             AuthenticationProvider daoAuthenticationProvider) {
> >>
> >>
> >>
> >>               System.out.println("AppModule: contributeProviderManager"
> +
> >> configuration);
> >>
> System.out.println("-------->>"+daoAuthenticationProvider);
> >>         configuration.add("daoAuthenticationProvider",
> >> daoAuthenticationProvider);
> >>
> >>
> >>     }
> >>     public static AuthenticationProcessingFilter
> >> buildMyAuthenticationProcessingFilter(
> >>             @AcegiServices final AuthenticationManager manager,
> >>             @AcegiServices final RememberMeServices rememberMeServices,
> >>             @Inject @Value("${acegi.check.url}") final String authUrl,
> >>             @Inject @Value("${acegi.target.url}") final String
> targetUrl,
> >>             @Inject @Value("${acegi.failure.url}") final String
> >> failureUrl)
> >>
>                                               throws Exception {
> >>
> >>
> >>       System.out.println("Auth URL"+ authUrl );
> >>           AuthenticationProcessingFilter filter = new
> >> AuthenticationProcessingFilter();
> >>           filter.setAuthenticationManager(manager);
> >>           filter.setAuthenticationFailureUrl(failureUrl);
> >>           filter.setDefaultTargetUrl(targetUrl);
> >>           filter.setFilterProcessesUrl(authUrl);
> >>           filter.setRememberMeServices(rememberMeServices);
> >>           filter.afterPropertiesSet();
> >>           return filter;
> >>       }
> >>
> >>       public static void contributeAliasOverrides(
> >>                   @InjectService("MySaltSource")
> >>                   SaltSourceService saltSource,
> >>                   @InjectService("MyAuthenticationProcessingFilter")
> >>                   AuthenticationProcessingFilter
> >> authenticationProcessingFilter,
> >>                   Configuration<AliasContribution> configuration) {
> >>
> >>               System.out.println("AppModule: contributeAliasOverrides" +
> >> configuration);
> >>
> >>
> configuration.add(AliasContribution.create(SaltSourceService.class,saltSource));
> >>
> >>
> configuration.add(AliasContribution.create(AuthenticationProcessingFilter.class,authenticationProcessingFilter));
> >>       }
> >>
> >>
> >>     public static LoginHelper
> >> buildLoginHelper(@InjectService("MySaltSource") SaltSourceService
> >>                                       saltSource, PasswordEncoder
> encrypter , AuthenticationManager
> >> authManager) {
> >>             return new
> AcegiLoginHelper(authManager,saltSource,encrypter);
> >>       //return new AcegiLoginHelper(authManager);
> >>     }
> >>
> >>
> >>     public static void
> >> contributeApplicationDefaults(MappedConfiguration<String, String>
> >> configuration){
> >>         configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
> >>         configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
> >>         configuration.add("acegi.failure.url", "/error");
> >>         configuration.add("acegi.password.encoder",
> >> "org.acegisecurity.providers.encoding.PlaintextPasswordEncoder");
> >>         configuration.add("acegi.target.url", "/Program");
> >>     }
> >>
> >>
> >>     /**
> >>      * This is a service definition, the service will be named
> >> "TimingFilter". The interface,
> >>      * RequestFilter, is used within the RequestHandler service
> pipeline,
> >> which is built from the
> >>      * RequestHandler service configuration. Tapestry IoC is responsible
> >> for passing in an
> >>      * appropriate Logger instance. Requests for static resources are
> >> handled at a higher level, so
> >>      * this filter will only be invoked for Tapestry related requests.
> >>      *
> >>      * <p>
> >>      * Service builder methods are useful when the implementation is
> >> inline as an inner class
> >>      * (as here) or require some other kind of special initialization.
> In
> >> most cases,
> >>      * use the static bind() method instead.
> >>      *
> >>      * <p>
> >>      * If this method was named "build", then the service id would be
> >> taken from the
> >>      * service interface and would be "RequestFilter".  Since Tapestry
> >> already defines
> >>      * a service named "RequestFilter" we use an explicit service id
> that
> >> we can reference
> >>      * inside the contribution method.
> >>      */
> >>     public RequestFilter buildTimingFilter(final Logger log)
> >>     {
> >>         return new RequestFilter()
> >>         {
> >>             public boolean service(Request request, Response response,
> >> RequestHandler handler)
> >>                     throws IOException
> >>             {
> >>                 long startTime = System.currentTimeMillis();
> >>
> >>                 try
> >>                 {
> >>                     // The responsibility of a filter is to invoke the
> >> corresponding method
> >>                     // in the handler. When you chain multiple filters
> >> together, each filter
> >>                     // received a handler that is a bridge to the next
> >> filter.
> >>
> >>                     return handler.service(request, response);
> >>                 }
> >>                 finally
> >>                 {
> >>                     long elapsed = System.currentTimeMillis() -
> startTime;
> >>
> >>                     log.info(String.format("Request time: %d ms",
> >> elapsed));
> >>                 }
> >>             }
> >>         };
> >>     }
> >>
> >>
> >>
> >
> > --
> > View this message in context:
> http://www.nabble.com/Error-while-launching-Login-page-tp23164519p23165434.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Error while launching Login page

Posted by Borut Bolčina <bo...@gmail.com>.
Hi,

did you have a look at http://www.localhost.nu/java/tapestry-spring-security/?

There is also a sample application to download at
http://www.localhost.nu/svn/public/tapestry-spring-security-sample/

HTH,
Borut

2009/4/21 ChandraB <b_...@yahoo.com>:
>
>
> I am a newbie to tapestry, i am getting NullPointerException when i access
> authManager.
> How do i inject AuthManager?
>
> Chandra
>
>
>
> ChandraB wrote:
>>
>> Service id 'authenticationProvider' is not defined by any module
>>
>>
>> My appModule.java is as below
>>
>> public class AppModule
>> {
>>     public static void bind(ServiceBinder binder)
>>     {
>>
>>
>> binder.bind(com.eveo.edetail.reporting.service.UserDetailsService.class,
>> UserDetailsServiceImpl.class).withId("UserDetailsServiceImpl");
>>       binder.bind(SaltSourceService.class,
>> SaltSourceImpl.class).withId("SaltSourceImpl");
>>
>>     }
>>     public static SaltSourceService buildMySaltSource() throws Exception {
>>         SaltSourceImpl saltSource = new SaltSourceImpl();
>>         saltSource.setSystemWideSalt("DEADBEEF");
>>         saltSource.afterPropertiesSet();
>>         return saltSource;
>>     }
>>
>>     public static UserDetailsService buildUserDetailsService(UserDao
>> userDao) {
>>         return new
>> com.eveo.edetail.reporting.service.impl.UserDetailsServiceImpl(userDao);
>>     }
>>
>>    public static void contributeProviderManager(
>>             OrderedConfiguration<AuthenticationProvider> configuration,
>>             @InjectService("DaoAuthenticationProvider")
>>             AuthenticationProvider daoAuthenticationProvider) {
>>
>>
>>
>>               System.out.println("AppModule: contributeProviderManager" +
>> configuration);
>>               System.out.println("-------->>"+daoAuthenticationProvider);
>>         configuration.add("daoAuthenticationProvider",
>> daoAuthenticationProvider);
>>
>>
>>     }
>>     public static AuthenticationProcessingFilter
>> buildMyAuthenticationProcessingFilter(
>>             @AcegiServices final AuthenticationManager manager,
>>             @AcegiServices final RememberMeServices rememberMeServices,
>>             @Inject @Value("${acegi.check.url}") final String authUrl,
>>             @Inject @Value("${acegi.target.url}") final String targetUrl,
>>             @Inject @Value("${acegi.failure.url}") final String
>> failureUrl)
>>                                                                                                                       throws Exception {
>>
>>
>>       System.out.println("Auth URL"+ authUrl );
>>           AuthenticationProcessingFilter filter = new
>> AuthenticationProcessingFilter();
>>           filter.setAuthenticationManager(manager);
>>           filter.setAuthenticationFailureUrl(failureUrl);
>>           filter.setDefaultTargetUrl(targetUrl);
>>           filter.setFilterProcessesUrl(authUrl);
>>           filter.setRememberMeServices(rememberMeServices);
>>           filter.afterPropertiesSet();
>>           return filter;
>>       }
>>
>>       public static void contributeAliasOverrides(
>>                   @InjectService("MySaltSource")
>>                   SaltSourceService saltSource,
>>                   @InjectService("MyAuthenticationProcessingFilter")
>>                   AuthenticationProcessingFilter
>> authenticationProcessingFilter,
>>                   Configuration<AliasContribution> configuration) {
>>
>>               System.out.println("AppModule: contributeAliasOverrides" +
>> configuration);
>>
>> configuration.add(AliasContribution.create(SaltSourceService.class,saltSource));
>>
>> configuration.add(AliasContribution.create(AuthenticationProcessingFilter.class,authenticationProcessingFilter));
>>       }
>>
>>
>>     public static LoginHelper
>> buildLoginHelper(@InjectService("MySaltSource") SaltSourceService
>>                                       saltSource, PasswordEncoder encrypter , AuthenticationManager
>> authManager) {
>>             return new AcegiLoginHelper(authManager,saltSource,encrypter);
>>       //return new AcegiLoginHelper(authManager);
>>     }
>>
>>
>>     public static void
>> contributeApplicationDefaults(MappedConfiguration<String, String>
>> configuration){
>>         configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
>>         configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
>>         configuration.add("acegi.failure.url", "/error");
>>         configuration.add("acegi.password.encoder",
>> "org.acegisecurity.providers.encoding.PlaintextPasswordEncoder");
>>         configuration.add("acegi.target.url", "/Program");
>>     }
>>
>>
>>     /**
>>      * This is a service definition, the service will be named
>> "TimingFilter". The interface,
>>      * RequestFilter, is used within the RequestHandler service pipeline,
>> which is built from the
>>      * RequestHandler service configuration. Tapestry IoC is responsible
>> for passing in an
>>      * appropriate Logger instance. Requests for static resources are
>> handled at a higher level, so
>>      * this filter will only be invoked for Tapestry related requests.
>>      *
>>      * <p>
>>      * Service builder methods are useful when the implementation is
>> inline as an inner class
>>      * (as here) or require some other kind of special initialization. In
>> most cases,
>>      * use the static bind() method instead.
>>      *
>>      * <p>
>>      * If this method was named "build", then the service id would be
>> taken from the
>>      * service interface and would be "RequestFilter".  Since Tapestry
>> already defines
>>      * a service named "RequestFilter" we use an explicit service id that
>> we can reference
>>      * inside the contribution method.
>>      */
>>     public RequestFilter buildTimingFilter(final Logger log)
>>     {
>>         return new RequestFilter()
>>         {
>>             public boolean service(Request request, Response response,
>> RequestHandler handler)
>>                     throws IOException
>>             {
>>                 long startTime = System.currentTimeMillis();
>>
>>                 try
>>                 {
>>                     // The responsibility of a filter is to invoke the
>> corresponding method
>>                     // in the handler. When you chain multiple filters
>> together, each filter
>>                     // received a handler that is a bridge to the next
>> filter.
>>
>>                     return handler.service(request, response);
>>                 }
>>                 finally
>>                 {
>>                     long elapsed = System.currentTimeMillis() - startTime;
>>
>>                     log.info(String.format("Request time: %d ms",
>> elapsed));
>>                 }
>>             }
>>         };
>>     }
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Error-while-launching-Login-page-tp23164519p23165434.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Error while launching Login page

Posted by ChandraB <b_...@yahoo.com>.

I am a newbie to tapestry, i am getting NullPointerException when i access
authManager.
How do i inject AuthManager?

Chandra



ChandraB wrote:
> 
> Service id 'authenticationProvider' is not defined by any module
> 
> 
> My appModule.java is as below 
> 
> public class AppModule
> {
>     public static void bind(ServiceBinder binder)
>     {
>        
>     
> binder.bind(com.eveo.edetail.reporting.service.UserDetailsService.class,
> UserDetailsServiceImpl.class).withId("UserDetailsServiceImpl");
>     	binder.bind(SaltSourceService.class,
> SaltSourceImpl.class).withId("SaltSourceImpl");
> 
>     }
>     public static SaltSourceService buildMySaltSource() throws Exception {
>         SaltSourceImpl saltSource = new SaltSourceImpl();
>         saltSource.setSystemWideSalt("DEADBEEF");
>         saltSource.afterPropertiesSet();
>         return saltSource;
>     }
>     
>     public static UserDetailsService buildUserDetailsService(UserDao
> userDao) {
>         return new
> com.eveo.edetail.reporting.service.impl.UserDetailsServiceImpl(userDao);
>     }
>    
>    public static void contributeProviderManager(
>             OrderedConfiguration<AuthenticationProvider> configuration,
>             @InjectService("DaoAuthenticationProvider")
>             AuthenticationProvider daoAuthenticationProvider) {
> 	   
> 	   
> 	   
> 	   	System.out.println("AppModule: contributeProviderManager" +
> configuration); 	   
> 	   	System.out.println("-------->>"+daoAuthenticationProvider);	   
>         configuration.add("daoAuthenticationProvider",
> daoAuthenticationProvider);
>         
>         
>     }
>     public static AuthenticationProcessingFilter
> buildMyAuthenticationProcessingFilter(
>             @AcegiServices final AuthenticationManager manager,
>             @AcegiServices final RememberMeServices rememberMeServices,
>             @Inject @Value("${acegi.check.url}") final String authUrl,
>             @Inject @Value("${acegi.target.url}") final String targetUrl,
>             @Inject @Value("${acegi.failure.url}") final String
> failureUrl)
>     															throws Exception {
>     	
>     	
>     	System.out.println("Auth URL"+ authUrl );
> 	    AuthenticationProcessingFilter filter = new
> AuthenticationProcessingFilter();
> 	    filter.setAuthenticationManager(manager);
> 	    filter.setAuthenticationFailureUrl(failureUrl);
> 	    filter.setDefaultTargetUrl(targetUrl);
> 	    filter.setFilterProcessesUrl(authUrl);
> 	    filter.setRememberMeServices(rememberMeServices);
> 	    filter.afterPropertiesSet();
> 	    return filter;
> 	}
> 
> 	public static void contributeAliasOverrides(
> 	            @InjectService("MySaltSource")
> 	            SaltSourceService saltSource,
> 	            @InjectService("MyAuthenticationProcessingFilter")
> 	            AuthenticationProcessingFilter
> authenticationProcessingFilter,
> 	            Configuration<AliasContribution> configuration) {
> 		
> 	  	System.out.println("AppModule: contributeAliasOverrides" +
> configuration); 	   
> 	   
> configuration.add(AliasContribution.create(SaltSourceService.class,saltSource));
> 	   
> configuration.add(AliasContribution.create(AuthenticationProcessingFilter.class,authenticationProcessingFilter));
> 	} 
> 	
> 	
>     public static LoginHelper
> buildLoginHelper(@InjectService("MySaltSource") SaltSourceService
>     					saltSource, PasswordEncoder encrypter , AuthenticationManager
> authManager) {
>             return new AcegiLoginHelper(authManager,saltSource,encrypter);
>     	//return new AcegiLoginHelper(authManager);
>     } 
>     
>     
>     public static void
> contributeApplicationDefaults(MappedConfiguration<String, String>
> configuration){      
>         configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
>         configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
>         configuration.add("acegi.failure.url", "/error");
>         configuration.add("acegi.password.encoder",
> "org.acegisecurity.providers.encoding.PlaintextPasswordEncoder");
>         configuration.add("acegi.target.url", "/Program");        
>     }
>     
> 
>     /**
>      * This is a service definition, the service will be named
> "TimingFilter". The interface,
>      * RequestFilter, is used within the RequestHandler service pipeline,
> which is built from the
>      * RequestHandler service configuration. Tapestry IoC is responsible
> for passing in an
>      * appropriate Logger instance. Requests for static resources are
> handled at a higher level, so
>      * this filter will only be invoked for Tapestry related requests.
>      * 
>      * <p>
>      * Service builder methods are useful when the implementation is
> inline as an inner class
>      * (as here) or require some other kind of special initialization. In
> most cases,
>      * use the static bind() method instead. 
>      * 
>      * <p>
>      * If this method was named "build", then the service id would be
> taken from the 
>      * service interface and would be "RequestFilter".  Since Tapestry
> already defines
>      * a service named "RequestFilter" we use an explicit service id that
> we can reference
>      * inside the contribution method.
>      */    
>     public RequestFilter buildTimingFilter(final Logger log)
>     {
>         return new RequestFilter()
>         {
>             public boolean service(Request request, Response response,
> RequestHandler handler)
>                     throws IOException
>             {
>                 long startTime = System.currentTimeMillis();
> 
>                 try
>                 {
>                     // The responsibility of a filter is to invoke the
> corresponding method
>                     // in the handler. When you chain multiple filters
> together, each filter
>                     // received a handler that is a bridge to the next
> filter.
>                     
>                     return handler.service(request, response);
>                 }
>                 finally
>                 {
>                     long elapsed = System.currentTimeMillis() - startTime;
> 
>                     log.info(String.format("Request time: %d ms",
> elapsed));
>                 }
>             }
>         };
>     }
>     
>    
> 

-- 
View this message in context: http://www.nabble.com/Error-while-launching-Login-page-tp23164519p23165434.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org