This software has been lightly tested against the CAS infrastructure at Virginia Tech. Pending further testing, it should be considered alpha software. The CTU group at Tech supports its use in the Virginia Tech environment, and we encourage its use there. Groups outside the University are encouraged to use it with the understanding that we cannot support it outside Virginia Tech. Feedback, bug reports, and feature requests are welcome: myvt@vt.edu.
CasClient.dll - Version 0.1a compiled against .NET Framework 1.1. This version has passed testing in the following environments:
Although it has not been tested in C++.NET or with .NET Framework versions prior to 1.1, we have no reason to suspect it would not work fine in those environments as well.
Add the CasClient.dll assembly to the References section of your project(s) before using the CasClient class in your code as in the examples below.
'// CAS protocol 2.0 authentication example (preferred) Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim message As String Dim client As Ctu.Cas.Client.CasClient Dim useSession As Boolean '// Uncomment the line below if you do not wish to use Session to store '// the results of authentication. The consequence of not using Session storage '// is an additional round trip with the CAS server on every page '//client = New Ctu.Cas.Client.CasClient(False) client = New Ctu.Cas.Client.CasClient() client.CasServerName = "auth.vt.edu" If client.ServiceValidate(Me) Then message = "Service validation succeeded for user " + client.GetNetId Else message = "Service validation failed." End If System.Diagnostics.Debug.WriteLine(message) Label1.Text = message End Sub '// CAS protocol 1.0 authentication example Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim message As String Dim client As Ctu.Cas.Client.CasClient Dim useSession As Boolean '// Uncomment the line below if you do not wish to use Session to store '// the results of authentication. The consequence of not using Session storage '// is an additional round trip with the CAS server on every page '//client = New Ctu.Cas.Client.CasClient(False) client.CasServerName = "auth.vt.edu" If client.Validate(Me) Then message = "Validation succeeded for user " + client.GetNetId Else message = "Validation failed." End If System.Diagnostics.Debug.WriteLine(message) Label1.Text = message End Sub |
// CAS protocol 2.0 authentication example (preferred) private void Page_Load(object sender, System.EventArgs e) { string message; Ctu.Cas.Client.CasClient client; // Uncomment the line below if you do not wish to use Session to store // the results of authentication. The consequence of not using Session storage // is an additional round trip with the CAS server on every page //client = new Ctu.Cas.Client.CasClient(False) client = new Ctu.Cas.Client.CasClient(); client.CasServerName = "auth.vt.edu"; if (client.ServiceValidate(this)) message = "Service validation succeeded for user " + client.GetNetId(); else message = "Service validation failed."; System.Diagnostics.Debug.WriteLine(message); Label1.Text = message; } // CAS protocol 1.0 authentication example private void Page_Load(object sender, System.EventArgs e) { string message; Ctu.Cas.Client.CasClient client; // Uncomment the line below if you do not wish to use Session to store // the results of authentication. The consequence of not using Session storage // is an additional round trip with the CAS server on every page //client = new Ctu.Cas.Client.CasClient(False) client.CasServerName = "auth.vt.edu"; if (client.Validate(this)) message = "Validation succeeded for user " + client.GetNetId(); else message = "Validation failed."; System.Diagnostics.Debug.WriteLine(message); Label1.Text = message; } |
The .NET CAS client has logging features provided by the .NET Tracing capability; the log messages are invaluable for identifying and resolving bugs. Tracing is enabled by modifying the Web.config file of the CAS-enabled ASP.NET Web application. Add the code below to the Web.config file immediately following the <system.web> node:
<system.diagnostics> <trace autoflush="true" indentsize="2"> <listeners> <remove name="Default"/> <!-- Customize log file location as necessary. Log file must be writable by ASPNET account! --> <add name="TraceLog" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\CasClientTest.log"/> </listeners> </trace> </system.diagnostics> |