C# Class NGM.CasClient.Client.Utils.UrlUtil

An internal class used to generate and modify URLs as needed for redirection and external communication.
See https://wiki.jasig.org/display/CASC/UrlUtil+Methods for additional information including sample output of each method.
Inheritance: IUrlUtil
Mostra file Open project: NIKASoftwareDevs/Orchard

Private Properties

Property Type Description

Public Methods

Method Description
ConstructLoginRedirectUrl ( bool gateway, bool renew, bool gatewayCheck ) : string

Constructs the URL to use for redirection to the CAS server for login

The server name is not parsed from the request for security reasons, which is why the service and server name configuration parameters exist.

ConstructProxyCallbackUrl ( ) : string

Constructs a proxy callback URL containing a ProxyCallbackParameter (proxyResponse by default). This URL is sent to the CAS server during a proxy ticket request and is then connected to by the CAS server. If the CAS server cannot successfully connect (generally due to SSL configuration issues), the CAS server will refuse to send a proxy ticket.

This is a .NET implementation specific method used to eliminate the need for a special HTTP Handler. Essentially, if the client detects an incoming request with the ProxyCallbackParameter in the URL (i.e., proxyResponse), that request is treated specially and behaves as if it were handled by an HTTP Handler. In other words, this behavior may or may not short circuit the request event processing and will not allow the underlying page to execute and transmit back to the client. If your application does coincidentally make use of the key 'proxyResponse' as a URL parameter, you will need to configure a custom proxyCallbackParameter value which does not conflict with the URL parameters in your application.

ConstructProxyTicketRequestUrl ( string proxyGrantingTicketId, string targetService ) : string

Constructs a proxy ticket request URL containing both a proxy granting ticket and a URL Encoded targetServiceUrl. The URL returned will generally only be executed by the CAS client as a part of a proxy redirection in CasAuthentication.ProxyRedirect(...) or CasAuthentication.GetProxyTicketIdFor(...) but may also be used by applications which require low-level access to the proxy ticket request functionality.

ConstructServiceUrl ( bool gateway ) : string

Constructs a service URL using configured values in the following order: 1. if not empty, the value configured for Service is used - otherwise - 2. the value configured for ServerName is used together with HttpRequest data

The server name is not parsed from the request for security reasons, which is why the service and server name configuration parameters exist, per Jasig website.

ConstructSingleSignOutRedirectUrl ( ) : string

Constructs the URL to use for redirection to the CAS server for single signout. The CAS server will invalidate the ticket granting ticket and redirect back to the current page. The web application must then call ClearAuthCookie and revoke the ticket from the ServiceTicketManager to sign the client out.

ConstructValidateUrl ( string serviceTicket, bool gateway, bool renew, NameValueCollection customParameters ) : string

Constructs a URL used to check the validitiy of a service ticket, with or without a proxy callback URL, and with or without requiring renewed credentials.

See CAS Protocol specification, section 2.5

GetProxyRedirectUrl ( string targetService, string>.Func getProxyTicket ) : string

Attempts to request a proxy ticket for the targetService specified and returns a URL appropriate for redirection to the targetService containing a ticket.

GetProxyRedirectUrl ( string targetService, string proxyTicketUrlParameter, string>.Func getProxyTicket ) : string

Attempts to request a proxy ticket for the targetService specified and returns a URL appropriate for redirection to the targetService containing a ticket.

RemoveCasArtifactsFromUrl ( string url ) : string

Returns a copy of the URL supplied modified to remove CAS protocol-specific URL parameters.

ResolveUrl ( string url ) : string

Resolves a relative ~/Url to a Url that is meaningful to the client. Derived from: http://weblogs.asp.net/palermo4/archive/2004/06/18/getting-the-absolute-path-in-asp-net-part-2.aspx

UrlUtil ( IOrchardServices orchardServices, Lazy ticketValidatorFactory ) : System

Method Details

ConstructLoginRedirectUrl() public method

Constructs the URL to use for redirection to the CAS server for login
The server name is not parsed from the request for security reasons, which is why the service and server name configuration parameters exist.
public ConstructLoginRedirectUrl ( bool gateway, bool renew, bool gatewayCheck ) : string
gateway bool
renew bool
gatewayCheck bool
return string

ConstructProxyCallbackUrl() public method

