Skip navigation

Blog Posts

Blog Posts

Items per page
1 2 Previous Next
0

I'm very excited to showcase the power and flexibility of the REST API in EmpowerID 2012. Take a look at the Create Super Simple Person Mobile workflow application on the Android Nexus phone. Developing workflow applications for mobile devices is extremely easy with the REST API. The REST API is specifically designed to support mobile platforms and restricted device environments.

 

Check back again to see the full walk-through on how to expose the Create Super Simple Person workflow to your Android devices using the Mono for Android platform.

 

1. Create Super Simple Person Workflow running on a real Andrio Nexus S Cell Phone

M1.JPG

M2.JPG

 

2. The Create Super Simple Person Workflow running on an Android Emulator for Android 4.0

 

Login to a workflow server

ad1.jpg

Fill out the basic information form

ad2.jpg

Select a Primary Business Role

ad3.jpg

Select a Business Address

ad4.jpg

Confirm person information and submit to the CreateSuperSimplePerson workflow

ad5.jpg

Submit for Approval Confirmation if and when required

ad6.jpg

Request submitted!

ad7.jpg

0

1. Assuming you're setting up SharePoint federation on a new SharePoint install with no resource system created in EmpowerID, you'll need to create a new SharePoint Resource System in EmpowerID.

a) In the Configuration Manager, select Resource Systems and from the resource systems view, click Add New.

b) The Add New Resource System window will appear, select the EmpowerID account store for the Account Store field. Select SharePoint Relying Party for the Type of Resource System and enter name for the SharePoint resource system you wish to create.

sp1.jpg

2. Go to the EmpowerID Servers and Roles and make sure the SharePoint Management Host WCF Service and the Workflow Server Managment Host WCF Service are selected for the SharePoint Server.

sp2.jpg

3. In Workflow Studio, select the SharePoint tab far to the left. The SharePoint tree will load if the Resource System is configured properly and the Workflow Service is running on your SharePoint server.

sp3.jpg

4. Expand the SharePoint Central Administration node and right click on the site URL to bring up the context menu. From the context menu, select Install/Reinstall GAC Requirements to install the required EmpowerID assemblies for SharePoint federation into the GAC.

sp4.jpg

5. Right click on the site URL again and from the context menu, select Enable SignIn/SignOut with Federation Trust. When prompted to confirm, select Yes.

sp5.jpg

6. Right click on the site URL again and from the context menu, select Configure Security Token Service Federation Trust to bring up the EmpowerID STS Federation Trust wizard.

sp6.jpg

7. In the Federation Trust wizard welcome screen, click Next. On the next screen, select the STS Certificate and the Root Authority Certificate and click Next to continue.

sp7.jpg

8. In the next screen,select the EmpowerID Identity Provider for the Identity Provider dropdown. In the Security Token Service textbox, enter the URL of the IdProvider.aspx page and specify a value for the realm. Click Nexst to continue. FYI - To create a Trust for the Realm, go to the Trusted Endpoint Configuration tool (under Application Ribbon Menu->Management Tools), locate and right click on the STS certificate and from the context menu, select Add Trust URI. The Add New Trust window will appear, in the text field, specify the Realm and click OK.

sp8.jpg

9. Right click on the site URL again and from the context menu, select Open Web Site.

sp9.jpg

10. Go the Security->Manage Trust and cofirm the EmpowerID Federationt Trust has successfully been created in SharePoint.

sp10.jpg

11. EmpowerID Federation Trust in SharePoint should appear similar to as shown below.

sp11.jpg

Converting an existing Windows Authentication Site to Claim-based Site

1. In the SharePoint Administration Console, select a Windows based SharePoint Web Application. From the top menu options, select Authentication Providers, you should see the Authentication provider is Windows and appear as shown below.

sp12.jpg

2. In Workflow Studio, click on the URL to the Windows based SharePoint site and from the context menu, select Open Authentication Provider Page.

sp13.jpg

3. From the Authentication Provider page you should be able to confirm the Authentication Type.

sp14.jpg

4. Right click on the site URL and from the context menu, select Use Claims-based Authentication Provider.

sp15.jpg

5. Select Yes when prompted to confirm.

sp16.jpg

6. After the operation succeeds, you'll get the success confirmation message.

sp17.jpg

7. Right click on the site URL and from the context menu,select Use Claims-based Authentication Provider. Go the site's authentication provider page, scroll down and select the Trusted Identity Provider and EmpowerID Identity Provider. Scroll down and click Save.

