我使用java ee开发Web应用程序,如果我使用spring security创建身份验证则无法正常工作

时间:2019-05-02 15:16:14

标签: spring security

具有Spring安全认证的J2EE Web应用程序 我的代码是正确的,也不例外,但是我无法登录并重定向到失败的登录页面 我用eclipse,spring mvc项目,tomcat 8,mysql开发我的应用程序

15:43:16.476 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.FilterChainProxy - /j_spring_security_check?username=sousou@d&password=123456 at position 1 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
15:43:16.478 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository - HttpSession returned null object for SPRING_SECURITY_CONTEXT
15:43:16.478 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@5d2fc5. A new one will be created.
15:43:16.488 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.FilterChainProxy - /j_spring_security_check?username=sousou@d&password=123456 at position 2 of 11 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
15:43:16.490 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.FilterChainProxy - /j_spring_security_check?username=sousou@d&password=123456 at position 3 of 11 in additional filter chain; firing Filter: 'LogoutFilter'
15:43:16.492 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.FilterChainProxy - /j_spring_security_check?username=sousou@d&password=123456 at position 4 of 11 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
15:43:16.492 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - Request is to process authentication
15:43:16.497 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - Authentication request failed: org.springframework.security.authentication.AuthenticationServiceException: Authentication method not supported: GET
15:43:16.498 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - Updated SecurityContextHolder to contain null Authentication
15:43:16.499 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - Delegating to authentication failure handler org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler@147c3d7
15:43:16.499 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler - Redirecting to /failedlogin
15:43:16.500 [http-nio-9090-exec-19] DEBUG org.springframework.security.web.DefaultRedirectStrategy - Redirecting to '/it/failedlogin'

...

              <form  role="form" action="j_spring_security_check" > 
                     <div class="form-group mb-4">
                            <label for="Email">Identifiant</label>
                            <input type="text" class="form-control"   name="username">  
                                 <!--small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small-->
                     </div>

                     <div class="form-group mb-4">
                            <label for="Password">Mot de passe</label>
                            <input type="password" class="form-control" name="password">
                     </div>


                                <div class="d-flex justify-content-center mt-3 login_container mb-3">
                                  <input type="submit" class="btn btn-success" value="connection" >
                                 </div>



                        <div class="text-center">
                       <span class="small" >créer un nouveau compte </span> <a class="small" href="/it/inscription/nouveau"> s'inscrire!</a>
                        </div>                                                              
              </form>

              ...

* application-config .xml *          

        <s:intercept-url pattern="/actualite/" access="ROLE_ADMIN , ROLE_USER"/>
        <!--    <s:intercept-url pattern="" access="ROLE_ADMIN"/> -->


        <s:form-login login-page="/" default-target-url="/home/" authentication-failure-url="/failedlogin"></s:form-login>


        <s:access-denied-handler error-page="/403/"></s:access-denied-handler>
        <s:logout   logout-success-url="/" delete-cookies="JSESSIONID"></s:logout>

    </s:http>

    <s:authentication-provider> 
    <!--   <s:password-encoder hash="md5"/> -->
     <s:jdbc-user-service data-source-ref="dataSource"
      users-by-username-query="select login, pwd ,actived from compte where login = ?"
      authorities-by-username-query="select v.login, r.nameRole from compte v ,roles r where v.idCpt = r.idCpt and v.login = ?"/>
    </s:authentication-provider>

0 个答案:

没有答案