N
nsyforce
About a year ago, I wrote a custom userNameTokenManger. It worked
fine then. I recently dusted it off again and using the same test
code I used a year ago, I can no longer get the AuthenticateToken
function to be invoked when attached to a web service. I've tried
rewriting with the simplest of code just to test without any luck.
I'm totally stumped. I have my assembly in the gac, so the only
difference from many code examples is that I fully qualify the name of
my assembly with versioning info in the web.xml, when compared to
other examples. My IIS settings are set on the web service to allow
anonymous, basic auth, and integrated windows auth.
My code looks like this:
using System;
using Microsoft.Web.Services2;
using Microsoft.Web.Services2.Security.Tokens;
using Microsoft.Web.Services2.Security;
using System.Text;
using System.Collections;
using System.Configuration;
using System.IO;
namespace JoeWSE
{
/// <summary>
/// Summary description for WSEClass.
/// </summary>
///
public class UserNameTokenJoe:UsernameTokenManager
{
protected override string AuthenticateToken(UsernameToken token)
{
//I put code here to
write to a file, and it never works.
string userName = token.Username;
string password = token.Password;
//Return some bogus thing here that doesn't match the password
//so hopefully I won't
be able to call the web service successfully
return "This should cause an authentication problem";
}
}
}
I put this in the GAC and edit my web.xml file on a 'hello world' web
service, which I'm trying to lock down with the usernameTokenManager
above, so it looks like...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="microsoft.web.services2"
type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</configSections>
<system.web>
<webServices>
<soapExtensionTypes>
<add type="Microsoft.Web.Services2.WebServicesExtension,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" priority="1" group="0" />
</soapExtensionTypes>
</webServices>
</system.web>
<microsoft.web.services2>
<security>
<securityTokenManager
type="JoeWSE.UserNameTokenJoe,JoeWSE,Version=1.0.0.0,Culture=neutral,PublicKeyToken=671e5018475725ea,Custom=null"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
wssecurity-secext-1.0.xsd" qname="wsse:UsernameToken" />
</security>
<diagnostics>
<trace enabled="true" input="C:\_tracing\WebServiceCustomTrace
\inputtrace.webinfo" output="C:\_tracing\WebServiceCustomTrace
\OutputTrace.webinfo" />
</diagnostics>
</microsoft.web.services2>
</configuration>
Another weird thing is that if I make the type attribute invalid by
changing the name to something bogus, or changing to an invalid
version number, I will get a runtime error because the assembly can't
be found. So it's being recognized at that level. But the
AuthenticateToken function just won't get invoked. The web service
will always run successfully returning "Hello World", although based
on the bogus password I'm returning in the function, I should not be
able to call it successfully.
thanks in advance for your help.
fine then. I recently dusted it off again and using the same test
code I used a year ago, I can no longer get the AuthenticateToken
function to be invoked when attached to a web service. I've tried
rewriting with the simplest of code just to test without any luck.
I'm totally stumped. I have my assembly in the gac, so the only
difference from many code examples is that I fully qualify the name of
my assembly with versioning info in the web.xml, when compared to
other examples. My IIS settings are set on the web service to allow
anonymous, basic auth, and integrated windows auth.
My code looks like this:
using System;
using Microsoft.Web.Services2;
using Microsoft.Web.Services2.Security.Tokens;
using Microsoft.Web.Services2.Security;
using System.Text;
using System.Collections;
using System.Configuration;
using System.IO;
namespace JoeWSE
{
/// <summary>
/// Summary description for WSEClass.
/// </summary>
///
public class UserNameTokenJoe:UsernameTokenManager
{
protected override string AuthenticateToken(UsernameToken token)
{
//I put code here to
write to a file, and it never works.
string userName = token.Username;
string password = token.Password;
//Return some bogus thing here that doesn't match the password
//so hopefully I won't
be able to call the web service successfully
return "This should cause an authentication problem";
}
}
}
I put this in the GAC and edit my web.xml file on a 'hello world' web
service, which I'm trying to lock down with the usernameTokenManager
above, so it looks like...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="microsoft.web.services2"
type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</configSections>
<system.web>
<webServices>
<soapExtensionTypes>
<add type="Microsoft.Web.Services2.WebServicesExtension,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" priority="1" group="0" />
</soapExtensionTypes>
</webServices>
</system.web>
<microsoft.web.services2>
<security>
<securityTokenManager
type="JoeWSE.UserNameTokenJoe,JoeWSE,Version=1.0.0.0,Culture=neutral,PublicKeyToken=671e5018475725ea,Custom=null"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
wssecurity-secext-1.0.xsd" qname="wsse:UsernameToken" />
</security>
<diagnostics>
<trace enabled="true" input="C:\_tracing\WebServiceCustomTrace
\inputtrace.webinfo" output="C:\_tracing\WebServiceCustomTrace
\OutputTrace.webinfo" />
</diagnostics>
</microsoft.web.services2>
</configuration>
Another weird thing is that if I make the type attribute invalid by
changing the name to something bogus, or changing to an invalid
version number, I will get a runtime error because the assembly can't
be found. So it's being recognized at that level. But the
AuthenticateToken function just won't get invoked. The web service
will always run successfully returning "Hello World", although based
on the bogus password I'm returning in the function, I should not be
able to call it successfully.
thanks in advance for your help.