2

I am New on Spring Security.using Spring 4.3 and Spring Security 5.0 .Everything Run .the login page also came .if you given Wrong Password it tells Your login attempt was not successful, try again.Fine But Right Password give it raised Exception

my Spring_Security . XML is

 <authentication-manager>  
      <authentication-provider>  
        <user-service>  
        <user name="admin" password="1234" authorities="ROLE_USER" />  
        </user-service>  
      </authentication-provider>  
    </authentication-manager> 

my Web.xml

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        /WEB-INF/spring-security.xml,
         /WEB-INF/spring/appServlet/hibernate.xml
        </param-value>
    </context-param>



<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>




<filter>  
    <filter-name>springSecurityFilterChain</filter-name>  
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  
</filter>  
<filter-mapping>  
    <filter-name>springSecurityFilterChain</filter-name>  
    <url-pattern>/*</url-pattern>  
</filter-mapping>  





<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        /WEB-INF/spring/appServlet/servlet-context.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

my Controller Class

 @RequestMapping(value="/admin", method=RequestMethod.GET)  
        public String privateHome() {  

            return "privatePage";  
        }  


When Run the Code /admin page its default run log in page .Everything Fine 

.Once Right Credentials Given i got There is no Password Encoder mapped for the id "null"

Gana
  • 51
  • 1
  • 3
  • Possible duplicate of https://stackoverflow.com/questions/49654143/spring-security-5-there-is-no-passwordencoder-mapped-for-the-id-null – dur May 21 '18 at 09:03
  • See also https://stackoverflow.com/questions/49609768/spring-security-migrating-4-0-to-5-0-error-there-is-no-passwordencoder-mapp – dur May 21 '18 at 09:04
  • 2
    these Links are Tell about the Spring Boot .But I want in Spring xml based – Gana May 21 '18 at 09:13
  • See also: https://stackoverflow.com/questions/49122867/spring-boot-2-0-0-oauth2 – dur May 21 '18 at 09:40

1 Answers1

0

You can lookup the answers for this question: Spring security : migrating 4.0 to 5.0 - Error -There is no PasswordEncoder mapped for the id “null”

However, for Spring Security 5, the correct definition would be:

<bean id ="passwordEncoder" class = "org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method = "getInstance" />