org.springframework.webflow.action.EventFactorySupport Java Examples

The following examples show how to use org.springframework.webflow.action.EventFactorySupport. 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: AllSpnegoKnownClientSystemsFilterActionTest.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void ensureRemoteIpShouldBeChecked() {
    final BaseSpnegoKnownClientSystemsFilterAction action =
            new BaseSpnegoKnownClientSystemsFilterAction("^192\\.158\\..+");

    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("192.158.5.781");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
 
Example #2
Source File: AllSpnegoKnownClientSystemsFilterActionTest.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void ensureRemoteIpShouldNotBeChecked() {
    final BaseSpnegoKnownClientSystemsFilterAction action =
            new BaseSpnegoKnownClientSystemsFilterAction("^192\\.158\\..+");

    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("193.158.5.781");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertNotEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
 
Example #3
Source File: AllSpnegoKnownClientSystemsFilterActionTest.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void ensureAltRemoteIpHeaderShouldBeChecked() {
    final BaseSpnegoKnownClientSystemsFilterAction action =
            new BaseSpnegoKnownClientSystemsFilterAction("^74\\.125\\..+", "alternateRemoteIp");

    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("555.555.555.555");
    req.addHeader("alternateRemoteIp", "74.125.136.102");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
 
Example #4
Source File: AllSpnegoKnownClientSystemsFilterActionTest.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void ensureHostnameShouldDoSpnego() {
    final HostNameSpnegoKnownClientSystemsFilterAction action =
            new HostNameSpnegoKnownClientSystemsFilterAction("\\w+\\.\\w+\\.\\w+");

    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("74.125.136.102");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());

}
 
Example #5
Source File: AllSpnegoKnownClientSystemsFilterActionTest.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void ensureHostnameAndIpShouldDoSpnego() {
    final HostNameSpnegoKnownClientSystemsFilterAction action =
            new HostNameSpnegoKnownClientSystemsFilterAction("\\w+\\.\\w+\\.\\w+");
    action.setIpsToCheckPattern("74\\..+");

    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("74.125.136.102");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());

}
 
Example #6
Source File: AllSpnegoKnownClientSystemsFilterActionTest.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void verifyIpMismatchWhenCheckingHostnameForSpnego() {
    final HostNameSpnegoKnownClientSystemsFilterAction action =
            new HostNameSpnegoKnownClientSystemsFilterAction("\\w+\\.\\w+\\.\\w+");
    action.setIpsToCheckPattern("14\\..+");

    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("74.125.136.102");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertEquals(ev.getId(), new EventFactorySupport().no(this).getId());

}
 
Example #7
Source File: LdapSpnegoKnownClientSystemsFilterActionTests.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
@Test
public void ensureLdapAttributeShouldDoSpnego() {
    final LdapSpnegoKnownClientSystemsFilterAction action =
            new LdapSpnegoKnownClientSystemsFilterAction(this.connectionFactory,
            this.searchRequest, "mail");
    final MockRequestContext ctx = new MockRequestContext();
    final MockHttpServletRequest req = new MockHttpServletRequest();
    req.setRemoteAddr("localhost");
    final ServletExternalContext extCtx = new ServletExternalContext(
            new MockServletContext(), req,
            new MockHttpServletResponse());
    ctx.setExternalContext(extCtx);

    final Event ev = action.doExecute(ctx);
    assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
 
Example #8
Source File: CartController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
public Event checkUser(LoginForm login, MessageContext messageContext) {
	if (loginService.retrieveAccount(login.getUsername()) == null) {
		MessageBuilder errorMessageBuilder1 = new MessageBuilder().error();
		errorMessageBuilder1.source("username");
		errorMessageBuilder1.code("login.username.error");
		messageContext.addMessage(errorMessageBuilder1.build());
		
		MessageBuilder errorMessageBuilder2 = new MessageBuilder().error();
		errorMessageBuilder2.source("password");
		errorMessageBuilder2.code("login.password.error");
		messageContext.addMessage(errorMessageBuilder2.build());
		return new EventFactorySupport().error(this);
	}
	return new EventFactorySupport().success(this);
}
 
Example #9
Source File: CartController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
public Event registerOrder(OrderForm order, MessageContext messageContext) {
	if (order == null) {
		// Code here for Error Messages
		return new EventFactorySupport().error(this);
	}
	return new EventFactorySupport().success(this);
}
 
Example #10
Source File: CartController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
public Event registerPayment(PaymentForm payment, MessageContext messageContext) {
	if (payment == null) {
		// Code here for Error Messages
		return new EventFactorySupport().error(this);
	}
	return new EventFactorySupport().success(this);
}
 
Example #11
Source File: CartController.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
public Event shipOrder(ShipForm ship, MessageContext messageContext) {
	if (ship == null) {
		// Code here for Error Messages
		return new EventFactorySupport().error(this);
	}
	return new EventFactorySupport().success(this);
}
 
Example #12
Source File: AcceptableUsagePolicyFormAction.java    From springboot-shiro-cas-mybatis with MIT License 2 votes vote down vote up
/**
 * Success event.
 *
 * @return the event
 */
protected final Event success() {
    return new EventFactorySupport().success(this);
}
 
Example #13
Source File: AcceptableUsagePolicyFormAction.java    From springboot-shiro-cas-mybatis with MIT License 2 votes vote down vote up
/**
 * Accept event signaled by id {@link #EVENT_ID_MUST_ACCEPT}.
 *
 * @return the event
 */
protected final Event accept() {
    return new EventFactorySupport().event(this, EVENT_ID_MUST_ACCEPT);
}