UsernameToken and CustomUsernameTokenManager are not calling Authenticate token

UsernameToken and CustomUsernameTokenManager are not calling Authenticate token

Post by was1 » Thu, 13 Jan 2005 23:06:00


i guys,

I tried to follow the example for securing a webservice with a
UsernameToken (http://msdn.microsoft.com/library/en-us/wse/html/cf2b92f2-2338-4af9-89c1-38fe0eab7730.asp).
I have a class CustomUsernameTokenManager derived from
UsernameTokenManager with a function AuthenticateToken(UsernameToken
userName). The CustomUsernameTokenManager is registered in the
web.config with

<code from web.config>

<?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>
<microsoft.web.services2>
<security>
<securityTokenManager type="MyNamespace.CustomUsernameTokenManager,
MyNamespace" xmlns:wsse="http://tempuri.org/MyNamespace"
qname="wsse:UsernameToken" />
</security>
<diagnostics>
<detailedErrors enabled="true" />
<trace enabled="false" />
</diagnostics>
</microsoft.web.services2>
</configuration>

</code>

The Client calls a webservice with the following:

<code from client>

UsernameToken userToken = new UsernameToken("xxx", "yyy",
PasswordOption.SendPlainText);
webservice.HelloServiceWse serviceProxy = new
webservice.HelloServiceWse();
SoapContext requestContext = serviceProxy.RequestSoapContext;
requestContext.Security.Tokens.Add(userToken);
MessageSignature sig = new MessageSignature(userToken);
requestContext.Security.Elements.Add(sig);
requestContext.Security.Timestamp.TtlInSeconds = 60;
textBox1.Text = serviceProxy.sayHello();

</code>

Every time I call the webservice function an security error occurs. In
the AuthenticateToken function I return "yyy".

<code from error>

'System.Web.Services.Protocols.SoapHeaderException' occured in
system.web.services.dll

Additional information:

Microsoft.Web.Services2.Security.SecurityFault: The security token
could not be authenticated or authorized
at Microsoft.Web.Services2.Security.Tokens.UsernameTokenManager.OnLogonUserFailed(UsernameToken
token)
at Microsoft.Web.Services2.Security.Tokens.UsernameTokenManager.LogonUser(UsernameToken
token)
at Microsoft.Web.Services2.Security.Tokens.UsernameTokenManager.AuthenticateToken(UsernameToken
token)
at Microsoft.Web.Services2.Security.Tokens.UsernameTokenManager.VerifyToken(SecurityToken
securityToken)
at Microsoft.Web.Services2.Security.Tokens.SecurityTokenManager.LoadXmlSecurityToken(XmlElement
element)
at Microsoft.Web.Services2.Security.Tokens.SecurityTokenManager.GetTokenFromXml(XmlElement
element)
at Microsoft.Web.Services2.Security.Security.LoadToken(XmlElement
element, SecurityConfiguration configuration, Int32& tokenCount)
at Microsoft.Web.Services2.Security.Security.LoadXml(XmlElement
element)
at Microsoft.Web.Services2.Security.SecurityInputFilter.ProcessMessage(SoapEnvelope
envelope)
at Microsoft.Web.Services2.Pipeline.ProcessInputMessage(SoapEnvelope
envelope)
at Microsoft.Web
 
 
 

UsernameToken and CustomUsernameTokenManager are not calling Authenticate token

Post by Sami Vaara » Thu, 13 Jan 2005 23:31:57

hat's with all these sudden UsernameToken problems?

Anyway, it seems that WES is using its built-in UsernameTokenManager which
tries to authenticate the credentials against a Windows account. Try
changing

xmlns:wsse="http://tempuri.org/MyNamespace"

in the securityTokenManager tag in the service config file to

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"

and see if it picks up your custom UsernameTokenManager.

Regards,
Sami


"Matthias" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...