2015-10-20 79 views
0

我正在配置一個Mule應用程序(在API網關2.1上運行),並在配置彈簧安全性時遇到一些問題。Mule spring基本安全失敗,用戶服務屬性文件

這裏是安全配置:

<spring:beans> 
    <ss:authentication-manager alias="authenticationManager"> 
     <ss:authentication-provider > 
      <ss:user-service id="userService" properties="classpath:users.properties"> 
      <!-- **** This works, but the properties file above^doesn't **** 
       <ss:user name="user" password="password" authorities="ROLE_ADMIN"/> 
       <ss:user name="anon" password="anon" authorities="ROLE_ANON" /> 
      --> 
      </ss:user-service> 
     </ss:authentication-provider> 
    </ss:authentication-manager> 
</spring:beans> 

<mule-ss:security-manager name="security-manager" 
    doc:name="Spring Security Provider"> 
    <mule-ss:delegate-security-provider 
     name="memory-provider" delegate-ref="authenticationManager" /> 
</mule-ss:security-manager> 

users.properties是我的類路徑,幷包含以下內容:

user=userpassword,ROLE_USER,enabled 
admin=admin,ROLE_USER,ROLE_ADMIN,enabled 
chris=chrispassword,ROLE_USER,enabled 

我感到困惑的是,當我使用嵌入的用戶(見註釋部分在上面的騾流),並刪除properties=classpath:users.properties,一切運行良好。但是當我嘗試使用users.properties時,我得到下面的異常。我知道在類路徑中找到users.properties。我錯誤地配置了users.properties?如果這是一個更一般的配置問題,爲什麼它總是失敗?

,我發現了以下異常(堆棧跟蹤的頂部):

org.mule.module.launcher.DeploymentInitException:NullPointerException異常: 在org.mule.module.launcher.application。 DefaultMuleApplication.init(DefaultMuleApplication.java:197)〜[mule-module-launcher-3.7.2.jar:3.7.2] at org.mule.module.launcher.artifact.ArtifactWrapper $ 2.execute(ArtifactWrapper.java:62 )〜[mule-module-launcher-3.7.2.jar:3.7.2] at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129)〜[mule-module-launcher-3.7 .2.jar:3.7.2] at org。 mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:57)〜[mule-module-launcher-3.7.2.jar:3.7.2] at org.mule.module.launcher.DefaultArtifactDeployer.deploy( DefaultArtifactDeployer.java:25)〜[mule-module-launcher-3.7.2.jar:3.7.2] at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:310)〜[mule-module- launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:330)〜[mule-module-launcher-3.7.2.jar:3.7.2]啓動器 - 3.7.2.jar:3.7.2] 在org.mule.module.launcher.DefaultArchiveDeployer上的org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:155)〜[mule-module-launcher-3.7.2.jar:3.7.2] 。 deployPackagedArtifact(DefaultArchiveDeployer.java:256)〜[mule-module-launcher-3.7.2.jar:3.7.2] 在org.mule.module.launcher.DeploymentDirectoryWatcher上的org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:78)〜[mule-module-launcher-3.7.2.jar:3.7.2] 。 deployPackedApps(DeploymentDirectoryWatcher.java:275)〜[mule-module-launcher-3.7.2.jar:3.7.2] at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150)〜[mule- module-launcher-3.7.2.jar:3.7.2] at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:100)〜[mule-module-launcher-3.7.2.jar:3.7。 2] at org.mule.tooling.server上的org.mule.module.launcher.MuleContainer.start(MuleContainer.java:170)〜[mule-module-launcher-3.7.2.jar:3.7.2] 。 application.ApplicationDeployer.main(ApplicationDeployer.java:21)〜[tooling-support-1.0.0.jar :?] 原因:org.mule.api.config.ConfigurationException:創建名爲'_muleSecurityManager'的bean時出錯:無法創建類型爲[org.mule.module.spring.security.S ]的內部bean'(內部bean)#157a5cdc' pringProviderAdapter],同時使用鍵[0]設置bean屬性'providers';嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名稱爲'(內部bean)的bean時出錯#157 a5cdc':設置bean屬性'delegate'時無法解析對bean'authenticationManager'的引用;嵌套異常是org.springframework.beans.factory。BeanCreationException:創建名爲'org.springframework.security.authenticationManager'的bea 錯誤:在設置構造 或使用鍵[0]的參數時,無法解析對bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'的引用。 ;嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名爲'org.springframework.security.authentication.dao.DaoAuthenticationP rovider#0'的Bean時出錯:無法在設置bean屬性'userDetailsS​​ervice時解析對bean'userService'的引用「;嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名稱爲'userService'的 bean時出錯:通過構造函數的Bean實例化失敗;嵌套異常是org.springframework.beans.BeanInstantiationException:無法實例化[org.springframework.security。 provisioning.InMemoryUserDetailsManager]:構造函數拋出異常;嵌套異常是java.lang.NullPointerException(org.mule.api.lifecycle.InitialisationException)(org.mule.api.config.Configur ationException) at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java: 49)〜[mule-core-3.7.2.jar:3.7.2] at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69)〜[mule-core-3.7.2.jar: 3.7.2] at org.mule.context.DefaultMuleContextFactory $ 1.configure(DefaultMuleContextFactory.java:89)〜[mule-core-3.7.2.jar:3.7.2] at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext (DefaultMuleContextFactory.java:222)〜[mule-core-3.7.2.jar:3.7.2] at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81)〜[mule-core-3.7.2 。罐:3.7.2] at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:188)〜[mule-module-launcher-3.7.2.jar:3.7.2] ... 14更多 導致:org.mule.api.config.ConfigurationException:創建名爲'_muleSecurityManager'的bean時出錯:無法創建類型爲[org.mule.module.spring.security.S的內部bean'(內部bean)#157a5cdc' pringProviderAdapter],同時使用鍵[0]設置bean屬性'providers';嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名稱爲'(內部bean)的bean時出錯#157 a5cdc':設置bean屬性'delegate'時無法解析對bean'authenticationManager'的引用;嵌套的異常是org.springframework.beans.factory.BeanCreationException:創建名爲'org.springframework.security.authenticationManager'的bea 錯誤:無法解析對bean的引用'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'同時使用鍵[0]設置構造 或參數;嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名爲'org.springframework.security.authentication.dao.DaoAuthenticationP rovider#0'的Bean時出錯:無法在設置bean屬性'userDetailsS​​ervice時解析對bean'userService'的引用「;嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名稱爲'userService'的 bean時出錯:通過構造函數的Bean實例化失敗;嵌套異常是org.springframework.beans.BeanInstantiationException:無法實例化[org.springframework.security。 provisioning.InMemoryUserDetailsManager]:構造函數拋出異常;嵌套的例外是顯示java.lang.NullPointerException(org.mule.api.lifecycle.InitialisationException)

回答

1

我嘗試這樣做,發現,如果你調用的屬性文件別的東西,說myusers.properties那麼它的工作原理。它看起來有一些其他users.properties類路徑添加了一個mule依賴關係,它具有不正確的SS格式,因此會引發可怕的錯誤。所以只需將文件重命名爲其他內容。

+0

沒錯,謝謝!幾個小時以來,我一直在嘲笑我, – deyur