Activemq配置——Jaas方式配置用戶登錄驗證

配置方式:

一、要配置系統環境變量:配置Jaas加載的配置文件路徑。


linux下使用

export ACTIVEMQ_OPTS=-Djava.security.auth.login.config=<login.config存儲路徑> 
或是在profile文件末尾添加上這樣一個導出

windows下

SET ACTIVEMQ_OPTS=%ACTIVEMQ_OPTS% -Djava.security.auth.login.config=<login.config存儲路徑>


二、配置配置文件


在配置文件broker之間添加下面的配置

  1. <plugins>  
  2.         <!-- Configure authentication; Username, passwords and groups
  3.  添加jaas認證插件  
  4. activemq-domain 在login.config裏面定義,詳細見login.config -->  
  5.         <jaasAuthenticationPlugin configuration="activemq-domain" />
  6.   
  7.   
  8.       <!--  Lets configure a destination based authorization mechanism 
  9. 配置隊列用戶權限,>表示任意字符 -->  
  10.       <authorizationPlugin>  
  11.         <map>  
  12.           <authorizationMap>  
  13.             <authorizationEntries>  
  14.               <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />  
  15.               <authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />  
  16.               <authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />  
  17.                 
  18.               <authorizationEntry queue="TEST.Q" read="guests" write="guests" />  
  19.                 
  20.               <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />  
  21.               <authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />  
  22.               <authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />  
  23.                 
  24.               <authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>  
  25.             </authorizationEntries>  
  26.           </authorizationMap>  
  27.         </map>  
  28.       </authorizationPlugin>  
  29.     </plugins>  


login.config:Jaas插件驗證入口

  1. activemq-domain //與配置文件中jaas plugin配置中的configuration相一致
  2. {
        org.apache.activemq.jaas.PropertiesLoginModule required//加載模塊
            debug=true //設置調試模式
            org.apache.activemq.jaas.properties.user="users.properties"//配置users.properties的相應文件路徑
            org.apache.activemq.jaas.properties.group="groups.properties";//配置groups.properties的相應文件路徑
    };
下載連接:login.config


users.properties:配置用戶名和密碼

  1. ## ---------------------------------------------------------------------------
    ## Licensed to the Apache Software Foundation (ASF) under one or more
    ## contributor license agreements.  See the NOTICE file distributed with
    ## this work for additional information regarding copyright ownership.
    ## The ASF licenses this file to You under the Apache License, Version 2.0
    ## (the "License"); you may not use this file except in compliance with
    ## the License.  You may obtain a copy of the License at
    ## 
    ## http://www.apache.org/licenses/LICENSE-2.0
    ## 
    ## Unless required by applicable law or agreed to in writing, software
    ## distributed under the License is distributed on an "AS IS" BASIS,
    ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ## See the License for the specific language governing permissions and
    ## limitations under the License.
    ## ---------------------------------------------------------------------------

    #格式user=password

  2. system=manager
    user=password
    guest=password
    sslclient=CN=localhost, OU=activemq.org, O=activemq.org, L=LA, ST=CA, C=US
下載連接:users.properties

group.properties:配置用戶對應的用戶組

  1. ## ---------------------------------------------------------------------------
    ## Licensed to the Apache Software Foundation (ASF) under one or more
    ## contributor license agreements.  See the NOTICE file distributed with
    ## this work for additional information regarding copyright ownership.
    ## The ASF licenses this file to You under the Apache License, Version 2.0
    ## (the "License"); you may not use this file except in compliance with
    ## the License.  You may obtain a copy of the License at
    ## 
    ## http://www.apache.org/licenses/LICENSE-2.0
    ## 
    ## Unless required by applicable law or agreed to in writing, software
    ## distributed under the License is distributed on an "AS IS" BASIS,
    ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    ## See the License for the specific language governing permissions and
    ## limitations under the License.
    ## ---------------------------------------------------------------------------

    #格式:用戶組=用戶1,用戶2,...
    admins=system,sslclient,client,broker1,broker2
    tempDestinationAdmins=system,user,sslclient,client,broker1,broker2
    users=system,user,sslclient,client,broker1,broker2
    guests=guest
下載連接:group.properties



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章