0
目前我通過Spring Filter和Servlet使用Spring Security認證。如果通過java代碼訪問URL,Spring認證失敗
<servlet-mapping>
<servlet-name>remoting</servlet-name>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>remoting</servlet-name>
<url-pattern>/admin</url-pattern>
</servlet-mapping>
<!-- Enables Spring Security -->
<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>
<!-- End Spring Security -->
在我的彈簧security.xml文件現在
<authentication-manager alias="authenticationManager">
<authentication-provider ref="myAppAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="myAppAuthenticationProvider"
class="com.filter.MyAppAuthenticationProvider">
<beans:property name="repository" value="#{deployment['globalregistry.repository']}"/>
</beans:bean>
當我打的網址,例如:http://localhost:8080/context/admin?action=authenticate
爲j_username:用戶
爲j_password:密碼
我得到一個用於輸入由spring-security認證的用戶和密碼。
現在,當我嘗試通過HTTPPost API通過Java程序訪問上述URL時,我得到的重定向錯誤響應爲302.現在如何繞過登錄屏幕進行驗證並直接進行身份驗證,而無需重定向到網頁。並使用我的java程序提供j_username和j_password。
請注意,當我點擊URL時,頁面被重定向到類似http://localhost:8080/context/spring_security_login
的東西。
你的幫助將會真心感謝你們!
或者通過POST,這僅僅是默認不允許的方法給他們。 – Xaerxess