sp18.jpg

8. At this time your Windows SharePoint site should now be a Claims-based SharePoint site.

sp19.jpg

9. In Workflow Studio, right click on the Resource System and from the context menu, select Recycle Web Server (IIS Reset).

sp20.jpg

10. When prompted to confirm, select Yes.

sp21.jpg

11.After the operation succeeds, you'll get the success confirmation message.

sp22.jpg

12. Right click on the site URL again and from the context menu, select Configure Web.Config Security Token Service Federation Trust to bring up the Web.Config configuration window.

sp23.jpg

13. From the SharePoint Web.Config Configuration window, select the relying party certificate and using the Web.Config location button, locate and select the SharePoint web.config for the Claims-based web site. Click on the Update Web.Config to update the web.config for the site.

sp24.jpg

14. Select Yes, when prompted to confirm the changes to the web.config.

sp26.jpg

15. After the operation succeeds, the operation completed message is shown.

sp27.jpg

16. In Workflow Studio, right click on the site URL and from the context menu, select Open Web Site to open the newly configured web site.

sp28.jpg

17. Going to the Claims-based SharePoint site will now redirect you to the EmpowerID federation login page.

sp29.jpg

Give Everyone Permission to Login to SharePoint

1. In Workflow Studio, right click on the newly configured SharePoint site and from the context menu, select Grant Business Role and Location Permission to SharePoint Group.

ad1.jpg

19. From the Business Role and Location Selector window, select Any Role and Anywhere and click OK to close the window.

ad2.jpg

20. From the Grant Business Role and Location Permission window, select the SharePoint Group with the permission level you wish to grant to everyone by default and click OK to continue.

ad3.jpg

21. When prompted to confirm the permission assignments, select Yes.

ad4.jpg

22.  Go back to the EmpowerID Federation Login page, and login with an EmpowerID user.

ad5.jpg

0

    protected void Page_Load(object sender, EventArgs e)

    {

        IClaimsIdentity identity = HttpContext.Current.User.Identity as IClaimsIdentity;

 

        Response.Write(string.Format("Name Claim: {0}<br>", identity.NameClaimType));

        Response.Write(string.Format("Role Claim: {0}<br>", identity.RoleClaimType));

        Response.Write("--------------------------------------------------------------<br>");

        foreach (Claim c in identity.Claims)

        {

            Response.Write(string.Format("{0} = {1}<br>",c.ClaimType,c.Value));

        }

 

        Response.Write("--------------------------------------------------------------<br>");

        if (this.User.IsInRole("Managers"))

        {

            Response.Write(string.Format("Yes! You're a manager!"));

        }

 

    }

0

    protected void Page_Load(object sender, EventArgs e)

    {

        IClaimsIdentity identity = this.User.Identity as IClaimsIdentity;

 

        string role = identity.RoleClaimType;

        string name = identity.NameClaimType;

 

        Response.Write("Name ClaimType: " + name+"<br>");

        Response.Write("Role ClaimType: " + role + "<br>");

 

        Response.Write("******************************************************<br>");

        foreach (Claim c in identity.Claims)

        {

            Response.Write(string.Format("{0} = {1}", c.ClaimType, c.Value) + "<br>");

        }

 

        if (this.User.IsInRole("Managers"))

        {

            Response.Write("Yes, you're a Manager!");

        }

        else

        {

            Response.Write("Access denied: You need to be a Manager.");

        }

    }

    protected void Button1_Click(object sender, EventArgs e)

    {       

        SecurityToken token = (this.User.Identity as IClaimsIdentity).BootstrapToken;

 

        DemoMedicalRulesClient client = new DemoMedicalRulesClient();

        client.ChannelFactory.ConfigureChannelFactory();

 

        DemoMedicalRules iclient = client.ChannelFactory.CreateChannelWithIssuedToken(token);

 

        EmailOutObject output = iclient.DoesEmailHasGoogleDomain(new EmailObject

        {

            DoctorEmail = "michael@google.com",

            FriendlyName = "Dr. James"

        });

 

 

        Response.Write("<br>");

        Response.Write(output.DisplayText);

 

    }

0

<?xml version="1.0"?>

