Springセキュリティを使用してユーザーを認証するWebインターフェイスを備えたWebServerがありますが、モバイルアプリからのログイン要求でユーザーを認証するために同じエンジンを使用する必要があり、それらを認証する必要があります。認証クラスですが、初めてこれを行うときは正しく理解できないようです。私は一種の道に迷っているので、誰かがこれを手伝ってくれることを願っています。
@Post
@Path("/mobile/session")
public void login(String username, String password) {
Usuario usuario = usuarioService.loadByUserName(username);
UsernamePasswordAuthenticationToken usernamePassAuthToken = new UsernamePasswordAuthenticationToken(usuario,EncriptarMD5.encriptar(password));
Authentication auth = authenticationManager.authenticate(usernamePassAuthToken);
if(auth.isAuthenticated()){
result.use(Results.json()).from(RequestContextHolder.currentRequestAttributes().getSessionId().toString(), "token").serialize();
} else {
result.use(Results.http()).setStatusCode(401);
}
}
次の例外が発生します
br.com.caelum.vraptor.InterceptionException:例外が発生しました。詳細については根本原因を確認してください:org.springframework.security.authentication.BadCredentialsException:br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java: 96)br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum .vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor.interceptor.ParametersInstantiatorInterceptor.intercept (ParametersInstantiatorInterceptor.java:93)br.com.caelum.vraptor.core.LazyInterceptorHandlerにあります。execute(LazyInterceptorHandler.java:59)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.otgmobile.trackgoweb.util.CustomInterceptor.intercept(CustomInterceptor.java:24) br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor .core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor .java:83)at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)atbr.com.caelum.vraptor.core。DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java: 54)br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)at br.com.caelum .vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept (ResourceLookupInterceptor.java:69)br.com.caelum.vraptor.core.ToInstantiateInterceptorHandlerにあります。execute(ToInstantiateInterceptorHandler.java:54)at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:44) br.com.caelum.vraptor.VRaptor $ 1.insideRequest(VRaptor.java:91)at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)atbr.com.caelum。 vraptor.VRaptor.doFilter(VRaptor.java:88)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:169)でorg.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter。java:126)org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)at org.apache.catalina.core.ApplicationFilterChain .doFilter(ApplicationFilterChain.java:210)at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)at org.springframework.security.web.FilterChainProxy.doFilterInternal( FilterChainProxy.java:186)org.springframework.security.webで。FilterChainProxy.doFilter(FilterChainProxy.java:160)at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)at org .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve .java:222)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)atorg.apache.catalina。 core.StandardHostValve.invoke(StandardHostValve.java:171)(org.apache.catalina.valves.ErrorReportValve)。invoke(ErrorReportValve.java:99)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)at org.apache .catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProto :589)org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)atjava.util.concurrent。 ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報java:99)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)at org.apache.catalina.connector .CoyoteAdapter.service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker。 run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報java:99)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)at org.apache.catalina.connector .CoyoteAdapter.service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor$Worker。 run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)のvalves.AccessLogValve.invoke(AccessLogValve.java:931)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)atjava。 lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)のvalves.AccessLogValve.invoke(AccessLogValve.java:931)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)atjava。 lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor。 java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util .concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:722)原因: org.springframework.security.authentication.BadCredentialsException:不正な資格情報apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor。 java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util .concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)at java.lang.Thread.run(Thread.java:722)原因: org.springframework.security.authentication.BadCredentialsException:不正な資格情報service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache .tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor .java:603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報service(CoyoteAdapter.java:407)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)at org.apache .tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor .java:603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java: 603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java: 603)at java.lang.Thread.run(Thread.java:722)原因:org.springframework.security.authentication.BadCredentialsException:不正な資格情報