Single Sign-on (vi) CAS RETROFIT--Exit to the specified page

Source: Internet
Author: User
Tags cas

CAS exit the default is to go to the CAS built-in exit page, in the actual application need to jump to their own designated page. Exit steering depends on Org.jasig.cas.web.LogoutController, let's look at the original code.

protected Modelandview handlerequestinternal (final httpservletrequest request, final Httpservle Tresponse response) throws Exception {final String Ticketgrantingticketid = This.ticketgrantingticketcook
        Iegenerator.retrievecookievalue (Request);

        Final String service = request.getparameter ("service");
        	if (Ticketgrantingticketid! = null) {System.out.println ("destroyed in Centralauthenticationservice");
            
            This.centralauthenticationservice. Destroyticketgrantingticket (Ticketgrantingticketid);
            This.ticketGrantingTicketCookieGenerator.removeCookie (response);
        This.warnCookieGenerator.removeCookie (response); } if (this.followserviceredirects && service! = null) {return new Modelandview (new REDIRECTV
        Iew (service));
    } return new Modelandview (This.logoutview); }

As can be seen, when this.followserviceredirects && service! = NULL jumps to its own specified view,service should be familiar with, it is the parameters of the customer pass,

Specify where to turn the CAS center, but we just pass the service or not, and we need to set the Followserviceredirects property to True, and see how to modify this property


Modify the Logoutcontroller in the Cas-servlet.xml configuration file, add the properties p:followserviceredirects= "true", and modify the following:

<bean id= "Logoutcontroller" class= "Org.jasig.cas.web.LogoutController"
		p:centralauthenticationservice-ref = "Centralauthenticationservice"
		p:logoutview= "Caslogoutview"
		p:followserviceredirects= "true"
		p: warncookiegenerator-ref= "Warncookiegenerator"
		p:ticketgrantingticketcookiegenerator-ref= " Ticketgrantingticketcookiegenerator "/>

Client Add Exit button:

<a href= "https://www.talkingdata.net:8446/logout?service=http://localhost:8082/" > Exit </a>

The client Cas-client2 is modified accordingly.


Test:

Restart Cas-server, Cas-client1, and cas-client2 for testing.

First use http://localhost:8081/to log in, after the login page is as follows:

Enter the address http://localhost:8082/for Cas-client2 in a new tab in the same browser, where the protected index.jsp can be accessed normally.

Click here to "Exit" link, you can see the browser and jump to the CAS login page. Because the service address of the exit link points to http://localhost:8081/, and the path is secured, it jumps to the CAS login page.

At this point, the Cas-client2 page is refreshed, the browser also jumps to the CAS login page, a single point exit test success.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.