Constructs a proxy callback URL containing a ProxyCallbackParameter (proxyResponse by default). This URL is sent to the CAS server during a proxy ticket request and is then connected to by the CAS server. If the CAS server cannot successfully connect (generally due to SSL configuration issues), the CAS server will refuse to send a proxy ticket.
This is a .NET implementation specific method used to eliminate the need for a special HTTP Handler. Essentially, if the client detects an incoming request with the ProxyCallbackParameter in the URL (i.e., proxyResponse), that request is treated specially and behaves as if it were handled by an HTTP Handler. In other words, this behavior may or may not short circuit the request event processing and will not allow the underlying page to execute and transmit back to the client. If your application does coincidentally make use of the key 'proxyResponse' as a URL parameter, you will need to configure a custom proxyCallbackParameter value which does not conflict with the URL parameters in your application.
public ConstructProxyCallbackUrl ( ) : string
return string

ConstructProxyTicketRequestUrl() public method

Constructs a proxy ticket request URL containing both a proxy granting ticket and a URL Encoded targetServiceUrl. The URL returned will generally only be executed by the CAS client as a part of a proxy redirection in CasAuthentication.ProxyRedirect(...) or CasAuthentication.GetProxyTicketIdFor(...) but may also be used by applications which require low-level access to the proxy ticket request functionality.
public ConstructProxyTicketRequestUrl ( string proxyGrantingTicketId, string targetService ) : string
proxyGrantingTicketId string /// The proxy granting ticket used to authorize the request for a proxy ticket on the /// CAS server ///
targetService string /// The target service URL to request a proxy ticket request URL for ///
return string

ConstructServiceUrl() public method

Constructs a service URL using configured values in the following order: 1. if not empty, the value configured for Service is used - otherwise - 2. the value configured for ServerName is used together with HttpRequest data
The server name is not parsed from the request for security reasons, which is why the service and server name configuration parameters exist, per Jasig website.
public ConstructServiceUrl ( bool gateway ) : string
gateway bool
return string

ConstructSingleSignOutRedirectUrl() public method

Constructs the URL to use for redirection to the CAS server for single signout. The CAS server will invalidate the ticket granting ticket and redirect back to the current page. The web application must then call ClearAuthCookie and revoke the ticket from the ServiceTicketManager to sign the client out.
public ConstructSingleSignOutRedirectUrl ( ) : string
return string

ConstructValidateUrl() public method

Constructs a URL used to check the validitiy of a service ticket, with or without a proxy callback URL, and with or without requiring renewed credentials.
See CAS Protocol specification, section 2.5
public ConstructValidateUrl ( string serviceTicket, bool gateway, bool renew, NameValueCollection customParameters ) : string
serviceTicket string The service ticket to validate.
gateway bool /// whether or not to include gatewayResponse=true in the request (client specific). ///
renew bool /// Whether or not renewed credentials are required. If True, ticket validation /// will fail for Single Sign On credentials. ///
customParameters System.Collections.Specialized.NameValueCollection custom parameters to add to the validation URL
return string

GetProxyRedirectUrl() public method

Attempts to request a proxy ticket for the targetService specified and returns a URL appropriate for redirection to the targetService containing a ticket.
public GetProxyRedirectUrl ( string targetService, string>.Func getProxyTicket ) : string
targetService string The target service for proxy authentication
getProxyTicket string>.Func
return string

GetProxyRedirectUrl() public method

Attempts to request a proxy ticket for the targetService specified and returns a URL appropriate for redirection to the targetService containing a ticket.
public GetProxyRedirectUrl ( string targetService, string proxyTicketUrlParameter, string>.Func getProxyTicket ) : string
targetService string The target service for proxy authentication
proxyTicketUrlParameter string /// The name of the ticket URL parameter expected by the target service (ticket by /// default) ///
getProxyTicket string>.Func
return string

RemoveCasArtifactsFromUrl() public method

Returns a copy of the URL supplied modified to remove CAS protocol-specific URL parameters.
public RemoveCasArtifactsFromUrl ( string url ) : string
url string The URL to remove CAS artifacts from
return string

ResolveUrl() public method

Resolves a relative ~/Url to a Url that is meaningful to the client. Derived from: http://weblogs.asp.net/palermo4/archive/2004/06/18/getting-the-absolute-path-in-asp-net-part-2.aspx
public ResolveUrl ( string url ) : string
url string The Url to resolve
return string

UrlUtil() public method

public UrlUtil ( IOrchardServices orchardServices, Lazy ticketValidatorFactory ) : System
orchardServices IOrchardServices
ticketValidatorFactory Lazy
return System