Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Development of the .NET client was done on Visual Studio 2005. A working knowledge of developing projects on Visual Studio is required before proceeding with this guide. The .NET client for the Grouper WS is merely proof of concept and as such, the UI is very simplistic. All relevant files can be found in the Attachment section.

Creating a client to consume a Basic Auth enabled Grouper WS

Once you have a client application (project) in place, you will need to add a proxy class to the project that allows the client to access the Grouper WS. The following example describes how to create a Web service client and generate a proxy class that allows the client to access the Grouper WS.

...

Copy the code below onto the Web Form:

No Format

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
    BasicAuthGrouper.WsGroup[] wsGroupArray = null;

    try
    {

        /************************/

        /******* Grouper ********
         * "Grouper" policy requires the wse3 extensions, to create the policy
         * you'll need the wse3 plugin for visual studio, then right click the
         * project and select "wse3 settings" then use a user/pass based authentication
         * method, specify the password and don't use the ws security extensions.
         */

        BasicAuthGrouper.GrouperService gws = new BasicAuthGrouper.GrouperService();

        //setting up Basic Auth stuff
        NetworkCredential netCredential = new NetworkCredential("Username", "Password");
        Uri uri = new Uri(gws.Url);
        ICredentials credentials = netCredential.GetCredential(uri, "Basic");
        gws.Credentials = credentials;
        gws.PreAuthenticate = true;

        BasicAuthGrouper.WsGetGroupsLiteResult wsgglr = gws.getGroupsLite("v1_3_000", "ncf17@ncl.ac.uk", "", "", "All", "", "", "", "", "", "", "", "", "", "");
        wsGroupArray = wsgglr.wsGroups;

        /*************************/
    }
    catch(Exception e)
    {
%>
        <%= e.ToString() %>
<%
    }
%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>
    <div>

Grouper says:<br />
<%
    try
    {
        for(int i=0;i<wsGroupArray.Length;i++)
        {
%>
        <br />
        /******WsGroup <%= i+1 %>*******/<br />
        Description: <%= (wsGroupArray[i]).description %><br />
        Detail: <%= (wsGroupArray[i]).detail %><br />
        Display Extension: <%= (wsGroupArray[i]).displayExtension %><br />
        Display Name: <%= (wsGroupArray[i]).displayName %><br />
        Extension: <%= (wsGroupArray[i]).extension %><br />
        Name: <%= (wsGroupArray[i]).name %><br />
        Uuid: <%= (wsGroupArray[i]).uuid %><br />
<%
        }
    }
    catch(Exception e)
    {
%>
        Error: <%= e.ToString() %>
<%
    }
%>
    </div>
</body>
</html>

 It should be noted that the BasicAuthGrouper from the line of code below is the name given to the Web Reference in Step 4. Packages in Java are named in a similiar fashion.

No Format

BasicAuthGrouper.GrouperService gws = new BasicAuthGrouper.GrouperService();

...

A pre-authentication mode has to be set the authorization header on every request. The recommended way to get preauthentication is to set the credentials on the request, set PreAuthenticate=true (in Step 6), and send the request. Once the first authentication handshake happens, and credentials are accepted by the server, preauthentication will happen behind the scenes for every request to the same Uri-Prefix.

 Creating a client to consume a Rampart enabled Grouper WS

Web Services Enhancements 3.0 (WSE3) for Microsoft® .NET implements WS-Security standards on a .NET framework and has to be installed before it can interoperate with a Rampart enabled service. Rampart is the open source implementation of WS-Security standards and a .NET client should be able invoke a Rampart enabled service as they both support WS-Security standards.

...

Right click on the Project and select Add New Item. Then select Web Configuration File and name it WSE3Policy and untick the Place code in separate file box.. You should now have a WSE3Policy.config file in your project domain. Open the WSE3Policy.config file and copy the policy below into WSE3Policy.config:

No Format

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
  <extensions>
    <extension name="usernameForCertificateSecurity" type="Microsoft.Web.Services3.Design.UsernameForCertificateAssertion," +
    		" Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="x509" type="Microsoft.Web.Services3.Design.X509TokenProvider, Microsoft.Web.Services3, " +
    		"Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion, " +
    		"Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion, " +
    		"Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="username" type="Microsoft.Web.Services3.Design.UsernameTokenProvider, " +
    		"Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="kerberosSecurity" type="Microsoft.Web.Services3.Design.KerberosAssertion, " +
    		"Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="kerberos" type="Microsoft.Web.Services3.Design.KerberosTokenProvider, " +
    		"Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </extensions>
  <policy name="Grouper">
    <usernameOverTransportSecurity>
      <clientToken>
        <username username="Username" password="Password" />
      </clientToken>
    </usernameOverTransportSecurity>
    <requireActionHeader />
  </policy>
</policies>

...

Copy the code below onto the Web Form:

No Format

<%@ Page Language="C#" %>
<%@ Import Namespace="Microsoft.Web.Services3" %>
<%@ Import Namespace="Microsoft.Web.Services3.Security.Tokens" %>
<%@ Import Namespace="System.Net" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%

    RampartGrouper.WsGroup[] wsGroupArray = null;

    try
    {

        /************************/

        /******* Grouper ********
         * "Grouper" policy requires the wse3 extensions, to create the policy
         * you'll need the wse3 plugin for visual studio, then right click the
         * project and select "wse3 settings" then use a user/pass based authentication
         * method, specify the password and don't use the ws security extensions.
         */

        RampartGrouper.GrouperServiceWse gws = new RampartGrouper.GrouperServiceWse();
        gws.SetPolicy("Grouper");
        RampartGrouper.WsGetGroupsLiteResult wsgglr = gws.getGroupsLite("v1_3_000", "nsv12@ncl.ac.uk", "", "", "All", "", "", "", "", "", "", "", "", "", "");
        wsGroupArray = wsgglr.wsGroups;

        /*************************/
    }
    catch(Exception e)
    {
%>
        <%= e.ToString() %>
<%
    }
%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>
    <div>
RampartGrouper says:<br />
<%
    try
    {
        for(int i=0;i<wsGroupArray.Length;i++)
        {
%>
        <br />
        /******WsGroup <%= i+1 %>*******/<br />
        Description: <%= (wsGroupArray[i]).description %><br />
        Detail: <%= (wsGroupArray[i]).detail %><br />
        Display Extension: <%= (wsGroupArray[i]).displayExtension %><br />
        Display Name: <%= (wsGroupArray[i]).displayName %><br />
        Extension: <%= (wsGroupArray[i]).extension %><br />
        Name: <%= (wsGroupArray[i]).name %><br />
        Uuid: <%= (wsGroupArray[i]).uuid %><br />
<%
        }
    }
    catch(Exception e)
    {
%>
        Error: <%= e.ToString() %>
<%
    }
%>
    </div>
</body>
</html>

 The important item from the above code the Grouper policy is used in the following line of code:

No Format

gws.SetPolicy("Grouper");

...