13693261870
2022-09-20 a666b5f9741ef9b21f547d3b2141752a0383c70c
src/java/org/apereo/cas/web/flow/SendTicketGrantingTicketAction.java
@@ -13,6 +13,10 @@
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
/**
 * @author Tanbin
 * @date   2018-12-12
 */
public class SendTicketGrantingTicketAction extends AbstractAction {
  private static final Logger LOGGER = LoggerFactory.getLogger(SendTicketGrantingTicketAction.class);
  
@@ -26,11 +30,15 @@
  
  private AuthenticationSystemSupport authenticationSystemSupport;
  
  private  static String mRenew = "renew";
  @Override
  protected Event doExecute(RequestContext context) {
    String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
    String ticketGrantingTicketValueFromCookie = (String)context.getFlowScope().get("ticketGrantingTicketId");
    if (ticketGrantingTicketId == null)
    if (ticketGrantingTicketId == null) {
      return success(); 
    }
    if (WebUtils.isAuthenticatingAtPublicWorkstation(context)) {
      LOGGER.info("Authentication is at a public workstation. SSO cookie will not be generated. Subsequent requests will be challenged for authentication.");
    } else if (!this.createSsoSessionCookieOnRenewAuthentications && isAuthenticationRenewed(context)) {
@@ -40,15 +48,16 @@
      this.ticketGrantingTicketCookieGenerator.addCookie(WebUtils.getHttpServletRequest(context), 
          WebUtils.getHttpServletResponse(context), ticketGrantingTicketId);
    } 
    if (ticketGrantingTicketValueFromCookie != null && !ticketGrantingTicketId.equals(ticketGrantingTicketValueFromCookie))
    if (ticketGrantingTicketValueFromCookie != null && !ticketGrantingTicketId.equals(ticketGrantingTicketValueFromCookie)) {
      this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicketValueFromCookie); 
    }
    return success();
  }
  
  public void setCreateSsoSessionCookieOnRenewAuthentications(boolean createSsoSessionCookieOnRenewAuthentications) { this.createSsoSessionCookieOnRenewAuthentications = createSsoSessionCookieOnRenewAuthentications; }
  
  private boolean isAuthenticationRenewed(RequestContext ctx) {
    if (ctx.getRequestParameters().contains("renew")) {
    if (ctx.getRequestParameters().contains(mRenew)) {
      LOGGER.debug("[{}] is specified for the request. The authentication session will be considered renewed.", "renew");
      return true;
    }