Program: 188820
Project: 188820
Buggy source:
/** 
 * @see Filter#doFilter(ServletRequest,ServletResponse,FilterChain)
 */
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  boolean doFilter=true;
  logger.debug("String_Node_Str");
  if (request.getParameter("String_Node_Str") != null) {
    logger.debug("String_Node_Str");
    HttpServletRequest servletRequest=(HttpServletRequest)request;
    HttpServletResponse servletResponse=(HttpServletResponse)response;
    try {
      String ticket=request.getParameter("String_Node_Str");
      String cleanURL=getCleanURL(servletRequest);
      UserUtility.loginCas(servletRequest,cleanURL.toString(),ticket,new URL(casURL),new URL(coreURL));
      doFilter=false;
      logger.debug("String_Node_Str" + cleanURL.toString());
      servletResponse.sendRedirect(cleanURL.toString());
    }
 catch (    AuthenticationException e) {
      e.printStackTrace();
    }
  }
 else {
    HttpServletRequest servletRequest=(HttpServletRequest)request;
    HttpServletResponse servletResponse=(HttpServletResponse)response;
    if (servletRequest.getRequestURI().trim().equalsIgnoreCase("String_Node_Str")) {
      logger.debug("String_Node_Str");
      try {
        UserLoginServiceImpl.getInstance().logout();
      }
 catch (      Exception e) {
      }
      String cleanURL=getCleanURL(servletRequest);
      String urlToRedirectTo=CommonUtils.constructRedirectUrl(casLoginURL,"String_Node_Str",cleanURL,false,false);
      if (!this.gatewayStorage.hasGatewayedAlready(servletRequest,urlToRedirectTo)) {
        urlToRedirectTo=this.gatewayStorage.storeGatewayInformation(servletRequest,urlToRedirectTo);
        doFilter=false;
        servletResponse.sendRedirect(urlToRedirectTo);
      }
 else {
        doFilter=false;
        servletResponse.sendRedirect("String_Node_Str");
      }
    }
 else     if (servletRequest.getRequestURI().trim().equalsIgnoreCase("String_Node_Str")) {
      logger.debug("String_Node_Str");
      String cleanURL=getCleanURL(servletRequest);
      UserUtility.logout(servletRequest,new URL(casURL),new URL(coreURL));
      String urlToRedirectTo=CommonUtils.constructRedirectUrl(casLogoutURL,"String_Node_Str",cleanURL,false,false);
      doFilter=false;
      servletResponse.sendRedirect(urlToRedirectTo);
    }
 else {
      CASUserPrincipal cup=UserUtility.getUser(servletRequest);
      if (cup != null) {
        if (UserUtility.haveSessionActive(casUtility,servletRequest)) {
          String cleanURL=getCleanURL(servletRequest);
          String urlToRedirectTo=CommonUtils.constructRedirectUrl(casLoginURL,"String_Node_Str",cleanURL,false,false);
          if (!this.gatewayStorage.hasGatewayedAlready(servletRequest,urlToRedirectTo)) {
            urlToRedirectTo=this.gatewayStorage.storeGatewayInformation(servletRequest,urlToRedirectTo);
            doFilter=false;
            servletResponse.sendRedirect(urlToRedirectTo);
          }
 else {
            doFilter=false;
            servletResponse.sendRedirect("String_Node_Str");
          }
        }
      }
 else {
        try {
          CASUserPrincipal guestCUP=this.casUtility.getCASUserPrincipal(guestUsername,guestPassword,"String_Node_Str");
          guestCUP.setGuest(true);
          UserLoginServiceImpl.getInstance().loginCUP(servletRequest,guestCUP);
        }
 catch (        Exception e) {
        }
      }
    }
    if (doFilter) {
      chain.doFilter(servletRequest,servletResponse);
    }
  }
}

