title: Add custom AuthenticationProvider to Spring Security in JHipster
body: <p>My main goal is to authenticate certain APIs differently in a JHipster application.</p>
  
  <p>Right now I'm using JHipster built-in stateless JWT authentication mechanism, which works just fine. I would like to create a subset of APIs where an API key is needed to authenticate a tenant (not a user) instead of JWT.</p>
  
  <p>I was trying to add multiple HttpSecurity instances with <a href="http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/reference/htmlsingle/#multiple-httpsecurity" rel="nofollow">this</a> approach (order(1) is my custom configuration, order(2) is jwt). My own custom AuthorizationProvider's <em>authenticate</em> method fires, and returns a token, but I still got a JWT error message.</p>
  
  <p>Despite the fact that my authentication was successful JWTFilter invoked while it shouldn't be.</p>
  
  <p>What am I missing?</p>
  
  <p>My log:</p>
  
  <pre><code>[nio-8080-exec-3] c.s.b.s.i.IntegrationAuthFilter          : Request is to process authentication
  [nio-8080-exec-3] c.s.b.s.i.IntegrationAuthFilter          : Authentication success. Updating SecurityContextHolder to contain: com.example.app.security.integration.IntegrationAuthToken@ffffffc4: Principal: asd; Credentials: [PROTECTED]; Authenticated: true; Details: null; Not granted any authorities
  [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
  
  io.jsonwebtoken.MalformedJwtException: JWT strings must contain exactly 2 period characters. Found: 0
      at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:223)
      at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:458)
      at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:518)
      at com.example.app.security.jwt.TokenProvider.validateToken(TokenProvider.java:98)
      at com.example.app.security.jwt.JWTFilter.doFilter(JWTFilter.java:40)
  </code></pre>