Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 161979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:18:34+00:00 2026-05-11T11:18:34+00:00

I’ve got a simple client-server application based on TcpClient/TcpListener and SslStream. Clients can authenticate

  • 0

I’ve got a simple client-server application based on TcpClient/TcpListener and SslStream. Clients can authenticate themselves to the server using a X509Certificate or by sending a user name and password after the SslStream has been established.

WCF makes use of the System.IdentityModel namespace for authentication purposes, but apparently that can be used in arbitrary applications–which sounds interesting. Information on how to do this is sparse though (or my Google foo is weak today).

So, my question is: What do I need to do to integrate System.IdentityModel with my application? I’m not sure if I need all that ClaimSet stuff, but it would be nice if users could log in just using their Windows account or any other provided authentication mechanism. (Unfortunately I can’t just switch to WCF but have to use the custom protocol, although I can make some changes to it if necessary.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:18:35+00:00Added an answer on May 11, 2026 at 11:18 am

    My Google foo was indeed weak. The answer is right behind the link in my question. So here are a couple of links to this blog in case somebody has the same question eventually.

    First, you should try to understand ‘that claim set stuff’:

    • Claims
    • Claim Sets
    • Inspecting Claim Sets
    • Windows and X509Certificate Claim Sets
    • Typical Operations on Claim Sets

    Then, you need to know where claim sets come from:

    • Authorization Policies, Context and Claims Transformation
    • Claims Transformation in WCF
    • Authorization Context and Claims Transformation outside of WCF

    Armed with this knowledge, it actually becomes quite simple.

    If I understand it correctly, the basic workflow would be something like this:

    1. Client creates a SecurityToken using a SecurityTokenProvider
    2. Client serializes the SecurityToken using a SecurityTokenSerializer
    3. Server deserializes the SecurityToken using a SecurityTokenSerializer
    4. Server creates IAuthorizationPolicys using a SecurityTokenAuthenticator
    5. Server creates AuthorizationContext from IAuthorizationPolicys
    6. Done

    Example:

    // Create the SecurityTokenProvider var p = new UserNameSecurityTokenProvider('username', 'password');  // Get the SecurityToken from the SecurityTokenProvider var t = p.GetToken(TimeSpan.FromSeconds(1.0)) as UserNameSecurityToken;  // ... transmit SecurityToken to server ...  // Create the SecurityTokenAuthenticator var a = new CustomUserNameSecurityTokenAuthenticator(     UserNamePasswordValidator.None);  // Create IAuthorizationPolicies from SecurityToken var i = a.ValidateToken(t);  // Create AuthorizationContext from IAuthorizationPolicies var c = AuthorizationContext.CreateDefaultAuthorizationContext(i); ShowClaims(c.ClaimSets); 

    For X509SecurityTokens use a X509SecurityTokenProvider/Authenticator. For WindowsSecurityTokens there’s a WindowsSecurityTokenAuthenticator but not a provider; instead, use the WindowsSecurityToken constructor:

    var t = new WindowsSecurityToken(WindowsIdentity.GetCurrent()); 

    This works quite well. The only thing I omitted so far above is the token serialization. There is a SecurityTokenSerializer class which has one implementation in the .NET framework: the WSSecurityTokenSerializer class which comes with WCF.

    Serializing UserNameSecurityTokens and X509SecurityTokens works like a charm (haven’t tried deserialization), but WindowsSecurityTokens are apparently not supported by the serializer. This leaves me with the two authentication methods that I already have (certificates and username/password) and, as I didn’t want that AuthorizationContext anyway, I’ll stick with what I have 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Joomla is PHP based whereas Google App Engine is Python… May 11, 2026 at 3:51 pm
  • added an answer There are three types of standards behaviour you should be… May 11, 2026 at 3:51 pm
  • added an answer I found out what was wrong. I was using a… May 11, 2026 at 3:51 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.