在SecurityContext OAUTH1a中找不到Authentication对象:不断遇到此错误

时间:2016-12-26 23:35:08

标签: spring security authentication servlets oauth

我正在尝试设置OAuth1.0自动启动器springboot模块,调用应用程序将此作为依赖模块。以下是我的配置设置和代码。

MODULE INFORMATION:

模块项目结构:

Module Project Structure

Build.gradle file in MODULE
repositories {

    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "http://mbuild01:8090/archiva/repository/internal" }

}
dependencies {
   // compile group: 'org.springframework', name: 'spring-tx', version: '4.2.4'
    compile "org.springframework.boot:spring-boot-starter-parent:${SPRING_BOOT_VERSION}"
    compile "org.springframework.boot:spring-boot-autoconfigure:${SPRING_BOOT_VERSION}"
    compile "org.springframework.boot:spring-boot-starter-web:${SPRING_BOOT_VERSION}"
    compile 'org.codehaus.groovy:groovy:2.3.6'

    //spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE
    compile("org.springframework.boot:spring-boot-starter-security:${SPRING_BOOT_VERSION}")
    compile("org.springframework.security.oauth:spring-security-oauth:1.0.5.RELEASE")
    compile('org.springframework.security:spring-security-config:3.2.7.RELEASE')
    compile('org.springframework.security:spring-security-core:3.2.7.RELEASE')
    compile('org.springframework.security:spring-security-web:3.2.7.RELEASE')
   // compile('org.springframework:spring-tx:${SPRING_BOOT_VERSION}')
   // compile 'org.springframework:spring-tx'


    compile "org.slf4j:log4j-over-slf4j:${SLF4J_VERSION}"
    compile "org.slf4j:jul-to-slf4j:${SLF4J_VERSION}"
    compile "org.slf4j:slf4j-api:${SLF4J_VERSION}"

    compile 'ch.qos.logback:logback-classic:1.1.3'


    testCompile "org.springframework.boot:spring-boot-starter-test:${SPRING_BOOT_VERSION}"
    testCompile 'org.spockframework:spock-spring:0.7-groovy-2.0'
    testRuntime "cglib:cglib-nodep:2.2.2"
    testRuntime "org.objenesis:objenesis:1.2"

    optional "org.springframework.boot:spring-boot-configuration-processor:${SPRING_BOOT_VERSION}"

}


Module: 
-- src
 -- main
   -- resource
    -- META-INF 
      -- spring.factories

在spring.factories中输入:

org.springframework.boot.autoconfigure.EnableAutoConfiguration=path to my SecurityConfig`enter code here`

Module: 
-- src
 -- main
  -- securityConfig

@Slf4j
@ComponentScan('com.mycomp.security')
@Configuration
@EnableAutoConfiguration
@EnableWebMvcSecurity
// enable spring security and web mvc hooks
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
//@Scope( proxyMode = ScopedProxyMode.TARGET_CLASS )
public class MyCompSecurityConfig extends WebMvcConfigurerAdapter {

    @Configuration
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public static class OAuthSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
        ZeroLeggedOAuthProviderProcessingFilter zeroLeggedOAuthProviderProcessingFilter
        @Autowired
        @Qualifier('oauthConsumerDetailsService')
        OAuthConsumerDetailsService oauthConsumerDetailsService
        @Autowired
        OAuthAuthenticationHandler oauthAuthenticationHandler
        @Autowired
        OAuthProcessingFilterEntryPoint oauthProcessingFilterEntryPoint
        @Autowired
        OAuthProviderTokenServices oauthProviderTokenServices
        @Autowired
        OAuthConsumerConfig oAuthConsumerConfig

        @PostConstruct
        public void init() {
            zeroLeggedOAuthProviderProcessingFilter =
                    new ZeroLeggedOAuthProviderProcessingFilter(
                            oauthConsumerDetailsService,
                            new InMemoryNonceServices(),
                            oauthProcessingFilterEntryPoint,
                            oauthAuthenticationHandler,
                            oauthProviderTokenServices)
      //      log.info('MAtching URL' + oAuthConsumerConfig.matchUrl)
       //     log.info('MAtching ROLES' + oAuthConsumerConfig.matchRoles)
        }

