Did anyone get this to work? I have been trying all morning to no avail.

I have a custom validator class:

    public class MyUserNamePasswordValidator : UserNamePasswordValidator
  {
        private ICredentialRepository _credentialRepository;

        public MyUserNamePasswordValidator(ICredentialRepository 
credentialRepository)
        {
            _credentialRepository = credentialRepository;
        }

        public override void Validate(string userName, string password)
        {
            if (userName != "bob" || password != "jones")
                throw new SecurityTokenException(string.Format("Username 
>{0}< is not allowed access", userName));
        }
    }

I created the AbstractServiceHostAware instance:

    public class CustomUserNamePasswordValidator : AbstractServiceHostAware
    {
        private readonly MyUserNamePasswordValidator _authentication;

        public CustomUserNamePasswordValidator(MyUserNamePasswordValidator 
authentication)
        {
            _authentication = authentication;
        }

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

... and attempted to wire everything up in XML as follows:

    <component id="UsernamePasswordValidator"
               type="My.Service.Web.AriesUserNamePasswordValidator, 
My.Service.Web"
               lifestyle="transient"/>

    <component id="CredentialRepository"
               service="My.ICredentialRepository, My"
               type="My.FileBasedCredentialRepository, My"
               lifestyle="transient">
      <parameters>
        
<credentialDataStoreFileName>conf\credentials.txt</credentialDataStoreFileName>
      </parameters>
    </component>
    
    <component id="AbstractServiceHostAwareClass"
               type="My.Service.Web.CustomUserNamePasswordValidator, 
My.Service.Web"
               lifestyle="transient"/>

But the validator is never called. The Opening method of the 
AbstractServiceHostAware implementation is called, though. I always see the 
following SOAP response:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:a="http://www.w3.org/2005/08/addressing";>
   <s:Header>
      <a:Action 
s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
   </s:Header>
   <s:Body>
      <s:Fault>
         <s:Code>
            <s:Value>s:Sender</s:Value>
            <s:Subcode>
               <s:Value 
xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";>a:FailedAuthentication</s:Value>
            </s:Subcode>
         </s:Code>
         <s:Reason>
            <s:Text xml:lang="en-US">At least one security token in the 
message could not be validated.</s:Text>
         </s:Reason>
      </s:Fault>
   </s:Body>
</s:Envelope>

Does anyone have any idea what I'm doing wrong (aside from using XML-based 
configuration)? Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to