<configuration>

  <configSections>

    <section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

  </configSections>

  <system.web>

    <authorization>

      <deny users="?"/>

    </authorization>

    <authentication mode="None"/>

    <compilation debug="true">

      <assemblies>

        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="System.Data.Entity.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        <add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      </assemblies>

    </compilation>

    <pages>

      <controls>

        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      </controls>

      <namespaces>

        <add namespace="System.Linq"/>

      </namespaces>

    </pages>

    <httpHandlers>

      <remove verb="*" path="*.asmx"/>

      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>

    </httpHandlers>

    <httpModules>

      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add name="ClaimsPrincipalHttpModule" type="Microsoft.IdentityModel.Web.ClaimsPrincipalHttpModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    </httpModules>

  </system.web>

  <system.codedom>

    <compilers>

      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

        <providerOption name="CompilerVersion" value="v3.5"/>

        <providerOption name="WarnAsError" value="false"/>

      </compiler>

      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

        <providerOption name="CompilerVersion" value="v3.5"/>

        <providerOption name="OptionInfer" value="true"/>

        <providerOption name="WarnAsError" value="false"/>

      </compiler>

    </compilers>

  </system.codedom>

  <system.webServer>

    <validation validateIntegratedModeConfiguration="false"/>

    <modules runAllManagedModulesForAllRequests="true">

      <remove name="ScriptModule"/>

      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add name="WSFederationAuthenticationModule" preCondition="integratedMode" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add name="SessionAuthenticationModule" preCondition="integratedMode" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    </modules>

    <handlers>

      <remove name="WebServiceHandlerFactory-Integrated"/>

      <remove name="ScriptHandlerFactory"/>

      <remove name="ScriptHandlerFactoryAppServices"/>

      <remove name="ScriptResource"/>

      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

    </handlers>

    <defaultDocument>

      <files>

        <clear/>

        <add value="default.aspx"/>

        <add value="Default.htm"/>

        <add value="Default.asp"/>

        <add value="index.htm"/>

        <add value="index.html"/>

        <add value="iisstart.htm"/>

      </files>

    </defaultDocument>

  </system.webServer>

  <runtime>

    <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>

        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

      </dependentAssembly>

      <dependentAssembly>

        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>

        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

      </dependentAssembly>

    </assemblyBinding>

  </runtime>

  <microsoft.identityModel>

    <service saveBootstrapTokens="true">

      <audienceUris  mode="Never"/>

      <issuerNameRegistry type="TheDotNetFactory.Framework.SAML.WSFederation.TrustedIssuerNameRegistry, TheDotNetFactory.Framework.SAML, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cdea72caaad57b56"/>

      <serviceTokenResolver type="TheDotNetFactory.Framework.SAML.WSFederation.ServiceSimpleTokenResolver, TheDotNetFactory.Framework.SAML, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cdea72caaad57b56"/>

      <issuerTokenResolver type="TheDotNetFactory.Framework.SAML.WSFederation.ServiceSimpleTokenResolver, TheDotNetFactory.Framework.SAML, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cdea72caaad57b56"/>

        <securityTokenHandlers>

            <clear />

            <add type="Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

            <add type="Microsoft.IdentityModel.Tokens.X509SecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

            <add type="Microsoft.IdentityModel.Tokens.EncryptedSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

            <add type="TheDotNetFactory.Framework.SAML.WSFederation.CustomSaml11SecurityTokenHandler, TheDotNetFactory.Framework.SAML, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cdea72caaad57b56"/>

            <add type="TheDotNetFactory.Framework.SAML.WSFederation.CSaml2SecurityTokenHandler, TheDotNetFactory.Framework.SAML, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cdea72caaad57b56"/>

        </securityTokenHandlers>       

      <federatedAuthentication>

        <wsFederation passiveRedirectEnabled="true" issuer="https://michael-wf1.thedotnetfactory.internal/empowerid/IdProvider.aspx/" realm="https://michael-wf1.thedotnetfactory.internal/TestWSFederationApp/" requireHttps="true"/>

        <cookieHandler requireSsl="true"/>

      </federatedAuthentication>

    </service>

  </microsoft.identityModel>

 

  <system.serviceModel>

    <bindings>

      <!--A secure and interoperable binding that derives from WS2007HttpBinding and supports federated security.-->

      <ws2007FederationHttpBinding>

        <binding name="WS2007FederationHttpBinding_DemoMedicalRules"

            closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"

            sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false"

            hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"

            maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8"

            useDefaultWebProxy="true">

          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

              maxBytesPerRead="4096" maxNameTableCharCount="16384" />

          <reliableSession ordered="true" inactivityTimeout="00:10:00"

              enabled="false" />

          <!--Message Security and Transport Security (SSL/HTTPS).-->

          <security mode="TransportWithMessageCredential">

            <message algorithmSuite="Default" issuedKeyType="SymmetricKey"

                negotiateServiceCredential="true" issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">

              <!--Set the Issuer(STS) URL-->

              <issuer address="https://MICHAEL-WF1.thedotnetfactory.internal:7080/empoweridsts" binding="ws2007HttpBinding"

                  bindingConfiguration="https://MICHAEL-WF1.thedotnetfactory.internal:7080/empoweridsts">

                <!--Set the Endpoint Identity for the Issuer (STS) using the STS certificate-->

                <identity>

                  <certificateReference findValue="A70012841C8E6E8C8CA5E9E2D78B04C3A64EB26C"

                     isChainIncluded="false"

                     storeName="My"

                     storeLocation="LocalMachine"

                     x509FindType="FindByThumbprint"/>

                </identity>

              </issuer>

              <!--Set the Issuer(STS) metadata URL -->

              <issuerMetadata address="https://MICHAEL-WF1.thedotnetfactory.internal:7080/empoweridsts/mex" />

              <tokenRequestParameters>

                <trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">

                  <trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey</trust:KeyType>

                  <trust:KeySize xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">256</trust:KeySize>

                  <trust:Claims Dialect="http://schemas.xmlsoap.org/ws/2005/05/identity"

                      xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">

                    <wsid:ClaimType Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"

                        xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />

                    <wsid:ClaimType Uri="http://empowerid.sts.com/svc/2010/03/claims/personid"

                        xmlns:wsid="http://schemas.xmlsoap.org/ws/2005/05/identity" />

                  </trust:Claims>

                  <trust:KeyWrapAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p</trust:KeyWrapAlgorithm>

                  <trust:EncryptWith xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptWith>

                  <trust:SignWith xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2000/09/xmldsig#hmac-sha1</trust:SignWith>

                  <trust:CanonicalizationAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>

                  <trust:EncryptionAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>

                </trust:SecondaryParameters>

              </tokenRequestParameters>

            </message>

          </security>

        </binding>

      </ws2007FederationHttpBinding>

      <!--Represents an interoperable binding that derives from WSHttpBinding and provides support for the updated

             versions of the Security, ReliableSession, and TransactionFlow binding elements.-->

      <ws2007HttpBinding>

        <binding name="https://MICHAEL-WF1.thedotnetfactory.internal:7080/empoweridsts" closeTimeout="00:01:00"

            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"

            maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"

            allowCookies="false">

          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

              maxBytesPerRead="4096" maxNameTableCharCount="16384" />

          <reliableSession ordered="true" inactivityTimeout="00:10:00"

              enabled="false" />

          <!--Message Security and Transport Security (SSL/HTTPS).-->

          <security mode="TransportWithMessageCredential">

            <transport clientCredentialType="None" proxyCredentialType="None"

                realm="" />

            <message clientCredentialType="UserName" negotiateServiceCredential="false"

                algorithmSuite="Default" establishSecurityContext="false" />

          </security>

        </binding>

      </ws2007HttpBinding>

    </bindings>

    <client>

      <!--TODO: Specify the correct Service Contract-->

      <endpoint address="https://MICHAEL-WF1.thedotnetfactory.internal:7080/DemoMedicalRules"

          binding="ws2007FederationHttpBinding" bindingConfiguration="WS2007FederationHttpBinding_DemoMedicalRules"

          contract="ServiceReference1.DemoMedicalRules" name="WS2007FederationHttpBinding_DemoMedicalRules">

        <!--Set the Endpoint Identity for the Service using the RP certificate-->

        <identity>

          <certificateReference findValue="A70012841C8E6E8C8CA5E9E2D78B04C3A64EB26C"

             isChainIncluded="false"

             storeName="My"

             storeLocation="LocalMachine"

             x509FindType="FindByThumbprint"/>

        </identity>

      </endpoint>

    </client>

  </system.serviceModel>

