| | |
| | | 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; |
| | | |
| | |
| | | |
| | | 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); |
| | |
| | | //进行判断,判断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()); |
| | |
| | | // 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); |
| | |
| | | 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); |
| | | } |
| | | } |