org.springframework.webflow.execution.repository.NoSuchFlowExecutionException Java Examples

The following examples show how to use org.springframework.webflow.execution.repository.NoSuchFlowExecutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitialFlowSetupAction.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Override
protected Event doExecute(final RequestContext context) throws Exception {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    if (!this.pathPopulated) {
        final String contextPath = context.getExternalContext().getContextPath();
        final String cookiePath = StringUtils.hasText(contextPath) ? contextPath + '/' : "/";
        logger.info("Setting path for cookies to: {} ", cookiePath);
        this.warnCookieGenerator.setCookiePath(cookiePath);
        this.ticketGrantingTicketCookieGenerator.setCookiePath(cookiePath);
        this.pathPopulated = true;
    }

    WebUtils.putTicketGrantingTicketInScopes(context,
            this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));

    WebUtils.putWarningCookie(context,
            Boolean.valueOf(this.warnCookieGenerator.retrieveCookieValue(request)));

    final Service service = WebUtils.getService(this.argumentExtractors, context);


    if (service != null) {
        logger.debug("Placing service in context scope: [{}]", service.getId());

        final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
        if (registeredService != null && registeredService.getAccessStrategy().isServiceAccessAllowed()) {
            logger.debug("Placing registered service [{}] with id [{}] in context scope",
                    registeredService.getServiceId(),
                    registeredService.getId());
            WebUtils.putRegisteredService(context, registeredService);
        }
    } else if (!this.enableFlowOnAbsentServiceRequest) {
        logger.warn("No service authentication request is available at [{}]. CAS is configured to disable the flow.",
                WebUtils.getHttpServletRequest(context).getRequestURL());
        throw new NoSuchFlowExecutionException(context.getFlowExecutionContext().getKey(),
                new UnauthorizedServiceException("screen.service.required.message", "Service is required"));
    }
    WebUtils.putService(context, service);
    return result("success");
}
 
Example #2
Source File: InitialFlowSetupActionTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test(expected = NoSuchFlowExecutionException.class)
public void disableFlowIfNoService() throws Exception {
    this.action.setEnableFlowOnAbsentServiceRequest(false);
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));

    this.action.execute(context);
}
 
Example #3
Source File: FlowExecutionExceptionResolverTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test
public void verifyNoSuchFlowExecutionException() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    ModelAndView model = this.resolver.resolveException(request,
            new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey(){

                private static final long serialVersionUID = 1443616250214416520L;

                @Override
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI(), ((RedirectView) model.getView())
            .getUrl());
}
 
Example #4
Source File: FlowExecutionExceptionResolverTests.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Test
public void verifyNoSuchFlowExecutionExeptionWithQueryString() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    request.setQueryString("test=test");
    ModelAndView model = this.resolver.resolveException(request,
            new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey(){

                private static final long serialVersionUID = -4750073902540974152L;

                @Override
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI() + "?" + request.getQueryString(), ((RedirectView) model.getView())
            .getUrl());
}
 
Example #5
Source File: FlowExecutionExceptionResolverTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoSuchFlowExecutionException() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    ModelAndView model = this.resolver.resolveException(request,
            new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey(){

                private static final long serialVersionUID = 1443616250214416520L;

                @Override
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI(), ((RedirectView) model.getView())
            .getUrl());
}
 
Example #6
Source File: FlowExecutionExceptionResolverTests.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoSuchFlowExecutionExeptionWithQueryString() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    request.setQueryString("test=test");
    ModelAndView model = this.resolver.resolveException(request,
            new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey(){

                private static final long serialVersionUID = -4750073902540974152L;

                @Override
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI() + "?" + request.getQueryString(), ((RedirectView) model.getView())
            .getUrl());
}
 
Example #7
Source File: UsersFlowHandler.java    From enhanced-pet-clinic with Apache License 2.0 5 votes vote down vote up
@Override
public String handleException(FlowException e, HttpServletRequest request, HttpServletResponse response) {
	if (e instanceof NoSuchFlowExecutionException) {
		return DEFAULT_URL;
	} else {
		// ModelAndView mav = new ModelAndView();
		// request.mav.addObject("exception", e);
		// mav.addObject("timestamp", new Date());
		// mav.addObject("url", req.getRequestURL());
		// mav.setViewName("exception");
		// return mav;

		throw e;
	}
}