Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

InfoCard / CardSpace samples problems

 
 
Thread Tools Display Modes
Old 07-26-2006   #1 (permalink)
James
Guest


 

InfoCard / CardSpace samples problems

Hello,

I am trying to complete the simple InfoCard walkthrough from the Federated
Identity and Access Resource Kit - Sept 2005 CTP. I am running Windows XP
SP2 with the following components installed:

- Microsoft .NET Framework 3.0 - July 2006 CTP
- Visual C# Express Edition
- Federated Identity and Access Resource Kit - Sept 2005 CTP

The .NET Framework 3.0 - July 2006 CTP provides the CardSpace control panel
and the appropriate dlls for Visual C#.

I have managed to re-write the sample code provided in the Federated
Identity and Access Resource Kit - Sept 2005 CTP so that it utilises the new
class structure in the .NET Framework 3.0 - July 2006 CTP. This includes
needing to use System.IdentityModel.Policy and System.IdentityModel.Claims
references.

I have managed to get a simple WCF Hello World application working with the
above components as long as I do not use security on the endpoints or
message security. As soon as I try to bring in InfoCard into the equation,
and thus endpoint security, I get a MessageSecurityException thrown which
states the following:

Client cannot determine the Service Principal Name vased on the identity in
the target address 'http://localhost:4123/myService/endpoint1' for the
purpose of SspiNegotiation/Kerberos. The target address identity must be a
UPN identity (like acmedomain\alice) or SPN identity (like
host\bobs-machine).

The sample code shows wsHTTPBinding message security enabled with the
message clientCredentialType="InfoCard", this is not a supported value in
the .NET Framework 3.0 - July 2006 CTP. I am currently set to use
clientCredentialType="IssuedToken". Is this correct, could this be causing
the issue?

I have included below my two files:

Many thanks for any help / suggestions you can provide.

James


File 1 - Program.cs ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.IdentityModel.Policy;
using System.IdentityModel.Claims;
using System.IdentityModel.Selectors;


namespace MyFirstHelloApp
{
[ServiceContract]
interface IHello
{
[OperationContract]
string SayHello();
[OperationContract]
string SayWithID();
}

class Hello : IHello
{
public const String emailClaimType =
"http://schemas.microsoft.com/ws/2005/05/identity/claims/EmailAddress";

public string SayHello()
{
return "Hello World!";
}

public string SayWithID()
{
AuthorizationContext authContext =
OperationContext.Current.ServiceSecurityContext.AuthorizationContext;
String identity = " ";

for (int i = 0; i < authContext.ClaimSets.Count; i++)
{
foreach (Claim claim in authContext.ClaimSets[i])
{
if (claim.ClaimType == emailClaimType)
{
identity += claim.Resource.ToString();
break;
}
}
}
return "Hello World - " + identity;
}

}

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting Service...");
ServiceHost sh = new ServiceHost(typeof(MyFirstHelloApp.Hello));
sh.Open();
Console.WriteLine("Service Listening...");

//Creating a client that consumes the interface (contract)
Console.WriteLine("Starting Client...");
ChannelFactory<IHello> chnFactory = new
ChannelFactory<IHello>("myClient");
Console.WriteLine("Client Creating Channel...");
IHello chn = chnFactory.CreateChannel();
Console.WriteLine("Client Connecting...");
Console.WriteLine(chn.SayWithID());

// Clean up
chnFactory.Close(); // close the client's channel
sh.Close(); // close the service host's listener

}
}

}


File 2 - App.config ------------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="myBinding">
<security mode="Message">
<message clientCredentialType="IssuedToken" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyFirstHelloApp.Hello"
behaviorConfiguration="MyServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:4123/myService"></add>
</baseAddresses>
</host>
<endpoint
address="endpoint1"
contract="MyFirstHelloApp.IHello"
binding="wsHttpBinding"
bindingConfiguration="myBinding">
<identity>
<certificateReference
findValue="Fabrikam"
storeLocation="LocalMachine"
storeName="TrustedPeople"
x509FindType="FindBySubjectName" />
</identity>
</endpoint>
</service>
</services>
<client>
<endpoint
name="myClient"
address="http://localhost:4123/myService/endpoint1"
contract="MyFirstHelloApp.IHello"
binding="wsHttpBinding"
behaviorConfiguration="MyClientBehavior">
<identity>
<certificateReference
findValue="Fabrikam"
storeLocation="CurrentUser"
storeName="My"
x509FindType="FindBySubjectName" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior"
returnUnknownExceptionsAsFaults="true" >
<serviceCredentials>
<serviceCertificate
findValue="Fabrikam"
storeLocation="LocalMachine"
storeName="TrustedPeople"
x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MyClientBehavior">
<clientCredentials>
<clientCertificate
findValue="Fabrikam"
storeLocation="CurrentUser"
storeName="My"
x509FindType="FindBySubjectName" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>



 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows cardspace ?? t-4-2 Vista General 1 06-01-2008 01:31 AM
CardSpace Crispy500 Vista General 0 02-21-2008 09:26 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50