        @Override
        protected void configure(HttpSecurity http) throws Exception {
        //    log.info('oauthConsumerConfig.securityEnabled : ' + oAuthConsumerConfig.securityEnabled)
        //    if (oAuthConsumerConfig.securityEnabled) {
                log.info('OH UH')
                http.requestMatchers().antMatchers('/url to secure/**')  //oAuthConsumerConfig.matchUrl
                        .and()
                        .addFilterBefore(zeroLeggedOAuthProviderProcessingFilter,
                         UsernamePasswordAuthenticationFilter)
                        .authorizeRequests().anyRequest().hasRole('role1')
                        .and().csrf().disable()
            }
       // }
    }

    public static class OAuthProcessingFilterEntryPointImpl extends OAuthProcessingFilterEntryPoint {
        @Override
        public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
            log.info("OAuth FILTER Failure (commence), req=" + request + ", ex=" + authException);
            super.commence(request, response, authException);
        }
    }

    @Bean(name = 'oauthAuthenticationEntryPoint')
    public OAuthProcessingFilterEntryPoint oauthAuthenticationEntryPoint() {
        return new OAuthProcessingFilterEntryPointImpl()
    }

    @Bean(name = 'oauthProviderTokenServices')
    public OAuthProviderTokenServices oauthProviderTokenServices() {
        return new InMemoryProviderTokenServices()
    }

    public static class ZeroLeggedOAuthProviderProcessingFilter extends ProtectedResourceProcessingFilter {
        ZeroLeggedOAuthProviderProcessingFilter(OAuthConsumerDetailsService oAuthConsumerDetailsService,
                                                OAuthNonceServices oAuthNonceServices,
                                                OAuthProcessingFilterEntryPoint oAuthProcessingFilterEntryPoint,
                                                OAuthAuthenticationHandler oAuthAuthenticationHandler,
                                                OAuthProviderTokenServices oAuthProviderTokenServices) {
            super()
            log.info("INSIDE ZeroLeggedOAuthProviderProcessingFilter")
            setAuthenticationEntryPoint(oAuthProcessingFilterEntryPoint)
            setAuthHandler(oAuthAuthenticationHandler)
            setConsumerDetailsService(oAuthConsumerDetailsService)
            setNonceServices(oAuthNonceServices)
            setTokenServices(oAuthProviderTokenServices)
        }
    }
}

Module:
-- src
 -- main
@Configuration
@CompileStatic
@ConfigurationProperties(prefix = 'oAuthServiceConfig')
class OAuthConsumerConfig {
    /*@NotNull
    String securityEnabled

    @NotNull
    String matchUrl

    @NotNull
    String matchRoles*/

    static class OAuthConsumer {
         @NotNull
         String consumerName

         @NotNull
         String consumerKey

         @NotNull
         String signatureSecret

