I am trying to create a custom UsernameTokenManager with WSE 3.0. The
class seems to be be instantiated ( I can debug the constructor as it
runs if I put one in), but the overridden AuthenticateToken method is
never called, instead the normal one is apparently used (I can access
the web services using a local user account. Below I am posting my
CustomUsernameTokenManager class, web.config file and
wse3policyCache.config file. As you can see, I am just trying to get it
to run, I have tried to strip everything down as much as possible. Any
suggestions would be appreciated.I'm not for sure how common a problem
this is, I haven't found anything very helpful on the web. I can
provide more info if needed.
CustomUsernameTokenManager Class:
using System;
using System.Xml;
using System.Security.Permissions;
using System.Web.Security;
using System.Security.Principal;
using Microsoft.Web.Services3.Security;
using Microsoft.Web.Services3.Security.Tokens;
namespace CompanyProject
{
[SecurityPermissionAttribute(SecurityAction.Demand,
Flags=SecurityPermissionFlag.UnmanagedCode)]
public class CustomUsernameTokenManager : UsernameTokenManager
{
protected override string AuthenticateToken(UsernameToken
token)
{
return "test";
}
}
}
Portion of web.config:
<webServices>
<soapExtensionImporterTypes>
<add
type="Microsoft.Web.Services3.Description.WseExtensionImporter,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</soapExtensionImporterTypes>
<soapServerProtocolFactory
type="Microsoft.Web.Services3.WseProtocolFactory,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</webServices>
</system.web>
<microsoft.web.services3>
<security>
<securityTokenManager>
<add type="CompanyProject.CustomUsernameTokenManager"
namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
localName="UserNameToken" />
</securityTokenManager>
</security>
<policy fileName="wse3policyCache.config" />
</microsoft.web.services3>
wse3policyCache.config:
<policies
xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<extensions>
<extension name="usernameOverTransportSecurity"
type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</extensions>
<policy name="usernameTokenSecurity">
<usernameOverTransportSecurity />
</policy>
</policies>
Pablo Cibraro [MVP] - 30 Nov 2006 14:52 GMT
Hi,
It seems to be an error in the localName value, you are using UserNameToken,
but it should be UsernameToken.
Regards,
Pablo Cibraro.
>I am trying to create a custom UsernameTokenManager with WSE 3.0. The
> class seems to be be instantiated ( I can debug the constructor as it
[quoted text clipped - 75 lines]
> </policy>
> </policies>
DEotw - 30 Nov 2006 15:35 GMT
That seemed to take care of it. I didn't realize that localName had
anything to do with the policy name, so I did not pay any much
attention to it. Thanks for the help.