Try creating a class like

  public class CustomUserNamePasswordValidator : AbstractServiceHostAware
  {
          private readonly AuthenticationService _authentication;

          public InstallUserNameValidator(AuthenticationService authentication)
          {
               _authentication = authentication;
          }

          protected override void Opening(ServiceHost serviceHost)
          {
                
serviceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator 
= _authentication;
          }
  }

  Register your AuthenticationService and CustomUserNamePasswordValidator in 
container and you should be good to go.
The AuthenticationService can then use dependencies in its ctor.

On Dec 21, 2011, at 7:32 AM, Herms wrote:

> Hi,
> I have a WCF project hosted in a non-IIS environment (Windows Service
> in production / console application when developing). The WCF
> application exposes some REST services through webHttpBindings.
> 
> For authentication, I have a custom developed
> UserNamePasswordValidator class. It is configured in a
> "serviceBehaviour" element in the WCF app.config file, like so:
> 
>        <behavior name="XxxBehaviour">
>          <serviceCredentials>
>            <userNameAuthentication
> userNamePasswordValidationMode="Custom"
> customUserNamePasswordValidatorType="Xxx.Security.Services.AuthenticationService,
> Xxx.Security" />
>          </serviceCredentials>
>        </behavior>
> 
> This has worked fine, until we recently decided to (try to) get rid of
> "all" tight couplings, and start using Castle Windsor.
> 
> I use the fluent API to configure the container. All components
> (services, data access objects, ...) are registered with Castle
> Windsor before I create ServiceHost objects with Castle Windsor's
> DefaultServiceHostFactory. Now, the last tightly coupled component
> (well...) in our solution is the above mentioned authentication
> service / UserNamePasswordValidator extension. Up until now we have
> had a default constructor on it, and "hard-wired" the dependencies. My
> goal is to inject its dependencies through the constructor, and have
> Castle Windsor do it's thing!
> 
> 1. Is this possible?
> 2. How?
> 
> BR,
> Herman
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/castle-project-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to