15.4. HTTPS 設定による EJB3 RMI


手順15.5 HTTPS による EJB3 RMI 設定の概要

これは SSL で暗号化された HTTP に Remote Method Invocation トラフィックのトンネリングを設定する手順です。これにはトラフィックを暗号化し、RMI ポートをブロックするファイアウォールをトラバースできるという 2 つの効果があります。
  1. 暗号化キーと証明書の生成
  2. HTTPS Web コネクタによる RMI の設定
  3. サーブレットの設定
  4. HTTPS による RMI のセキュアなリモートコネクタの設定
  5. HTTPS トランスポートに対する EJB3 Bean の設定
  6. HTTPS による RMI に対するクライアントの設定
暗号化キーと証明書の生成については 「暗号化キーと証明書の生成」 で取り上げています。

手順15.6 HTTPS Web コネクタによる RMI の設定

これは 8443 ポートでリッスンし、クライアントから SSL 接続を受け入れる Web コネクタを作成する手順です。
  • ファイル jboss-as/server/$PROFILE/deploy/jbossweb.sar/server.xml を編集し、HTTPS コネクタを非コメントします。
    <!-- SSL/TLS Connector configuration using the admin devl guide keystore -->
    <Connector protocol="HTTP/1.1" SSLEnabled="true"
       port="8443" address="${jboss.bind.address}"
       scheme="https" secure="true" clientAuth="false"
       keystoreFile="${jboss.server.home.dir}/conf/localhost.keystore"
       keystorePass="KEYSTORE_PASSWORD" sslProtocol = "TLS" />
    Copy to Clipboard Toggle word wrap
結果

Web コネクタを作成し、SSL 接続を受け入れます。

手順15.7 サーブレットの設定

