本文整理匯總了Java中org.springframework.validation.BindException類的典型用法代碼示例。如果您正苦於以下問題:Java BindException類的具體用法?Java BindException怎麽用?Java BindException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BindException類屬於org.springframework.validation包,在下文中一共展示了BindException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validate
import org.springframework.validation.BindException; //導入依賴的package包/類
@PostConstruct
public void validate() {
if (countBeans(AuthorizationServerEndpointsConfiguration.class) > 0) {
// If we are an authorization server we don't need remote resource token
// services
return;
}
if (countBeans(ResourceServerTokenServicesConfiguration.class) == 0) {
// If we are not a resource server or an SSO client we don't need remote
// resource token services
return;
}
if (!StringUtils.hasText(this.clientId)) {
return;
}
try {
doValidate();
}
catch (BindException ex) {
throw new IllegalStateException(ex);
}
}
示例2: getMatcher
import org.springframework.validation.BindException; //導入依賴的package包/類
private BaseMatcher<BindException> getMatcher(String message, String field) {
return new BaseMatcher<BindException>() {
@Override
public void describeTo(Description description) {
}
@Override
public boolean matches(Object item) {
BindException ex = (BindException) ((Exception) item).getCause();
ObjectError error = ex.getAllErrors().get(0);
boolean messageMatches = message.equals(error.getDefaultMessage());
if (field == null) {
return messageMatches;
}
String fieldErrors = ((FieldError) error).getField();
return messageMatches && fieldErrors.equals(field);
}
};
}
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:23,代碼來源:ResourceServerPropertiesTests.java
示例3: verifyFailedAuthenticationWithNoService
import org.springframework.validation.BindException; //導入依賴的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
示例4: verifyRenewWithServiceAndBadCredentials
import org.springframework.validation.BindException; //導入依賴的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
示例5: verifyFailedAuthenticationWithNoService
import org.springframework.validation.BindException; //導入依賴的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
示例6: verifyRenewWithServiceAndBadCredentials
import org.springframework.validation.BindException; //導入依賴的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
示例7: verifyFailedAuthenticationWithNoService
import org.springframework.validation.BindException; //導入依賴的package包/類
@Test
public void verifyFailedAuthenticationWithNoService() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
request.addParameter(USERNAME_PARAM, TEST);
request.addParameter(PASSWORD_PARAM, "test2");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword();
putCredentialInRequestScope(context, c);
context.getRequestScope().put("org.springframework.validation.BindException.credentials", new BindException(c, "credential"));
assertEquals(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, this.action.execute(context).getId());
}
示例8: testFailedAuthenticationWithNoService
import org.springframework.validation.BindException; //導入依賴的package包/類
@Test
public void testFailedAuthenticationWithNoService() 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()));
context.getRequestScope().put("credentials",
TestUtils.getCredentialsWithDifferentUsernameAndPassword());
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(TestUtils
.getCredentialsWithDifferentUsernameAndPassword(),
"credentials"));
// this.action.bind(context);
// assertEquals("error", this.action.submit(context).getId());
}
示例9: testRenewWithServiceAndBadCredentials
import org.springframework.validation.BindException; //導入依賴的package包/類
@Test
public void testRenewWithServiceAndBadCredentials() throws Exception {
final String ticketGrantingTicket = getCentralAuthenticationService()
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("ticketGrantingTicketId", ticketGrantingTicket);
request.addParameter("renew", "true");
request.addParameter("service", "test");
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
context.getRequestScope().put("credentials",
TestUtils.getCredentialsWithDifferentUsernameAndPassword());
context.getRequestScope().put(
"org.springframework.validation.BindException.credentials",
new BindException(TestUtils
.getCredentialsWithDifferentUsernameAndPassword(),
"credentials"));
// this.action.bind(context);
// assertEquals("error", this.action.submit(context).getId());
}
示例10: main
import org.springframework.validation.BindException; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
// below is output *before* logging is configured so will appear on console
logVersionInfo();
try {
SpringApplication.exit(new SpringApplicationBuilder(VacuumTool.class)
.properties("spring.config.location:${config:null}")
.properties("spring.profiles.active:" + Modules.REPLICATION)
.properties("instance.home:${user.home}")
.properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
.bannerMode(Mode.OFF)
.registerShutdownHook(true)
.build()
.run(args));
} catch (BeanCreationException e) {
if (e.getMostSpecificCause() instanceof BindException) {
printVacuumToolHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
}
throw e;
}
}
示例11: main
import org.springframework.validation.BindException; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
// below is output *before* logging is configured so will appear on console
logVersionInfo();
try {
SpringApplication.exit(new SpringApplicationBuilder(ComparisonTool.class)
.properties("spring.config.location:${config:null}")
.properties("spring.profiles.active:" + Modules.REPLICATION)
.properties("instance.home:${user.home}")
.properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
.bannerMode(Mode.OFF)
.registerShutdownHook(true)
.build()
.run(args));
} catch (BeanCreationException e) {
if (e.getMostSpecificCause() instanceof BindException) {
printComparisonToolHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
throw e;
}
if (e.getMostSpecificCause() instanceof IllegalArgumentException) {
LOG.error(e.getMessage(), e);
printComparisonToolHelp(Collections.<ObjectError> emptyList());
}
}
}
示例12: main
import org.springframework.validation.BindException; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
// below is output *before* logging is configured so will appear on console
logVersionInfo();
try {
SpringApplication.exit(new SpringApplicationBuilder(FilterTool.class)
.properties("spring.config.location:${config:null}")
.properties("spring.profiles.active:" + Modules.REPLICATION)
.properties("instance.home:${user.home}")
.properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
.bannerMode(Mode.OFF)
.registerShutdownHook(true)
.build()
.run(args));
} catch (BeanCreationException e) {
if (e.getMostSpecificCause() instanceof BindException) {
printFilterToolHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
}
throw e;
}
}
示例13: verifyFailedAuthenticationWithNoService
import org.springframework.validation.BindException; //導入依賴的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 = org.jasig.cas.authentication.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());
}
示例14: verifyRenewWithServiceAndBadCredentials
import org.springframework.validation.BindException; //導入依賴的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("error", this.action.submit(context, c2, messageContext).getId());
}
示例15: main
import org.springframework.validation.BindException; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
// below is output *before* logging is configured so will appear on console
logVersionInfo();
int exitCode = -1;
try {
SpringApplication application = new SpringApplicationBuilder(WaggleDance.class)
.properties("spring.config.location:${server-config:null},${federation-config:null}")
.properties("server.port:${endpoint.port:18000}")
.registerShutdownHook(true)
.build();
exitCode = SpringApplication.exit(registerListeners(application).run(args));
} catch (BeanCreationException e) {
if (e.getMostSpecificCause() instanceof BindException) {
printHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
}
if (e.getMostSpecificCause() instanceof ConstraintViolationException) {
logConstraintErrors(((ConstraintViolationException) e.getMostSpecificCause()));
}
throw e;
}
System.exit(exitCode);
}