         @NotNull
         List<String> authorities
    }

Module: 
-- src
 -- main
  -- securityoauth (Under this Package I have oAuthHandler / OAuthConsumerDetails and OAuthConsumerDetailService)

{@Component
@Slf4j
public class OAuthAuthenticationProcessingHandler  implements OAuthAuthenticationHandler {

    @Override
    public Authentication createAuthentication(
            HttpServletRequest request,
            ConsumerAuthentication authentication,
            OAuthAccessProviderToken authToken) {
        log.info("TTTTT OAuthAuthenticationProcessingHandler")
        Collection<GrantedAuthority> authorities = new HashSet<>(authentication.authorities)
        String username = request.getParameter('username')
        if (username) {
            username = authentication.name
        }

        Principal principal = new NamedOAuthPrincipal(username, authorities,
                authentication.consumerCredentials.consumerKey,
                authentication.consumerCredentials.signature,
                authentication.consumerCredentials.signatureMethod,
                authentication.consumerCredentials.signatureBaseString,
                authentication.consumerCredentials.token
        )
        Authentication auth = new UsernamePasswordAuthenticationToken(principal, null, authorities)
        auth
    }

    public static class NamedOAuthPrincipal extends ConsumerCredentials implements Principal {
        String name
        Collection<GrantedAuthority> authorities

        public NamedOAuthPrincipal(String name,
                                   Collection<GrantedAuthority> authorities,
                                   String consumerKey,
                                   String signature,
                                   String signatureMethod,
                                   String signatureBaseString,
                                   String token) {
            super(consumerKey, signature, signatureMethod, signatureBaseString, token)
            log.info("UUU OAuthAuthenticationProcessingHandler")
            this.name = name
            this.authorities = authorities
        }

        @Override
        public String getName() {
            name
        }

        public Collection<? extends GrantedAuthority> getAuthorities() {
            authorities
        }
    }
}

public class OAuthConsumerDetails implements ExtraTrustConsumerDetails {

     String consumerName
     String consumerKey
     SignatureSecret signatureSecret
     List<GrantedAuthority> authorities

    public boolean isRequiredToObtainAuthenticatedToken() {
        return false
    }
}

@Service('oauthConsumerDetailsService')
@Slf4j
public class OAuthConsumerDetailsService implements ConsumerDetailsService {

    List<com.mycomp.security.oauth.OAuthConsumerDetails> oauthConsumers = []

    @Autowired
    OAuthConsumerConfig oAuthConsumerConfig

    @PostConstruct
    public void init() {
        for (com.mycomp.security.config.OAuthConsumerConfig.OAuthConsumer consumer : oAuthConsumerConfig.consumers) {
            log.info('QQQQ key' + consumer.consumerKey
                    + ' secret' + consumer.signatureSecret
                    + ' name' + consumer.consumerName
                    + ' authorities' + consumer.authorities)
            List authoritiesTemp = []
            SimpleGrantedAuthority[] arrtmpAuthority = new SimpleGrantedAuthority[consumer.authorities.size()]
            int i=0
            for (String authority : consumer.authorities) {
                SimpleGrantedAuthority tmpAuthority = new SimpleGrantedAuthority(authority)
                arrtmpAuthority[i] = tmpAuthority
                i++
            }
            authoritiesTemp = Arrays.asList(arrtmpAuthority)
            OAuthConsumerDetails oauthConsumerDetails = new OAuthConsumerDetails()
            oauthConsumerDetails.with {
                consumerName = consumer.consumerName
                consumerKey = consumer.consumerKey
                signatureSecret =  new SharedConsumerSecretImpl(consumer.signatureSecret)
                authorities = authoritiesTemp
            }
            oauthConsumers.add(oauthConsumerDetails)
            log.info('oauthConsumers : ' + oauthConsumers
                    + ' oauthConsumers authorities : ' + oauthConsumers.authorities)
        }
    }

    List<OAuthConsumerDetails> getOauthConsumers() {
        return this.oauthConsumers
    }


    @Override
    public OAuthConsumerDetails loadConsumerByConsumerKey(String consumerKey) throws OAuthException {
        log.info('loadConsumerByConsumerKey consumerKey : ' + consumerKey)
        if (consumerKey == null) {
            throw new OAuthException('Credentials not found for the consumer key [' + consumerKey + ']')
        }
        for (com.mycomp.security.oauth.OAuthConsumerDetails consumer : oauthConsumers) {
            log.info('consumer.consumerKey : ' + consumer.consumerKey)
            if (consumer.consumerKey == consumerKey) {
                log.info('MATCHING KEY : ' + consumer.consumerKey + consumerKey)
                return consumer
            }
        }
        throw new OAuthException('Credentials not found')
    }
}

}

调用模块设置

Calling Module Project Structure

致电模块:

config
  -- application.yml has below entry
oAuthServiceConfig:
  securityEnabled: true
  matchUrl: "/url to secure/**"
  matchRoles: "role1, role2"
  consumers:
    -
      consumerName: role1Services
      consumerKey: hajhsajdhasd
      signatureSecret: AJSaksAKSA
      authorities: ['ROLE_role1']
    -
      consumerName: role2Services
      consumerKey: adsadsadsad
      signatureSecret: adasdsadsadsd
      authorities: ['ROLE_role2']

build.gradle entry

compile project(':lt-bootapp-oauth1a')

使用@PreAuthorize

注释调用方法
@ResponseBody
    @Transactional
    @PreAuthorize("hasRole('ROLE_role1')")
    //@PreAuthorize("hasRole('ROLE_role1')")
   // @Secured('role1')
    List<Object> show(.....)

从Postman运行API时出错

{
  "timestamp": 1482736203029,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "org.springframework.security.authentication.AuthenticationCredentialsNotFoundException",
  "message": "An Authentication object was not found in the SecurityContext",
  "path": "/path to secured url/methodwithkey/83221de0-23213-4610-b82d-30f4cc0acbd9"
}

日志文件条目

o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-12-25 23:17:14.504 ERROR 8844 --- [http-nio-8081-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext] with root cause

org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:378) ~[spring-security-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:222) ~[spring-security-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64) ~[spring-security-core-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at com.mycomp.mypack.controllers.MyCallingResource$$EnhancerBySpringCGLIB$$2a06e95b.show(<generated>) ~[main/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_112]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_112]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) ~[javax.servlet-api-3.1.0.jar:3.1.0]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:243) ~[spring-boot-actuator-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:111) ~[spring-boot-actuator-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:207) ~[spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176) ~[spring-security-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103) ~[spring-boot-actuator-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_112]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_112]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.30.jar:8.0.30]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_112]

2016-12-25 23:17:20.270 ERROR 8844 --- [http-nio-8081-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext] with root cause

org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext

0 个答案:

没有答案