Mule spring基本安全性因用户服务属性文件

时间:2015-10-20 03:39:20

标签: spring-security mule

我正在配置Mule应用程序(在API Gateway 2.1上运行),并在配置spring security时遇到一些问题。

这是安全配置:

<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  

我觉得令人困惑的是,当我使用嵌入式用户时(请参阅上面Mule流程中的注释部分),并删除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]       在org.mule.module.launcher.artifact.ArtifactWrapper $ 2.execute(ArtifactWrapper.java:62)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:57)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:310)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:330)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:155)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:256)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:78)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:275)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:100)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.module.launcher.MuleContainer.start(MuleContainer.java:170)〜[mule-module-launcher-3.7.2.jar:3.7.2]       在org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:21)〜[tooling-support-1.0.0.jar:?]   引起:org.mule.api.config.ConfigurationException:创建名称为&#39; _muleSecurityManager&#39;:无法创建内部bean&#39;(内部bean)#157a5cdc&#39;类型为[org.mule.module.spring.security.S   pringProviderAdapter]设置bean属性&#39; provider&#39;用键[0];嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为&#39;(内部bean)#157的错误   a5cdc&#39;:无法解析对bean&#39; authenticationManager&#39;的引用设置bean属性&#39;委托&#39 ;;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建bea时出错   n名称&#39; org.springframework.security.authenticationManager&#39;:无法解析对bean的引用&org.springframework.security.authentication.dao.DaoAuthenticationProvider#0&#39;设置构造   或者用键[0]参数;嵌套异常是org.springframework.beans.factory.BeanCreationException:使用名称&#39; org.springframework.security.authentication.dao.DaoAuthenticationP创建bean时出错   rovider#0&#39;:无法解析对bean的引用&#39; userService&#39;设置bean属性&#39; userDetailsS​​ervice&#39 ;;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建错误    bean名称&#39; userService&#39;:通过构造函数的Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.security。   provisioning.InMemoryUserDetailsManager]:构造函数抛出异常;嵌套异常是java.lang.NullPointerException(org.mule.api.lifecycle.InitialisationException)(org.mule.api.config.Configur   ationException)       在org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:49)〜[mule-core-3.7.2.jar:3.7.2]       在org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69)〜[mule-core-3.7.2.jar:3.7.2]       在org.mule.context.DefaultMuleContextFactory $ 1.configure(DefaultMuleContextFactory.java:89)〜[mule-core-3.7.2.jar:3.7.2]       在org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:222)〜[mule-core-3.7.2.jar:3.7.2]       在org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81)〜[mule-core-3.7.2.jar:3.7.2]       在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:创建名称为&#39; _muleSecurityManager&#39;:无法创建内部bean&#39;(内部bean)#157a5cdc&#39;类型为[org.mule.module.spring.security.S   pringProviderAdapter]设置bean属性&#39; provider&#39;用键[0];嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为&#39;(内部bean)#157的错误   a5cdc&#39;:无法解析对bean&#39; authenticationManager&#39;的引用设置bean属性&#39;委托&#39 ;;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建bea时出错   n名称&#39; org.springframework.security.authenticationManager&#39;:无法解析对bean的引用&org.springframework.security.authentication.dao.DaoAuthenticationProvider#0&#39;设置构造   或者用键[0]参数;嵌套异常是org.springframework.beans.factory.BeanCreationException:使用名称&#39; org.springframework.security.authentication.dao.DaoAuthenticationP创建bean时出错   rovider#0&#39;:无法解析对bean的引用&#39; userService&#39;设置bean属性&#39; userDetailsS​​ervice&#39 ;;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建错误    bean名称&#39; userService&#39;:通过构造函数的Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.security。   provisioning.InMemoryUserDetailsManager]:构造函数抛出异常;嵌套异常是java.lang.NullPointerException(org.mule.api.lifecycle.InitialisationException)

1 个答案:

答案 0 :(得分:1)

我试过这个并发现如果你调用属性文件,请说myusers.properties然后它可以工作。看起来在类路径上有一些其他的users.properties由一个具有不正确的SS格式的mule依赖项添加,因此抛出了可怕的错误。所以只需将文件重命名为其他内容。