これは Web コネクタから ServletServerInvoker に要求を渡すサーブレットを設定する手順です。
  1. jboss-as/server/$PROFILE/deploy/servlet-invoker.war という名前のディレクトリを作成します。
  2. servlet-invoker.war ディレクトリ内に WEB-INF ディレクトリを作成します。
  3. その WEB-INF ディレクトリに次の内容を含む web.xml という名前のファイルを作成します。
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    
    <web-app>
        <servlet>
            <servlet-name>ServerInvokerServlet</servlet-name>
            <description>The ServerInvokerServlet receives requests via HTTP
               protocol from within a web container and passes it onto the
               ServletServerInvoker for processing.
            </description>
            <servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class>
    
            <init-param>
                <param-name>locatorUrl</param-name>
                <param-value>servlet://${jboss.bind.address}:8080/servlet-invoker/ServerInvokerServlet</param-value>
                <description>The servlet server invoker</description>
            </init-param>
    
            <load-on-startup>1</load-on-startup>
        </servlet>
    
    
        <servlet>
            <servlet-name>SSLServerInvokerServlet</servlet-name>
            <description>The ServerInvokerServlet receives requests via HTTPS
               protocol from within a web container and passes it onto the
               ServletServerInvoker for processing.
            </description>
            <servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class>
    
            <init-param>
                <param-name>locatorUrl</param-name>
                <param-value>sslservlet://${jboss.bind.address}:8443/servlet-invoker/SSLServerInvokerServlet</param-value>
                <description>The servlet server invoker</description>
            </init-param>
    
            <load-on-startup>2</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>ServerInvokerServlet</servlet-name>
            <url-pattern>/ServerInvokerServlet/*</url-pattern>
        </servlet-mapping>
    
        <servlet-mapping>
            <servlet-name>SSLServerInvokerServlet</servlet-name>
            <url-pattern>/SSLServerInvokerServlet/*</url-pattern>
        </servlet-mapping>
    
    </web-app>
    Copy to Clipboard Toggle word wrap
    結果

    サーブレットを作成し、Web コンテナからサーバー invoker に SSL 要求を転送します。

locatorUrl を使用して、手順15.8「HTTPS による RMI のセキュアなリモートコネクタの設定」 で定義するリモートコネクタの InvokerLocator 属性を通じてサーブレットをリモートコネクタに接続します。

手順15.8 HTTPS による RMI のセキュアなリモートコネクタの設定

これは RMI を実装する Server Invoker を作成する手順です。
  • jboss-as/server/$PROFILE/deploy/ に次の内容を含む servlet-invoker-service.xml という名前のファイルを作成します。
    <?xml version="1.0" encoding="UTF-8"?>
    
    <server>
       <mbean code="org.jboss.remoting.transport.Connector" name="jboss.remoting:service=connector,transport=servlet"
        display-name="Servlet transport Connector">
          <attribute name="InvokerLocator">servlet://${jboss.bind.address}:8080/servlet-invoker/ServerInvokerServlet</attribute>
          <attribute name="Configuration">
             <handlers>
                <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
             </handlers>
          </attribute>
       </mbean>
    
       <mbean code="org.jboss.remoting.transport.Connector" name="jboss.remoting:service=connector,transport=sslservlet"
        display-name="Servlet transport Connector">
          <attribute name="InvokerLocator">sslservlet://${jboss.bind.address}:8443/servlet-invoker/SSLServerInvokerServlet</attribute>
          <attribute name="Configuration">
             <handlers>
                <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
             </handlers>
          </attribute>
       </mbean>
    </server>
    Copy to Clipboard Toggle word wrap
結果

サーブレットからの要求を受け入れ、EJB3 のメソッドを呼び出すことができるリモートコネクタを作成します。

手順15.9 HTTPS トランスポートに対する EJB3 Bean の設定

これは HTTPS トランスポートにバインドする EJB3 を設定する手順です。
  • HTTPS により RMI を使用するために Bean をアノテートする

    例15.5 HTTPS により RMI を使用するために EJB3 をアノテートする

    // RMI tunneled over HTTPS
    @Stateless
    @RemoteBinding(clientBindUrl = "https://0.0.0.0:8443/servlet-invoker/SSLServerInvokerServlet")
    @Remote(Calculator.class)
    @SecurityDomain("other")
    public class CalculatorHttpsBean implements Calculator
    {
    ....
    Copy to Clipboard Toggle word wrap
    結果

    これで HTTPS によるリモート呼び出しに EJB3 が使用可能になりました。

HTTP により RMI を使用するために Bean をアノテートする

オプションとして、HTTP による RMI での呼び出しに Bean をアノテートすることができます。これは RMI ポートをブロックするファイアウォールを通じて RMI 呼び出しをトンネルできるためテストに役立ちますが、セキュリティ設定の別のレイヤを削除します。

例15.6 HTTP により RMI を使用するために Bean をアノテートする

// RMI tunneled over HTTP
@Stateless
@RemoteBinding(clientBindUrl = "http://0.0.0.0:8080/servlet-invoker/ServerInvokerServlet")
@Remote(Calculator.class)
@SecurityDomain("other")
public class CalculatorHttpBean extends CalculatorImpl
{
....
Copy to Clipboard Toggle word wrap
HTTPS による RMI に対するクライアントの設定

Bean を検索する場合、EJB クライアントは JNDI ルックアップに次のプロパティを使用するべきです。

HTTP(S) による RMI へのクライアントアクセス

HTTPS
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory");
props.put("java.naming.provider.url", "https://localhost:8443/invoker/JNDIFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming");
Context ctx = new InitialContext(props);
props.put(Context.SECURITY_PRINCIPAL, username);
props.put(Context.SECURITY_CREDENTIALS, password);
Calculator calculator = (Calculator) ctx.lookup(jndiName);
// use the bean to do any operations
Copy to Clipboard Toggle word wrap
HTTP
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory");
props.put("java.naming.provider.url", "http://localhost:8080/invoker/JNDIFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming");
Context ctx = new InitialContext(props);
props.put(Context.SECURITY_PRINCIPAL, username);
props.put(Context.SECURITY_CREDENTIALS, password);
Calculator calculator = (Calculator) ctx.lookup(jndiName);
// use the bean to do any operations
Copy to Clipboard Toggle word wrap
HTTP(S) による RMI へのクライアントアクセス では、user namepassword の値は http-invoker をセキュアにするために使用するセキュリティドメインの有効なユーザー名とパスワードに一致します。このセキュリティドメインは jboss-as/$PROFILE/deploy/http-invoker.sar/invoker.war/WEB-INF/jboss-web.xml で設定されます。
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat