私は春が初めてです。私は最近、アノテーションと基本的なセキュリティで動作するサンプルを手に入れました。今、ユーザーをsecurity-app-context.xml
ファイルで定義する必要があります。私たちがしたいことは、既存のデータベースに接続してそこのユーザーを使用することです。セキュリティのためにSpring MVCをデータベースに向けるにはどうしたらいいですか?
当社のユーザーのパスワードは(MD5)などとして格納されています
username salt password
moe blah bb3e4e328a64e9745a98728468aacbb0
ユーザーがmoe
、パスワードはhoward
ので、我々が使用している:ここでmd5(moehowardblah)
またはmd5(Username + Password + Salt)
は、私たちのweb.xmlです:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!--
- Location of the XML file that defines the root application context
- Applied by ContextLoaderListener.
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-business.xml
/WEB-INF/security-app-context.xml
</param-value>
</context-param>
<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>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
security-app-context.xml:
また、私が使用している例では、ユーザー/パス用の組み込みフォームを使用していますが、これは現在は問題ありませんが、独自のカスタムログインの使用方法を知る必要があります。しかし、私は別の質問のためにそれを保存することができます。
ありがとうございました。
ドキュメントでは理解できないことはありますか? http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#core-services-dao-provider –
Hmm。私は元々それを見ていませんでした。 Googleは私をどこかに導いた。 :-) – cbmeeks
OMGなんて悪夢。私はレールが恋しい。あまりにも悪いことは、ここではオプションではありません。 – cbmeeks