</configuration>

0

        private static string GetToken(string username, string password)

        {

            string tokenEndpoint = "https://michael-wf1.thedotnetfactory.internal:7080/webservice/service/rawtoken";

 

            XmlDocument doc = new XmlDocument() { PreserveWhitespace = true, XmlResolver = null };

            doc.LoadXml(string.Format("<credential username=\"{0}\" password=\"{1}\"></credential>", username,password));

 

            string authXml = doc.DocumentElement.OuterXml;

 

            var data = UTF8Encoding.UTF8.GetBytes(authXml);

            HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(tokenEndpoint);

            webrequest.Method = "POST";

            webrequest.ContentType = "application/x-www-form-urlencoding";

            webrequest.ContentLength = data.Length;

 

            using (Stream newStream = webrequest.GetRequestStream())

            {

                newStream.Write(data, 0, data.Length);

                newStream.Close();

                using (HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse())

                {

                    using (StreamReader responseStream = new StreamReader(webresponse.GetResponseStream(), Encoding.Default))

                    {

                        var xmlResponse = new XmlDocument();

                        xmlResponse.Load(responseStream);

 

                        string xml = xmlResponse.DocumentElement.OuterXml;

                        responseStream.Close();

                        webresponse.Close();

                        return xml;

                    }

                }

            }

        }

        public static string InvokeWorkflow(string token, string xmlRequest)

        {

            var postData = string.Format("workflow|Xml|Xml|{0}", xmlRequest);

            string serviceEndpoint = "https://michael-wf1.thedotnetfactory.internal:7080/webservice/service/Request";

 

            var data = UTF8Encoding.UTF8.GetBytes(postData);

            HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(serviceEndpoint);

 

            webrequest.Headers[HttpRequestHeader.Authorization] = token;

            webrequest.Method = "POST";

            webrequest.ContentType = "application/x-www-form-urlencoding";

            webrequest.ContentLength = data.Length;

 

            using (Stream newStream = webrequest.GetRequestStream())

            {

                newStream.Write(data, 0, data.Length);

                newStream.Close();

                using (HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse())

                {

                    using (StreamReader responseStream = new StreamReader(webresponse.GetResponseStream(), Encoding.Default))

                    {

                        string xml = responseStream.ReadToEnd();

                        responseStream.Close();

                        webresponse.Close();

                        return xml;

                    }

                }

            }

 

        }

        private static XmlDocument CreateDocument(string xml, out XmlNamespaceManager manager)

        {

            var doc = new XmlDocument();

            doc.LoadXml(xml);

 

            string cleamXml = System.Web.HttpUtility.HtmlDecode(doc.DocumentElement.ChildNodes[0].OuterXml);

            doc = new XmlDocument();

            doc.LoadXml(cleamXml);

 

            manager = new XmlNamespaceManager(doc.NameTable);

            manager.AddNamespace("EID", "http://empowerid.sts.com/svc/2010/03/schemas");

            return doc;

        }

        static void Main(string[] args)

        {

            //Get security token

            string token = GetToken("empoweridadmin", "********);

 

            XmlNamespaceManager pmanager = null;

            XmlDocument tokenDoc = CreateDocument(token, out pmanager);

            token = tokenDoc.DocumentElement.OuterXml;

 

            //Create workflow request XML

            XmlWorkflowRequest request = new XmlWorkflowRequest();

            request.RequestWorkflow = "DemoTestFlowChart1";

            request.RequestType = WorkflowRequestType.OnStartWorkflow;

 

            string requestXml = request.GetXml();

 

            //Invoke workflow

            string xmlResponse = InvokeWorkflow(token, requestXml);

 

            //Consume workflow response

            XmlNamespaceManager manager = null;

            XmlDocument doc = CreateDocument(xmlResponse,out manager);

 

            string friedlyName = doc.SelectSingleNode("/DemoTestFlowChart1Properties/demoSunHFormActivity1FormData/TargetPerson/EID:FriendlyName",manager).InnerText;

            Console.WriteLine(friedlyName);

 

 

            string workflowInstanceId = doc.SelectSingleNode("/DemoTestFlowChart1Properties/demoSunHFormActivity1FormData/WorkflowInstanceId", manager).InnerText;

            string correlationId = doc.SelectSingleNode("/DemoTestFlowChart1Properties/demoSunHFormActivity1FormData/BusinessProcessCorrelationId", manager).InnerText;

 

            request = new XmlWorkflowRequest();

            request.RequestWorkflow = "DemoTestFlowChart1";

            request.RequestType = WorkflowRequestType.OnUpdated;

            request.WorkflowInstanceId = new Guid(workflowInstanceId);

            request.WorkflowCorrelationID = new Guid(correlationId);

 

            Metadata targetPerson = new Metadata { Name = "TargetPerson", Type = "C.Person" };

            targetPerson.Properties.Add(new Metadata{ Name = "FriendlyName", Type= typeof(string).FullName, Value = "Patrick H. Parker"});

 

            Metadata doctorEmail = new Metadata { Name = "DoctorEmail", Type = typeof(string).FullName, Value = "jason@google.com" };

            request.TaskProperties.Add(targetPerson);

            request.TaskProperties.Add(doctorEmail);

 

            requestXml = request.GetXml();

 

           string xmlResumeResponse = InvokeWorkflow(token, requestXml);

           doc = CreateDocument(xmlResumeResponse, out manager);

 

           string notes = doc.SelectSingleNode("/DemoTestFlowChart1Properties/demoSunHFormActivity1FormData/DoctorNotes", manager).InnerText;

           Console.WriteLine(friedlyName);

        }

0

New wiki article posted. It gives a good overview of the EmpowerID Metadirectory and related topics such as inventory, attribute flow, and permissions enforcement.

 

Understanding the EmpowerID Metadirectory

0

DemoTestFlowChart1ServiceClient client = new DemoTestFlowChart1ServiceClient();

 

            client.ClientCredentials.UserName.UserName = "empoweridadmin";

            client.ClientCredentials.UserName.Password = "**********";

 

            WorkflowAsServiceContext context = new WorkflowAsServiceContext { RequestWorkflowByName = "DemoTestFlowChart1"};

 

 

            if (client.HasRightsToCall("StartExecutingDemoTestFlowChart1"))

            {

                DemoTestFlowChart1Properties prop = client.StartExecutingDemoTestFlowChart1(context, new DemoTestFlowChart1Properties());

 

                demoSunHFormActivity1FormData editForm = prop.demoSunHFormActivity1FormData;

                editForm.TargetPerson = new Person { FriendlyName = "MICHAEL" };

                editForm.DoctorEmail = "JAMESLEE@GOOGLE.COM";

 

                editForm.WorkflowInstanceId = prop.WorkflowInstanceId;

                editForm.BusinessProcessCorrelationId = prop.BusinessProcessCorrelationId;

 

                if (client.HasRightsToCall("ResumedemoSunHFormActivity1"))

                {

                    prop = client.ResumedemoSunHFormActivity1(context, editForm, new Metadata[] { });

                }

                Console.WriteLine(prop.demoSunHFormActivity1FormData.DoctorNotes);

            }

0

            SecurityToken adfsToken = WSSecurityTokenService.IssueADFSToken(TheDotNetFactory.Framework.ADFSEndPoint.WindowsTransport,

                "https://michaelamanfi.thedotnetfactory.internal/adfs/services/trust/13/windowstransport",                

                "https://michaelamanfi.thedotnetfactory.internal/empowerid/services/trust");

 

//WCF Service

            DemoMedicalRulesClient client = new DemoMedicalRulesClient();

            client.ChannelFactory.ConfigureChannelFactory();

 

            DemoMedicalRules iWcf = client.ChannelFactory.CreateChannelWithIssuedToken(adfsToken);

            EmailOutObject output = iWcf.DoesEmailHasGoogleDomain(new EmailObject { DoctorEmail = "michael@google.com", FriendlyName = "Dr. James" });

 

//SOAP Web Service

 

            string tokenXml = ((GenericXmlSecurityToken)adfsToken).TokenXml.OuterXml;

 

            SOAP.DemoMedicalRulesWebService soapClient = new SOAP.DemoMedicalRulesWebService();

            soapClient.EIDClientCredentialValue = new SOAP.EIDClientCredential

            {

                Token = tokenXml

            };

 

            SOAP.EmailOutObject soapOutput = soapClient.DoesEmailHasGoogleDomain(new SOAP.EmailObject { DoctorEmail = "michael@google.com", FriendlyName = "Dr. James" });

 

            Console.WriteLine(soapOutput.DisplayText);

 

//REST Web Service

            RESTWebServiceRequest request = new RESTWebServiceRequest();

            request.ServiceContract = "DemoMedicalRules";

            request.OperationContract = "DoesEmailHasGoogleDomain";

 

            List<RESTOperationParameter> emailObjProps = new List<RESTOperationParameter>

            {

                new RESTOperationParameter("DoctorEmail",typeof(string).FullName,"michael@google.com"),

                new RESTOperationParameter("FriendlyName",typeof(string).FullName,"Dr. James")

            };

 

            RESTOperationParameter eObject = new RESTOperationParameter("context", RESTType.GetBREType("DemoMedicalRules", "EmailObject"), emailObjProps);

            request.Parameters.Add(eObject);

 

            string serviceCallXml = request.ToXml().OuterXml;

 

            string outXml = RESTWebService.InvokeWebService("https://michael-wf1.thedotnetfactory.internal:7080",

                adfsToken, serviceCallXml, RESTWebMessageFormat.Xml, RESTWebMessageFormat.Xml);

0

     string workflowServiceUrl = "https://michael-wf1.thedotnetfactory.internal:7080";

 

            SecurityToken token = EIDServerContext.IssueToken(workflowServiceUrl, "empoweridadmin", "********");

 

            TheDotNetFactory.Framework.RemoteDatabaseContext.CreateContext(token,workflowServiceUrl);

            TheDotNetFactory.Framework.EmpowerIDContext.EstablishClientApplicationTrust(token);

 

            EIDServerContext serverContext = EIDServerContext.CreateContext(token, workflowServiceUrl);

 

            RequestWorkflow requestWorkflow = RequestWorkflow.GetByName("DemoTestFlowChart1");

 

            EIDWorkflow workflow = serverContext.CreateWorkflow(requestWorkflow.RequestWorkflowID);

 

            Dictionary<string,object> workflowParameters = new Dictionary<string,object>();

            EIDWorkflowInstance instance = workflow.StartWorkflow(workflowParameters);

            if (!instance.IsCompleted)

            {

                if (instance.HasWorkflowTask)

                {

                    SecurityToken patrickToken = serverContext.IssueTokenOnBehalfOf("patrick");

                    EIDServerContext patrickServerContext = EIDServerContext.CreateContext(patrickToken, workflowServiceUrl);

 

                    EIDWorkflowInstance taskInstance = new EIDWorkflowInstance(patrickServerContext, instance.WorkflowInstanceId,

                        instance.CorrelationId);

 

                    EIDWorkflowTask pTaks = taskInstance.GetWorkflowTask();

                    WorkflowData pFormData = pTaks.GetWorkflowData();

 

                    Console.WriteLine(pFormData.Properties["DoctorNotes"]);

 

                    taskInstance = taskInstance.ResumeWorkflow(pFormData.Properties, patrickToken);

                    Console.WriteLine(taskInstance.Response.ResponseType.ToString());

                }                   

            }

0

            string workflowServiceUrl = "https://michael-wf1.thedotnetfactory.internal:7080";

 

            SecurityToken token = EIDServerContext.IssueToken(workflowServiceUrl, "empoweridadmin", "********");

 

            TheDotNetFactory.Framework.RemoteDatabaseContext.CreateContext(token,workflowServiceUrl);

            TheDotNetFactory.Framework.EmpowerIDContext.EstablishClientApplicationTrust(token);

 

            EIDServerContext serverContext = EIDServerContext.CreateContext(token, workflowServiceUrl);

 

            RequestWorkflow requestWorkflow = RequestWorkflow.GetByName("DemoTestFlowChart1");

 

            EIDWorkflow workflow = serverContext.CreateWorkflow(requestWorkflow.RequestWorkflowID);

 

            Dictionary<string,object> workflowParameters = new Dictionary<string,object>();

            EIDWorkflowInstance instance = workflow.StartWorkflow(workflowParameters);

            if (!instance.IsCompleted)

            {

                if (instance.HasUI && !instance.HasWorkflowTask)

                {         

                    WorkflowTask task = instance.TemporaryUIData;

                    IDictionary<string, object> formData = task.WorkflowTaskDefinition.Properties;

                    formData["DoctorEmail"] = "testers@google.com";

                    string ucx = formData["UserControlPath"] as string;

 

                    EIDWorkflowInstance resumedInstance = instance.ResumeWorkflow(formData, token);

 

                    if (!resumedInstance.IsCompleted)

                    {

                         task = resumedInstance.TemporaryUIData;

                        formData = task.WorkflowTaskDefinition.Properties;

 

                        Console.WriteLine(formData["DoctorNotes"]);

                    }

                }

            }

0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Microsoft.IdentityModel.Claims;

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        IClaimsIdentity identity = this.User.Identity as IClaimsIdentity;

 

        string role = identity.RoleClaimType;

        string name = identity.NameClaimType;

 

        Response.Write("Name ClaimType: " + name+"<br>");

        Response.Write("Role ClaimType: " + role + "<br>");

 

        Response.Write("******************************************************<br>");

        foreach (Claim c in identity.Claims)

        {

            Response.Write(string.Format("{0} = {1}", c.ClaimType, c.Value) + "<br>");

        }

 

        if (this.User.IsInRole("Managers"))

        {

            Response.Write("Yes, you're a Manager!");

        }

        else

        {

            Response.Write("Access denied: You need to be a Manager.");

        }

    }

}

