0

次のセクションでは、すべてのクライアントに https 接続を使用するよう強制する必要があります。

<security-constraint>
    <web-resource-collection>
        <web-resource-name>securedapp</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint>
</security-constraint>

実際には、index.html ページのみが ssl によって保護されます。したがって、次のようなリクエストhttp://localhost/JAX-RS_Service/がリダイレクトされhttps://localhost/JAX-RS_Service/、index.html ページが表示されます。同じことですが、http://localhost/JAX-RS_Service/index.html リクエストしようとするとhttp://localhost/JAX-RS_Service/services/customers/1、https へのリダイレクトがないため、すべてがプレーンテキストで送信されます。

認証を強制する場合も同様です

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Authenticated customers only</web-resource-name>
        <url-pattern>/services/customers/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>CUST</role-name>
    </auth-constraint>
</security-constraint>

のような URL パターン<url-pattern>/services/*</url-pattern>は機能しません。

がサブロケーションで機能しないのはなぜ<url-pattern>/*</url-pattern>ですか。これを修正する方法はありますか?

4

1 に答える 1

0

実際には理由はわかりませんが、次の構成で問題が解決しました。

    <security-constraint>
    <web-resource-collection>
        <web-resource-name>SSL Secured WebService</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint>
</security-constraint>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Authenticated customers only</web-resource-name>
        <url-pattern>/services/customers/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>CUST</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint>
</security-constraint>

それぞれに追加する<user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint>必要があり<security-constraint>ます。そうしないと、JBoss では機能しません。興味深いことに、Tomcat の場合、<transport-guarantee>CONFIDENTIAL</transport-guarantee>一度だけを定義する必要が<url-pattern>/*</url-pattern>あり、すべてが適切に保護されます。私の意見では、これははるかに合理的です!

于 2013-05-18T23:51:38.777 に答える