Fixed version (ground truth):
/** 
 * @see Filter#doFilter(ServletRequest,ServletResponse,FilterChain)
 */
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  boolean doFilter=true;
  logger.debug("String_Node_Str");
  if (request.getParameter("String_Node_Str") != null) {
    logger.debug("String_Node_Str");
    HttpServletRequest servletRequest=(HttpServletRequest)request;
    HttpServletResponse servletResponse=(HttpServletResponse)response;
    try {
      String ticket=request.getParameter("String_Node_Str");
      String cleanURL=getCleanURL(servletRequest);
      UserUtility.loginCas(servletRequest,cleanURL.toString(),ticket,new URL(casURL),new URL(coreURL));
      doFilter=false;
      logger.debug("String_Node_Str" + cleanURL.toString());
      servletResponse.sendRedirect(cleanURL.toString());
    }
 catch (    AuthenticationException e) {
      e.printStackTrace();
    }
  }
 else {
    HttpServletRequest servletRequest=(HttpServletRequest)request;
    HttpServletResponse servletResponse=(HttpServletResponse)response;
    if (servletRequest.getRequestURI().trim().equalsIgnoreCase("String_Node_Str")) {
      logger.debug("String_Node_Str");
      try {
        UserLoginServiceImpl.getInstance().logout();
      }
 catch (      Exception e) {
      }
      String cleanURL=getCleanURL(servletRequest);
      String urlToRedirectTo=CommonUtils.constructRedirectUrl(casLoginURL,"String_Node_Str",cleanURL,false,false);
      if (!this.gatewayStorage.hasGatewayedAlready(servletRequest,urlToRedirectTo)) {
        urlToRedirectTo=this.gatewayStorage.storeGatewayInformation(servletRequest,urlToRedirectTo);
        doFilter=false;
        servletResponse.sendRedirect(urlToRedirectTo);
      }
 else {
        doFilter=false;
        servletResponse.sendRedirect("String_Node_Str");
      }
    }
 else     if (servletRequest.getRequestURI().trim().equalsIgnoreCase("String_Node_Str")) {
      logger.debug("String_Node_Str");
      String cleanURL=getCleanURL(servletRequest);
      UserUtility.logout(servletRequest,new URL(casURL),new URL(coreURL));
      String urlToRedirectTo=CommonUtils.constructRedirectUrl(casLogoutURL,"String_Node_Str",cleanURL,false,false);
      doFilter=false;
      servletResponse.sendRedirect(urlToRedirectTo);
    }
 else {
      CASUserPrincipal cup=UserUtility.getUser(servletRequest);
      if (cup != null) {
        try {
          logger.debug("String_Node_Str");
          CASUserPrincipal cupUpdated=this.casUtility.getCASUserPrincipalFromProxyGrantingTicket(cup.getProxyGrantingTicket(),"String_Node_Str");
          cupUpdated.setGuest(cup.isGuest());
          UserUtility.setUser(servletRequest,cupUpdated);
        }
 catch (        Exception e) {
          String cleanURL=getCleanURL(servletRequest);
          String urlToRedirectTo=CommonUtils.constructRedirectUrl(casLoginURL,"String_Node_Str",cleanURL,false,false);
          if (!this.gatewayStorage.hasGatewayedAlready(servletRequest,urlToRedirectTo)) {
            urlToRedirectTo=this.gatewayStorage.storeGatewayInformation(servletRequest,urlToRedirectTo);
            doFilter=false;
            servletResponse.sendRedirect(urlToRedirectTo);
          }
 else {
            doFilter=false;
            servletResponse.sendRedirect("String_Node_Str");
          }
        }
      }
 else {
        try {
          CASUserPrincipal guestCUP=this.casUtility.getCASUserPrincipal(guestUsername,guestPassword,"String_Node_Str");
          guestCUP.setGuest(true);
          UserLoginServiceImpl.getInstance().loginCUP(servletRequest,guestCUP);
        }
 catch (        Exception e) {
        }
      }
    }
    if (doFilter) {
      chain.doFilter(servletRequest,servletResponse);
    }
  }
}