0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using TheDotNetFactory.Framework.SAML2.Assertions;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        SAMLAssertion samlAssertion = HttpContext.Current.Session["samlAssertion"] as SAMLAssertion;

 

        foreach (IStatement s in samlAssertion.Statements)

        {

            AttributeStatement statement = s as AttributeStatement;

            if (statement != null)

            {

                foreach (object a in statement.Attributes)

                {

                    SAMLAttribute displayName = a as SAMLAttribute;

                    if (displayName != null)

                    {

                        Response.Write("Attribute: " +displayName.Name +" "+ displayName.Values[0].Data);

                    }

                }

            }       

        }              

    }

}

0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

 

/// <summary>

/// Summary description for Utility

/// </summary>

public class Utility

{

    public const string IDPURL = "https://michael-wf1.thedotnetfactory.internal/EmpowerIDIdpForms/AuthRequest/SSOAuthServicePost.aspx?ssoconnect=11d04a12-2f10-4969-acce-bb3ac4ad76d5";

    public const string SIGNING_CERT_THUMBPRINT = "‎a70012841c8e6e8c8ca5e9e2d78b04c3a64eb26c";

}

0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Security.Cryptography.X509Certificates;

using TheDotNetFactory.Framework.SAML2.Protocols;

using TheDotNetFactory.Framework.SAML2.Profiles.SSOBrowser;

