2013-06-28 5 views
9

JBoss 7でセキュリティドメインを使用してアノテーションによるEJBセキュリティを使用しています。例えば。JBoss 7.1.1のstandalone.xml外のセキュリティドメインを宣言する

@RolesAllowed({"User", "Admin"}) 

現在、私はstandalone.xmlにセキュリティドメインを宣言しています。これは小さなものには合理的ですが、同じJBoss Server上のさまざまなプロジェクトでこのセキュリティの児童を使用したいと思います。したがって、私はstandalone.xmlの外でセキュリティドメインを宣言する方法を探しています。私は戦争の中でデプロイメント記述子を使用することを考えました。

this documentationによると、これが可能であるはずです。これはJBoss 5用であり、JBoss 7.1.1では動作しないようです。パーサーエラーのため、JBossを起動すると例外がスローされます。私もthis questionを見たことがあるが、これが私が必要とするものかどうかはわからない。私は、standalone.xmlの外のどこかでログインモジュールを使って新しいセキュリティドメインを宣言する必要があります。

セキュリティドメインの宣言と設定をwar-Deploymentに格納する方法はありますか?

おかげ

答えて

3

私は、これは簡単な方法(related JIRA issue)で、現時点では可能ではないと思います。ただし、回避策としてjboss-as-maven-pluginを使用することができます。

<profiles> 
     <profile> 
      <id>deploy-security-domain</id> 
      <activation> 
       <activeByDefault>false</activeByDefault> 
      </activation> 
      <build> 
       <pluginManagement> 
        <plugins> 
         <plugin> 
          <groupId>org.jboss.as.plugins</groupId> 
          <artifactId>jboss-as-maven-plugin</artifactId> 
          <version>7.4.Final</version> 
          <executions> 
           <execution> 
           <id>add-security-domain</id> 
           <phase>install</phase> 
           <goals> 
            <!-- This should work in both "standalone" and "domain" mode --> 
            <goal>execute-commands</goal> 
           </goals> 
           <configuration> 
            <execute-commands> 
            <batch>true</batch> 
            <commands> 
             <command>/subsystem=security/security-domain=MyDomain:add(cache-type=default)</command> 
             <command>/subsystem=security/security-domain=MyDomain/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:jboss/datasources/UserDB"),("principalsQuery"=>"select password from users where user_name=?"),("rolesQuery"=>"select role, 'Roles' from user_roles where user_name=?"),("hashAlgorithm"=>"SHA-256"),("hashEncoding"=>"base64")]}]</command> 
            </commands> 
            </execute-commands> 
           </configuration> 
           </execution> 
          </executions> 
         </plugin> 
        </plugins> 
       </pluginManagement> 
      </build> 
     </profile> 
</profiles> 

実行:

mvn install -P deploy-security-domain 

は別のオプションは、多かれ少なかれ同じことをしCLIスクリプトだろう。たとえば、thisクイックスタートプロジェクトをご覧ください。

関連する問題