すべて、春のWebセキュリティの質問
私は特定のユーザ名とパスワードの組み合わせを使用できるように、私は自分のアプリケーションのセットアップを持っている:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http use-expressions="true" access-denied-page="/start.jsf">
<intercept-url pattern="/start.jsf" filters="none" />
<intercept-url pattern="/web/**" access="isAuthenticated()" />
<form-login login-page="/start.jsf" default-target-url="/web/user/homepage.jsf" authentication-failure-url="/start.jsf?state=failure"/>
<logout logout-success-url="/start.jsf?state=logout" />
</http>
<!-- <authentication-manager alias="authenticationManager">
<authentication-provider>
<password-encoder hash="md5" />
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT U.email_address AS username, U.password as password, 'true' as enabled FROM users U where U.email_address=?"
authorities-by-username-query="SELECT U.email_address AS username, 'USER' as authority FROM users U WHERE U.email_address=?"
role-prefix="ROLE_" />
</authentication-provider>
</authentication-manager> -->
<authentication-manager alias="authenticationManager">
<authentication-provider>
<password-encoder hash="md5"/>
<user-service>
<user name="user1" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
問題は、それは、私が後藤にDataSourceを、それを要求したときということですデータソースを見つけることができません。この理由は、すべてのJavaソースファイルがあるconfigフォルダに別のApplicationContext.xmlがあります。このファイルがデータソースファイルをピックアップできるように、人々は通常どのようにプロジェクトを編成しますか?私はそれに応じてプロジェクトを設定したい...入力のおかげで!
また、ログインは機能しますが、ユーザーがログインすると、ユーザーID /パスワードを取得できるようになりますが、できません。そんなことがあるものか?
しかし、これはサーブレット経由で行われているので、コンテキストを取得してBeanを取得するにはどうすればよいですか? – KVISH
@kalvishでは、 'ApplicationContext ctx =(ApplicationContext)getServletContext()。getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); ' – alexkasko
hmm ...を使ってサーブレットからアプリコンテキストにアクセスできます。しかしこれは次のようなものでした: 'WebApplicationContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance()。getExternalContext()。getContext());' – KVISH