Versions Compared

Key

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

...

Default.aspx (The CAS proxier) - Your main default page

<%@ Page
Code Block
htmlhtml
Panel
borderColor#cccccc
bgColor#ffffff
titleBGColor#eeeeee
titleDefault.aspx
borderStyledashed

Span
stylebackground-color:yellow
idhl

<%

@ Page Language="VB"

%> <script

Span
stylebackground-color:yellow
idhl

%>

<script runat="server">

Protected Sub


    Protected Sub Page_Load(ByVal

sender

As

Object, ByVal

e

As

System.EventArgs)

If


        If User.Identity.IsAuthenticated

Then 'Once we've returned from CAS after our proxied application has been authenticated, we will 'get the proxy response and output it to the browser If Not

Then
            If Not String.IsNullOrEmpty(CASAuthentication.ProxyAppResponse) Then


                Response.Write(String.Concat("Proxied

App

Response:

",

CASAuthentication.ProxyAppResponse))

End If End If End Sub Protected Sub


            EndIf
        End If
    End Sub

    Protected Sub btnRunTest_Click(ByVal

sender

As

Object,

ByVal

e

As

System.EventArgs)


            'First,

let's

add

some

proxy

arguments

to

send

to

the

CAS

proxy

proxy
            CASAuthentication.AddProxyArgument("arg1",

"hello")


            CASAuthentication.AddProxyArgument("arg2",

"world")

'The InvokeCASProxy method of the CASAuthentication class will tell CAS to create a proxy granting ticket IOU 'we can later use to get our "real" proxyTicket needed to authenticate our proxy with CAS If Not

            If Not CASAuthentication.InvokeCASProxy(ProxyAppUrl:="

<url

{url_to_your_CAS_Proxy_

Application>

Application}",

_

_
                pgtUrl:="

<secure

{secure_url_to_your_CAS_Callback_Url_

Application>

Application}",

_

_
                HttpMethodPost:=

False)

Then

Then
                Response.Write(CASAuthentication.LastError)

Return EndIf End Sub </script> <html> <head> <title>Test calling a CAS Proxy</title> </head> <body> <p><a


                Return
            EndIf
    End Sub
</script>

<html>
<head>
    <title>Test calling a CAS Proxy</title>
</head>
<body>
    <p><a href="LogOut.aspx"

>Log

>Log out

of

CAS</a></p> <p><asp:Button

CAS</a></p>
    <p><asp:Button ID="btnRunTest"

runat="server"

OnClick="btnRunTest_Click"

Text="Call

Test

Proxy"

/></

p>

p>
</

body>

body>
</

html>

html>

ProxyCallback.aspx - The CAS callback Url (This would be the same application page specified in the pgtUrl attribute in the call to InvokeCASProxy method shown above) - This assumes that your main application (the CAS proxier) and callback Url are part of the same application so that they can share application specific variables. If the callback Url is NOT part of the same application, then you must handle storing/retrieving the pgtIou/pgtId pair yourself. (e.g. store them in an external database).

...