using Microsoft.Practices.EnterpriseLibrary.Data.Communication.FederatedSecurity;

using System.Security.Cryptography.Xml;

using TheDotNetFactory.Framework.SAML2.Bindings;

using System.Xml;

using System.Web.Security;

using TheDotNetFactory.Framework.SAML2.Assertions;

 

public partial class SAML_AssertionConsumerService : System.Web.UI.Page

{

    private void ReceiverSAMLResponse(out SAMLResponse samlResponse, out string relayState)

    {

        XmlElement samlResponseXml = null;

        ServiceProvider.ReceiveSAMLResponseByHTTPPost(Request, out samlResponseXml, out relayState);

 

        if (SAMLMessageSignature.IsSigned(samlResponseXml))

        {

            X509Certificate2 signingCert = CertificateUtility.GetCertificate(StoreName.My, StoreLocation.LocalMachine, Utility.SIGNING_CERT_THUMBPRINT);

            if (!SAMLMessageSignature.Verify(samlResponseXml, signingCert))

                throw new Exception("Unable to verify saml assertion.");

        }

        samlResponse = new SAMLResponse(samlResponseXml);

    }

    private void ProcessSAMLResponse(SAMLResponse samlResponse, string relayState)

    {

        if (!samlResponse.IsSuccess())

            throw new Exception("Received error response.");

 

        SAMLAssertion samlAssertion = samlResponse.GetAssertions()[0];

        if (!AssertionIDCache.Add(samlAssertion))

            throw new Exception("The SAML assertion has already been used.");

 

        HttpContext.Current.Session["samlAssertion"] = samlAssertion;

        string userName = samlAssertion.Subject.NameID.NameIdentifier;

        FormsAuthentication.SetAuthCookie(userName, false);

 

        if (!string.IsNullOrEmpty(relayState))

        {

            RelayState state = RelayStateCache.Get(relayState);

            string orginalUrl = state.ResourceURL;

            Response.Redirect(orginalUrl);

        }

        else

        {

            Response.Redirect("~/Default.aspx", false);

        }

 

    }

    protected void Page_Load(object sender, EventArgs e)

    {

        if (Request.IsAuthenticated)

        {

            Response.Redirect("~/Default.aspx");

            return;

        }

        else

        {

            SAMLResponse samlResponse = null;

            string relayState = null;

 

            //Receive SAML assertion

            ReceiverSAMLResponse(out samlResponse, out relayState);

 

            //Decrypt and Consume SAML assertion

            ProcessSAMLResponse(samlResponse, relayState);

        }

    }

}