標準 J2EE セキュリティーで HTTP 基本認証を使用することにより、統合 Web サービスを保護することができます。 これらのセキュリティー設定により、有効なユーザー名およびパスワードを持つ許可ユーザーが Web サービスにアクセスできるようになります。
手順
- HTTP サーブレットを保護する手順と同様に、次の例に示すように、web.xml ファイルで Web サービス呼び出しの <security-constraint> セクションをアンコメントします。
<security-constraint>
<web-resource-collection>
<web-resource-name>Integration Web Services</web-resource-name>
<description>
Integration Web Services accessible by authorized users
</description>
<url-pattern>/services/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>
Roles that have access to Integration Web Services
</description>
<role-name>maximouser</role-name>
</auth-constraint>
<user-data-constraint>
<description>data transmission gaurantee</description>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
- 次のコード例に示すように、web.xml ファイルの <security-role> セクションがコメント化されていないことを確認します。
<security-role>
<description>An Integration User</description>
<role-name>maximouser</role-name>
</security-role>
- 以下の例のように、「useAppServerSecurity <env-entry-name>」セクションで値を 0 から I に変更します。
<description>
Indicates whether to use Application Server security or not
</description>
<env-entry-name>useAppServerSecurity</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>1</env-entry-value>
</env-entry>
- Web サービスの呼び出しの場合、クライアント・プログラムが JAX-RPC Call オブジェクトで次のユーザー名とパスワード呼び出しを使用していることを確認します。
call.setProperty(Call.USERNAME_PROPERTY, username);
call.setProperty(Call.PASSWORD_PROPERTY, password);
次の作業
HTTPS ポストに Secure Sockets Layer (SSL) を使用すると、Web サービスを安全にデプロイすることができます。 アプリケーション・サーバーで、適切なデジタル証明書を指定して SSL を構成します。