4

Spring Security ファイルで HTTP と HTTPS の両方をサポートし、実行時にそれらを動的に切り替える必要があります。

そのため、any/http/https のいずれかを含むプロパティ ファイルを作成しようとしていますが、それでは XML 構成が解析されません。

春のセキュリティ構成:

<sec:http entry-point-ref="portalEntryPoint">
    <sec:anonymous />
    <sec:intercept-url pattern = "/portal" access="IS_AUTHENTICATED_ANONYMOUSLY"
            requires-channel="${user-security.login.channel}" />
    <!-- rest omitted -->
</sec:http>

プロパティ ファイル:

user-security.login.channel=https

次のエラーが表示されます。

Caused by: org.xml.sax.SAXParseException: cvc-enumeration-valid: Value '${user-security.login.channel}' is not facet-valid with respect to enumeration '[http, https, any]'. It must be a value from the enumeration.

Spring 3 と Spring Security 2 を使用しています。

4

2 に答える 2

1

絶対に必要な場合は、プロファイルを使用してポータル エントリ ポイントを構成します。明らかに、これは春の設定で多くのコピーと貼り付けを意味します....

springsource docs の例:

<bean id="transferService" class="com.bank.service.internal.DefaultTransferService">
    <constructor-arg ref="accountRepository"/>
    <constructor-arg ref="feePolicy"/>
</bean>

<bean id="accountRepository" class="com.bank.repository.internal.JdbcAccountRepository">
    <constructor-arg ref="dataSource"/>
</bean>

<bean id="feePolicy" class="com.bank.service.internal.ZeroFeePolicy"/>

<beans profile="dev">
    <jdbc:embedded-database id="dataSource">
        <jdbc:script location="classpath:com/bank/config/sql/schema.sql"/>
        <jdbc:script location="classpath:com/bank/config/sql/test-data.sql"/>
    </jdbc:embedded-database>
</beans>

<beans profile="production">
    <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/datasource"/>
</beans>

リンクhttp://blog.springsource.com/2011/02/14/spring-3-1-m1-introducing-profile/

于 2012-08-31T15:43:38.547 に答える
1

これは Spring Security 2 では不可能でした。Spring Security 3.0+ を使用する必要があります。

Spring Security 3.0 のリリース前に修正された、このサポートに関する問題が提出されました。

于 2012-08-31T14:51:43.837 に答える