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.