Hi,

I wouldn't use Configuration<AliasContribution<PasswordEncoder>>, but rather Configuration<AliasContribution>. Otherwise you won't be able to configure multiple alias overrides at once.

Apart from that, everything looks fine.

-Filip

Michael Gerzabek skrev:
Usecase:
tapestry-spring-security offers integration between Tapestry 5 an Spring Security [1]. It's implemented as a Tapestry IoC/Core module.

This module uses a PasswordEncoder shipped by Spring Security (they ship also a couple of standard implementations of PasswordEncoder).

For the module to function correctly an implementation class of PasswordEncoder (the service in charge) is needed. Now, there are two ways to configure the module:

1.) gracefully: The module declares a standard service for PasswordEncoder and assumes the main module will define an AliasContribution to override with whatever specific instance is needed.

2.) tough: The module doesn't declare a standard service for PasswordEncoder. It rather assumes that the user of the module will do so. If the user of the module doesn't provide an implementation a RuntimeException is thrown and the container won't start up.

Obviously there are arguments for both directions. In tapestry-spring-security we wanted to follow line 1.) This leads us to the FAQ.

[FAQ] How to configure a service that likely will be overriden by an AliasContribution?

i. Supplier: The only thing the supplier of a module has to do is to bind the interface (PasswordEncoder) to the default class (PlaintextPasswordEncoder) - or provide a build method if he needs to set it up.

public static void bind(final ServiceBinder binder) {

 binder.bind( PasswordEncoder.class,
              PlaintextPasswordEncoder.class ).withMarker(
              SpringSecurityServices.class);
}

ii. User: Now if you want to use a supplied module and you want to override a service defined there the only thing you have to do is to contribute to the Alias service.

public static void contributeAlias(
   Configuration<AliasContribution<PasswordEncoder>> configuration ) {

   configuration.add( AliasContribution.create(
           PasswordEncoder.class,
           new ShaPasswordEncoder() ) );
}

--
Crowd,

Is this correct? Do I miss something?

Regards,
Michael

[1] http://www.localhost.nu/java/tapestry5-acegi/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to