Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / April 2005

Tip: Looking for answers? Try searching our database.

Using UsernameToken.AnyElements to add extra credentialinfo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Qpeg - 22 Apr 2005 11:56 GMT
I want to add some extra fields to my custom UsernameToken in addition to the
username, password etc. fields. Specifically I want to add two strings;
TerminalId and UserRoleId.

In my business logic (windows.forms) I request a WS method like this:

// cut to the chase..
token = new UsernameToken(clientSession.UserName, clientSession.Password,
PasswordOption.SendPlainText );

// Add custom credentials to SOAP authentication header.
XmlDocument doc = new XmlDocument();
XmlElement terminalIdXml = doc.CreateElement("TerminalId");
terminalIdXml.InnerText = clientSession.TerminalId;
token.AnyElements.Add(terminalIdXml);

XmlElement userRoleIdXml = doc.CreateElement("UserRoleId");
userRoleIdXml.InnerText = clientSession.UserRoleId;
token.AnyElements.Add(userRoleIdXml);

// ...

proxy.RequestSoapContext.Security.Tokens.Add( token );
proxy.RequestSoapContext.Security.Elements.Add( new MessageSignature( token
) );

// Call method

Then here is the manager:
protected override string AuthenticateToken(UsernameToken token){
//..
if(session.AuthenticateUser(token.AnyElements[0].InnerText, token.Username,
token.Password, token.AnyElements[1].InnerText)){ return token.Password;}
//..

When the business logic calls the webservice, the AnyElements contains the
two extra elements.
I trace the SOAP message and find them as I expect:
<wsse:UsernameToken
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-e0620cd1-a599-4899-aacb-e00857d0609c">
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1
.0#PasswordText">PASSWORD</wsse:Password
>
<wsse:Nonce>k1llyCjkSOsQK9mJZ5PpRA==</wsse:Nonce>
<wsu:Created>2005-04-22T08:04:37Z</wsu:Created>
<TerminalId>aafajz+0000001000032</TerminalId>
<UserRoleId>aafafe+0000000000028</UserRoleId>
</wsse:UsernameToken>

But when I debug the UsernameTokenManager I find only the first of the two
additional elements, TerminalId. Isn't that weird?
I'm guessing there is something wrong in the way I add the XmlElements to
the AnyElement list, but I can't see what would be wrong..?

Any hints? I can't find much info about this around, and the documentation
is rather scarce..
Qpeg - 29 Apr 2005 09:16 GMT
My solution was to add a single XmlElement, and add the two extra fields to
this as attributes.

Still wondering what is going on here tho..

> I want to add some extra fields to my custom UsernameToken in addition to the
> username, password etc. fields. Specifically I want to add two strings;
[quoted text clipped - 52 lines]
> Any hints? I can't find much info about this around, and the documentation
> is rather scarce..

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.