13693261870
2022-09-20 a666b5f9741ef9b21f547d3b2141752a0383c70c
src/java/org/apereo/cas/web/flow/GenerateServiceTicketAction.java
@@ -33,6 +33,10 @@
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
/**
 * @author Tanbin
 * @date   2018-12-12
 */
public class GenerateServiceTicketAction extends AbstractAction {
  private CentralAuthenticationService centralAuthenticationService;
  
@@ -42,8 +46,11 @@
  
  private ServicesManager servicesManager;
  @Autowired
  public TerraProperties properties;
  public TerraProperties properties;
  private static String mFalse="false";
  @Override
  protected Event doExecute(RequestContext context) {
    WebApplicationService webApplicationService = WebUtils.getService(context);
    String ticketGrantingTicket = WebUtils.getTicketGrantingTicketId(context);
@@ -52,7 +59,7 @@
      //进行判断,判断service是可以被该用户访问
      String url=properties.getAdmissionQueryUrl();
      //String url="http://192.168.1.40:8081/api/sys/systeminfo/isAdmitSysByUserid";
      Map<String,Object>  map =new HashMap<>();
      Map<String,Object>  map =new HashMap<>(5);
     
      String rep = null;
      map.put("userid", authentication.getPrincipal().getId());
@@ -71,19 +78,21 @@
      // TODO Auto-generated catch block
      e.printStackTrace();
   }
      if(rep==null||"false".equals(rep)){
      if(rep==null||mFalse.equals(rep)){
         System.out.print(rep);
         return new Event(this,"error");
      }
      if (authentication == null)
        throw new InvalidTicketException(new AuthenticationException("No authentication found for ticket " + ticketGrantingTicket), ticketGrantingTicket);
      if (authentication == null) {
        throw new InvalidTicketException(new AuthenticationException("No authentication found for ticket " + ticketGrantingTicket), ticketGrantingTicket);
      }
      RegisteredService registeredService = this.servicesManager.findServiceBy(webApplicationService);
      WebUtils.putRegisteredService(context, registeredService);
      WebUtils.putService(context, webApplicationService);
      WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(context, registeredService
          .getAccessStrategy().getUnauthorizedRedirectUrl());
      if (WebUtils.getWarningCookie(context))
        return result("warn");
      if (WebUtils.getWarningCookie(context)) {
        return result("warn");
      }
      Credential credential = WebUtils.getCredential(context);
      AuthenticationResultBuilder builder = this.authenticationSystemSupport.establishAuthenticationContextFromInitial(authentication, credential);
      AuthenticationResult authenticationResult = builder.build(webApplicationService);
@@ -91,10 +100,12 @@
      WebUtils.putServiceTicketInRequestScope(context, serviceTicketId);
      return success();
    } catch (AbstractTicketException e) {
      if (e instanceof InvalidTicketException)
        this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicket);
      if (isGatewayPresent(context))
        return result("gateway");
      if (e instanceof InvalidTicketException) {
        this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicket);
      }
      if (isGatewayPresent(context)) {
        return result("gateway");
      }
      return newEvent("authenticationFailure", e);
    } 
  }