Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have done the following steps:

1. Client interacts with an STS, which will issue the token.
2. The client uses some other services.

The client needs to present the token to any service it interacts with.
For this reason I used the client and service behavior.
Every time the client calls the service, I put the SamlSecurityToken into the message being sent (using the behavior):
public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            UserInfo userInfo = new UserInfo {Username="aaa", password="1234"};
            TokenEngine te = new TokenEngine();

            SamlSecurityToken Token = (SamlSecurityToken)te.CreateToken(userInfo, null);

            //Add the token to the message header
            request.Headers.Add(MessageHeader.CreateHeader("SecurityToken", "", Token));
            
            return null;
        }


On the service side, I am trying to extract the token from the message:

public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            //Extract the security token from the received message
            SamlSecurityToken callerToken = request.Headers.GetHeader<samlsecuritytoken>("SecurityToken", "");

            return null;
        }
</samlsecuritytoken>


The problem comes on the service side: I get a null reference exception when trying to get the token.

Am I doing something wrong?
Any alternatives?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900