本文整理汇总了Java中org.springframework.binding.message.MessageContext类的典型用法代码示例。如果您正苦于以下问题:Java MessageContext类的具体用法?Java MessageContext怎么用?Java MessageContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageContext类属于org.springframework.binding.message包,在下文中一共展示了MessageContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateAdminForm
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
public void validateAdminForm(Person personBean, ValidationContext context) {
LOGGER.debug("Validate the admin - START");
MessageContext messages = context.getMessageContext();
if(personBean.getFirstName().equals(""))
messages.addMessage(new MessageBuilder().error().source("firstName").defaultText("required").build());
if(personBean.getLastName().equals(""))
messages.addMessage(new MessageBuilder().error().source("lastName").defaultText("required").build());
if(personBean.getEmail().equals(""))
messages.addMessage(new MessageBuilder().error().source("email").defaultText("required").build());
else
if(!testEmail(personBean.getEmail()))
messages.addMessage(new MessageBuilder().error().source("email").defaultText("incorrect form").build());
try {
if(BLPerson.getInstance().getByUsername(personBean.getUsername()) != null)
messages.addMessage(new MessageBuilder().error().source("username").defaultText("Username already exists!").build());
} catch (BusinessException e) {
e.printStackTrace();
}
LOGGER.debug("Validate the organisation - END");
}
示例2: verifySuccessfulAuthenticationWithNoService
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithNoService() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:AuthenticationViaFormActionTests.java
示例3: verifySuccessfulAuthenticationWithNoServiceAndWarn
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithNoServiceAndWarn()
throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
request.addParameter("warn", "true");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, response));
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
assertNotNull(WebUtils.getTicketGrantingTicketId(context));
assertNotNull(response.getCookie(this.warnCookieGenerator.getCookieName()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:AuthenticationViaFormActionTests.java
示例4: verifySuccessfulAuthenticationWithServiceAndWarn
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithServiceAndWarn() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
request.addParameter("warn", "true");
request.addParameter("service", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, response));
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
assertNotNull(response.getCookie(this.warnCookieGenerator.getCookieName()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:AuthenticationViaFormActionTests.java
示例5: verifyFailedAuthenticationWithNoService
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyFailedAuthenticationWithNoService() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
final UsernamePasswordCredential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithDifferentUsernameAndPassword();
request.addParameter("username", c.getUsername());
request.addParameter("password", c.getPassword());
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("authenticationFailure", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:AuthenticationViaFormActionTests.java
示例6: verifyRenewWithServiceAndSameCredentials
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndSameCredentials() throws Exception {
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = TestUtils.getService(TestUtils.CONST_TEST_URL);
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils.getAuthenticationContext(
getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("renew", "true");
request.addParameter("service", TestUtils.getService(TestUtils.CONST_TEST_URL).getId());
request.addParameter("username", "test");
request.addParameter("password", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlowScope().put("service", TestUtils.getService());
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("warn", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:AuthenticationViaFormActionTests.java
示例7: verifyRenewWithServiceAndDifferentCredentials
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndDifferentCredentials() throws Exception {
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils.getAuthenticationContext(
getAuthenticationSystemSupport(), TestUtils.getService("test"), c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", TestUtils.getService("test").getId());
request.addParameter("username", "test2");
request.addParameter("password", "test2");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:AuthenticationViaFormActionTests.java
示例8: verifyRenewWithServiceAndBadCredentials
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndBadCredentials() throws Exception {
final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = TestUtils.getService("test");
final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils.getAuthenticationContext(
getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", service.getId());
final Credential c2 = org.jasig.cas.authentication.TestUtils.getCredentialsWithDifferentUsernameAndPassword();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c2);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c2, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("authenticationFailure", this.action.submit(context, c2, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:AuthenticationViaFormActionTests.java
示例9: verifySuccessfulAuthenticationWithNoService
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithNoService() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("lt", "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:AuthenticationViaFormActionTests.java
示例10: verifySuccessfulAuthenticationWithNoServiceAndWarn
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithNoServiceAndWarn()
throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("lt", "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
request.addParameter("warn", "true");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, response));
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
assertNotNull(WebUtils.getTicketGrantingTicketId(context));
assertNotNull(response.getCookie(this.warnCookieGenerator.getCookieName()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:AuthenticationViaFormActionTests.java
示例11: verifySuccessfulAuthenticationWithServiceAndWarn
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithServiceAndWarn()
throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("lt", "LOGIN");
request.addParameter("username", "test");
request.addParameter("password", "test");
request.addParameter("warn", "true");
request.addParameter("service", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, response));
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
assertNotNull(response.getCookie(this.warnCookieGenerator.getCookieName()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:AuthenticationViaFormActionTests.java
示例12: verifyFailedAuthenticationWithNoService
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyFailedAuthenticationWithNoService() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
request.addParameter("username", "test");
request.addParameter("password", "test2");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("error", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:AuthenticationViaFormActionTests.java
示例13: verifyRenewWithServiceAndSameCredentials
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndSameCredentials() throws Exception {
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(c);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("lt", "LOGIN");
request.addParameter("renew", "true");
request.addParameter("service", "test");
request.addParameter("username", "test");
request.addParameter("password", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlowScope().put("service", TestUtils.getService());
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("warn", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:AuthenticationViaFormActionTests.java
示例14: verifyRenewWithServiceAndDifferentCredentials
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndDifferentCredentials() throws Exception {
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(c);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putLoginTicket(context, "LOGIN");
request.addParameter("lt", "LOGIN");
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", "test");
request.addParameter("username", "test2");
request.addParameter("password", "test2");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("success", this.action.submit(context, c, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:AuthenticationViaFormActionTests.java
示例15: verifyRenewWithServiceAndBadCredentials
import org.springframework.binding.message.MessageContext; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndBadCredentials() throws Exception {
final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(c);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", "test");
final Credential c2 = TestUtils.getCredentialsWithDifferentUsernameAndPassword();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
putCredentialInRequestScope(context, c2);
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(c2, "credentials"));
final MessageContext messageContext = mock(MessageContext.class);
assertEquals("error", this.action.submit(context, c2, messageContext).getId());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:AuthenticationViaFormActionTests.java