org.springframework.security.providers.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken

MuleSoft JIRA | Esteban Robles Luna | 7 years ago
  1. 0

    Customer has security configured as follows: <mule-ss:security-manager> <mule-ss:delegate-security-provider name="spring-ldap" delegate-ref="authenticationManager"> </mule-ss:security-manager> where the authenticationManager is this: <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"> <property name="providers"> <list> <ref local="preauthAuthProvider"/> </list> </property> </bean> <bean id="preauthAuthProvider" class="org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationProvider"> <property name="preAuthenticatedUserDetailsService" ref="userDetailsServiceWrapper" /> <sec:custom-authentication-provider /> </bean> However, the exception is thrown by Mule: Exception stack is: 1. No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken (org.springframework.security.providers.ProviderNotFoundException) org.springframework.security.providers.ProviderManager:214 (null) 2. Authentication Attempt Failed. Message payload is of type: ActiveMQTextMessage (org.mule.api.security.UnauthorisedException) org.mule.security.MuleSecurityManager:95 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/security/UnauthorisedException.html) Root Exception stack trace: org.springframework.security.providers.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken at org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:214) at org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46) at org.mule.module.spring.security.SpringProviderAdapter.authenticate(SpringProviderAdapter.java:69) at org.mule.security.MuleSecurityManager.authenticate(MuleSecurityManager.java:89) at org.mule.security.filters.MuleEncryptionEndpointSecurityFilter.authenticateInbound(MuleEncryptionEndpointSecurityFilter.java:61) ...etc It seems like Mule is trying to use UsernamePasswordAuthenticationToken when it should be using PreAuthenticatedAuthenticationToken. And SpringProviderAdapter.authenticate() method code reads: if (authentication instanceof SpringAuthenticationAdapter) { auth = ((SpringAuthenticationAdapter)authentication).getDelegate(); } else { auth = new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials()); } This should be fixed.

    MuleSoft JIRA | 7 years ago | Esteban Robles Luna
    org.springframework.security.providers.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken
  2. 0

    Customer has security configured as follows: <mule-ss:security-manager> <mule-ss:delegate-security-provider name="spring-ldap" delegate-ref="authenticationManager"> </mule-ss:security-manager> where the authenticationManager is this: <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"> <property name="providers"> <list> <ref local="preauthAuthProvider"/> </list> </property> </bean> <bean id="preauthAuthProvider" class="org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationProvider"> <property name="preAuthenticatedUserDetailsService" ref="userDetailsServiceWrapper" /> <sec:custom-authentication-provider /> </bean> However, the exception is thrown by Mule: Exception stack is: 1. No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken (org.springframework.security.providers.ProviderNotFoundException) org.springframework.security.providers.ProviderManager:214 (null) 2. Authentication Attempt Failed. Message payload is of type: ActiveMQTextMessage (org.mule.api.security.UnauthorisedException) org.mule.security.MuleSecurityManager:95 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/security/UnauthorisedException.html) Root Exception stack trace: org.springframework.security.providers.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken at org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:214) at org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46) at org.mule.module.spring.security.SpringProviderAdapter.authenticate(SpringProviderAdapter.java:69) at org.mule.security.MuleSecurityManager.authenticate(MuleSecurityManager.java:89) at org.mule.security.filters.MuleEncryptionEndpointSecurityFilter.authenticateInbound(MuleEncryptionEndpointSecurityFilter.java:61) ...etc It seems like Mule is trying to use UsernamePasswordAuthenticationToken when it should be using PreAuthenticatedAuthenticationToken. And SpringProviderAdapter.authenticate() method code reads: if (authentication instanceof SpringAuthenticationAdapter) { auth = ((SpringAuthenticationAdapter)authentication).getDelegate(); } else { auth = new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials()); } This should be fixed.

    MuleSoft JIRA | 7 years ago | Esteban Robles Luna
    org.springframework.security.providers.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken
  3. 0

    Spring Security LDAP - login problem (ProviderNotFoundException)

    Stack Overflow | 6 years ago | mateo
    org.springframework.security.providers.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.security.providers.ProviderNotFoundException

      No AuthenticationProvider found for org.springframework.security.providers.UsernamePasswordAuthenticationToken

      at org.springframework.security.providers.ProviderManager.doAuthentication()
    2. org.springframework.security
      AbstractAuthenticationManager.authenticate
      1. org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:214)
      2. org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46)
      2 frames
    3. Spring Security
      SpringProviderAdapter.authenticate
      1. org.mule.module.spring.security.SpringProviderAdapter.authenticate(SpringProviderAdapter.java:69)
      1 frame
    4. Mule Core
      MuleEncryptionEndpointSecurityFilter.authenticateInbound
      1. org.mule.security.MuleSecurityManager.authenticate(MuleSecurityManager.java:89)
      2. org.mule.security.filters.MuleEncryptionEndpointSecurityFilter.authenticateInbound(MuleEncryptionEndpointSecurityFilter.java:61)
      2 frames