activemq的密碼加密

這裏說的密碼加密並不是web端(8161端口)的賬號密碼,如果想要對那個的密碼進行加密的話,讀者可以自己去搜索關於jetty的安全驗證機制。

這裏的密碼加密是指61616默認模塊上面進行的密碼的加密,使用的是activemq方式進行的。

之前在網上看的好多關於密碼加密的都是
https://www.cnblogs.com/Peter2014/p/10981986.html

從這個網址來的,之後的搜索也都是這個的備份,有點不知道那些人不斷備份別人寫好的播客是爲了幹啥,閒着自己時間太多了?還是覺得別人一下子就搜到太容易了就想使壞

想要備份直接備份這個就夠了:

http://activemq.apache.org/encrypted-passwords

另外,

在activemq的開源項目assembly之中本來就有一個使用它本身自帶的加密的樣例:

下面附上樣例裏面的代碼:

<?xml version="1.0" encoding="UTF-8"?>

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
  <bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
    <property name="algorithm" value="PBEWithMD5AndDES" />
    <property name="passwordEnvName" value="ACTIVEMQ_ENCRYPTION_PASSWORD" />
  </bean>
                                                                     
  <bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
    <property name="config" ref="environmentVariablesConfiguration" />
  </bean>  
    
  <bean id="propertyConfigurer" class="org.jasypt.spring4.properties.EncryptablePropertyPlaceholderConfigurer">
      <constructor-arg ref="configurationEncryptor" /> 
      <property name="location" value="file:${activemq.conf}/credentials-enc.properties"/> 
  </bean> 

  <broker useJmx="true" persistent="false" xmlns="http://activemq.apache.org/schema/core" >

    <managementContext>
        <managementContext createConnector="true">
            <property xmlns="http://www.springframework.org/schema/beans" name="environment">
                <map xmlns="http://www.springframework.org/schema/beans">
                    <entry xmlns="http://www.springframework.org/schema/beans" key="jmx.remote.x.password.file"
                           value="${activemq.conf}/jmx.password"/>
                    <entry xmlns="http://www.springframework.org/schema/beans" key="jmx.remote.x.access.file"
                           value="${activemq.conf}/jmx.access"/>
                </map>
            </property>
        </managementContext>
    </managementContext>

    <plugins>
        <simpleAuthenticationPlugin>
            <users>
                <authenticationUser username="system" password="${activemq.password}"
                    groups="users,admins"/>
                <authenticationUser username="user" password="${guest.password}"
                    groups="users"/>
                <authenticationUser username="guest" password="${guest.password}" groups="guests"/>
            </users>
        </simpleAuthenticationPlugin>


      <authorizationPlugin>
        <map>
          <authorizationMap>
            <authorizationEntries>
              <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
              <authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
              <authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
              
              <authorizationEntry queue="TEST.Q" read="guests" write="guests" />
              
              <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
              <authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
              <authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
              
              <authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
            </authorizationEntries>
          </authorizationMap>
        </map>
      </authorizationPlugin>
    </plugins>
    
    <transportConnectors>
       <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
    </transportConnectors>

    <shutdownHooks>
        <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
    </shutdownHooks>

  </broker>

  <import resource="jetty.xml"/>

</beans>

需要注意的時這個配置文件裏面使用的org.jasypt.spring4.properties.EncryptablePropertyPlaceholderConfigurer,而本地可能只是jasypt.spring31

或者讀者自己去https://github.com/apache/activemq

這裏面查找

然後按照官網裏面操作的就行了,至於看不懂英文的不是問題,英文早已經不是學習的障礙了,簡單下一個谷歌瀏覽器就有自帶的網頁翻譯的功能。

 

另外,我本地其服務的時候老是報錯

出現錯誤的原因就是沒有完全按照裏面操作,解決方式我看有兩種:

一種是配置環境變量,

一種如上的使用那種替代方法

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