7

私は古いアプリケーションを企業向けの「ビジネス」の方法で書き直そうとしています。
それで、ログインモジュールを備えたSwingクライアントと、ゼロから作成した独自のサーバーを手に入れました。クライアントはssl証明書を使用してサーバーへのTCP接続を暗号化し(サーバーでクライアント証明書をチェックし、クライアントでサーバー証明書をチェックします)、サーバーはデータベースを使用してユーザーを認証および承認します。

現在、WildFly 8 CR1 がホストする ejb で動作させようとしています。同じクライアント/サーバー キー ペアを使用して Swing クライアントを WildFly サーバーに接続し、MySQL データソースに保存されている名前と資格情報でユーザーを認証したいと考えています。データベースにロールも保存されており、それらを使用してクライアントプリンシパルを構成したいと考えています。

シンプルで基本的な EJB 呼び出しがあります。

Context ctx = new InitialContext();
MyBeanRemote bean = (MyBeanRemote)ctx.lookup("AppName/module-0.0.1-SNAPSHOT/MyBean!my.app.MyBeanRemote");
ResultType result = bean.doSomething();

jndi.properties ファイルがあります

java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=http-remoting://myServer:8080
jboss.naming.client.ejb.context=true
java.naming.security.principal=app-user-name
java.naming.security.credentials=password@123

そして、基本的なデータソース構成があります

<datasource jta="false" jndi-name="java:jboss/datasources/MyDB" pool-name="MyDB" enabled="true" use-ccm="false">
<connection-url>jdbc:mysql://localhost:3306/Mydb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.28-bin.jar</driver>
<security>
  <user-name>mysqlUser</user-name>
  <password>mysqlPass</password>
</security>
<validation>
  <validate-on-match>false</validate-on-match>
  <background-validation>false</background-validation>
</validation>
<statement>
  <share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>

上記のすべてが正常に動作します。

いくつかのガイドを読みましたが、EJB (Web ではない) + WildFly 8 (JBoss 7 ではない) + SSL による暗号化 + ログイン クライアント モジュールを使用したデータソース経由の認証と承認の複合体の使用方法を説明しているガイドが見つかりません。

どんな助けでも大歓迎です。

私の英語でごめんなさい、私はこの言語を書くのではなく読むのによく使います:)

4

1 に答える 1

2

次のように、standalone.xml ファイルでリモーティング コネクタにマッピングされたセキュリティ レルムを作成する必要があります。

<management>  
   <security-realms>  
    <security-realm name="MyRealm">  
      <authentication>  
        <jaas name="my-domain"/>  
      </authentication>  
    </security-realm>  
</management>  

<subsystem xmlns="urn:jboss:domain:remoting:1.1">
  <connector name="remoting-connector" socket-binding="remoting" security-realm="MyRealm"/>
</subsystem>

次に、適切な LoginModule (組み込みのもの、または独自のもの) を使用してセキュリティ ドメインを有効にする必要があります。

<security-domains>
    <security-domain name="my-domain" cache-type="default">
        <authentication>
            <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
                <module-option name="dsJndiName" value="java:jboss/datasources/serviceDS"/>
                <module-option name="principalsQuery" value="SELECT identificationCode FROM devices WHERE name=?"/>
                <module-option name="rolesQuery" value="SELECT 'device', 'Roles' FROM devices WHERE name=?"/>
            </login-module>
        </authentication>
    </security-domain>
</security-realms>

もちろん、データソースは、クエリが適切なプリンシパル (ユーザー) とそのロールを見つけるデータベースを指す必要があります。リモーティングに関する 2 つの記事を確認してください: https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+projectおよびhttps://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI。「古い」リモーティングを使用しているようです - クライアント ログイン モジュールは JBoss 7 からサポートされなくなりました。要するに、ejb リモーティング設定はより似ているはずです (許可されていないローカル ユーザーに注意してください!)。

remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=8080
remote.connection.default.username=userName
remote.connection.default.password=password
remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false

https://github.com/wildfly/quickstart/tree/master/ejb-remoteを確認してください。

最後に、セキュリティ ドメイン マッピングを jboss-ejb3.xml に追加することを忘れないでください。

<jboss:ejb-jar>
  <assembly-descriptor>  
    <s:security>     
      <ejb-name>*</ejb-name>    
      <s:security-domain>my-domain</s:security-domain>       
    </s:security>  
   </assembly-descriptor>
</jboss:ejb-jar
于 2014-01-19T18:46:04.497 に答える