Mule 功能测试期间未注册安全提供程序

Mule 功能测试期间未注册安全提供程序,mule,esb,Mule,Esb,我们在部署在Mule上的RestFul Web服务中使用基本身份验证,安全性由内置的Spring安全性提供支持。我们正在使用Mule 3.3.0 我们将mflow分为两个不同的部分:main.xml和connector.xml。原因是,在运行功能测试时,我们传递另一个mflow connector-test.xml,而不是connector.xml,其中所有端点(如AMQ等)都是存根的。然而对于Rest,我们仍然使用适当的端点。 在我们的Mule功能测试中,我们使用ApacheCommonsHt

我们在部署在Mule上的RestFul Web服务中使用基本身份验证,安全性由内置的Spring安全性提供支持。我们正在使用Mule 3.3.0

我们将mflow分为两个不同的部分:main.xml和connector.xml。原因是,在运行功能测试时,我们传递另一个mflow connector-test.xml,而不是connector.xml,其中所有端点(如AMQ等)都是存根的。然而对于Rest,我们仍然使用适当的端点。 在我们的Mule功能测试中,我们使用ApacheCommonsHttpClient对这些端点进行RESTfulWS调用,等待响应,然后检查它是否通过了测试

同样的功能在mule standalone中也可以很好地工作——即rest webservice可以很好地部署,我们可以发出http rest请求——它得到基本的身份验证,然后返回响应。但是,在功能测试期间进行身份验证时,它会失败,并显示消息

Exception stack is:
1. There is no Security Provider reqistered called "org.mule.security.DefaultMuleAuthentication" (org.mule.api.security.SecurityProviderNotFoundException)
  org.mule.security.MuleSecurityManager:107 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/SecurityProviderNotFoundException.html)
********************************************************************************
Root Exception stack trace:
org.mule.api.security.SecurityProviderNotFoundException: There is no Security Provider reqistered called "org.mule.security.DefaultMuleAuthentication"
      at org.mule.security.MuleSecurityManager.authenticate(MuleSecurityManager.java:107)
      at org.mule.transport.http.filters.HttpBasicAuthenticationFilter.authenticateInbound(HttpBasicAuthenticationFilter.java:134)
      at org.mule.security.AbstractEndpointSecurityFilter.authenticate(AbstractEndpointSecurityFilter.java:58)
      at org.mule.security.AbstractAuthenticationFilter.doFilter(AbstractAuthenticationFilter.java:56)
      at org.mule.security.AbstractEndpointSecurityFilter.doFilter(AbstractEndpointSecurityFilter.java:49)
      at org.mule.processor.SecurityFilterMessageProcessor.process(SecurityFilterMessageProcessor.java:52)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:192)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:174)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:166)
      at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:153)
      at org.mule.transport.http.HttpMessageReceiver$HttpWorker$1.process(HttpMessageReceiver.java:310)
      at org.mule.transport.http.HttpMessageReceiver$HttpWorker$1.process(HttpMessageReceiver.java:305)
      at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:20)
      at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:34)
      at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:18)
      at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:58)
      at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:48)
      at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:54)
      at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:44)
      at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:44)
      at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:52)
      at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:32)
      at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:17)
      at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:113)
      at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:34)
      at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:304)
      at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:250)
      at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:163)
      at org.mule.work.WorkerContext.run(WorkerContext.java:311)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
知道为什么安全提供商没有注册吗

以下是设置

main.xml的内容


请帮忙。connector.xml中使用了相同的安全设置,当应用程序部署在独立的mule 3.3.0中时,它可以很好地部署,并且基本的身份验证也可以很好地执行。不知何故,在运行Mule功能测试时,安全提供程序没有得到注册,其中Mule服务器在内存中启动,并使用测试配置为测试部署了应用程序。

能否命名不同的代码段文件名并显示getConfigResources是如何编码的?您好,David,此方法受保护字符串getConfigResources{return main.xml,connector-test.xml;}对于mule standalone中的实时部署,我们在mule-deploy.properties中配置为config.resources=main.xml,正如您所看到的,对于测试,我们使用connector-test.xml,这样我们就可以去掉ActiveMQ连接器和一些spring注入的服务层类。非常感谢您的帮助。期待着你的到来,汉克斯。您能否编辑您的帖子,并在配置片段中清楚地显示属于main.xml和connector-test.xml的内容?谢谢David。我试图在MuleStudio中运行Junit测试时遇到了巨大的类路径错误。今天忙得不可开交,所以不能做很多测试。但是-我将行从main.xml移到connector.xml和connector-test.xml,现在测试运行正常。我不再获得SecurityProviderNotFoundException。因此,所有的spring安全设置都只在连接器xmls中—用于实时和测试。但是,还有一个问题——即使我给一个用户传递了错误的密码,它仍在工作,所以仍然需要查看。将返回tmorrowWow-一旦我将所有与安全相关的设置从connector-test.xml移到main.xml,它就开始正常工作,安全提供程序开始启动-即提供程序不再为空。让我想知道我是否正在将2个xml传递给getConfigResources,如main.xml、connector-test.xml——如果提供程序被拆分为2个不同的xml,则无法加载它们。大卫,你也是这样安排考试的吗?i、 e.如原问题所述,在2个不同的XML中拆分mule:ss和ss:configs?热衷于理解在测试中这是一个怎样的问题,但在独立测试中效果很好!
 <flow name="RestFlow" doc:name="RestFlow">
    <inbound-endpoint ref="restEndPoint" mimeType="text/xml">
            <mule-ss:http-security-filter realm="easervices-realm" />
        </inbound-endpoint>

            <jersey:resources doc:name="REST">
 <component>
            <spring-object bean="createCompany"/>            
        </component>
        <component>
            <spring-object bean="activateNumbers"/>            
        </component>
 </jersey:resources>
</flow>
    ........
<spring:beans>
      <spring:import resource="classpath:spring/external-service-config-stub.xml" />

      <ss:authentication-manager alias="authenticationManager">
            <ss:authentication-provider>
                  <ss:password-encoder hash="sha" />
                  <ss:user-service id="userService">
                        <ss:user name="adminportal" password="0314795e56347590b54b7da2afba3456fgcd4968"
                              authorities="ROLE_ADMIN" />
                  </ss:user-service>

            </ss:authentication-provider>
      </ss:authentication-manager>
      <ss:global-method-security
            pre-post-annotations="enabled" jsr250-annotations="enabled" />
      </spring:beans>

<http:endpoint exchange-pattern="request-response" host="localhost"
            port="8098" path="mypath" name="restEndPoint" doc:name="HTTP" />
<mule-ss:security-manager>
            <mule-ss:delegate-security-provider
                  name="memory-provider" delegate-ref="authenticationManager" />
      </mule-ss:security-manager>
<spring:beans>
    <spring:import resource="classpath:spring/external-service-config.xml" />

    <ss:authentication-manager alias="authenticationManager">
         <ss:authentication-provider>
                  <ss:password-encoder hash="sha" />
                  <ss:user-service id="userService">
                        <ss:user name="adminportal" password="0314795e56347590b54b7da2afba3456fgcd4968"
                              authorities="ROLE_ADMIN" />
                  </ss:user-service>

            </ss:authentication-provider>
    </ss:authentication-manager>
    <ss:global-method-security
        pre-post-annotations="enabled" jsr250-annotations="enabled" />

    <context:property-placeholder location="classpath:config/mule-config.properties" />
    </spring:beans>

<http:endpoint exchange-pattern="request-response" host="localhost"
        port="8088" path="mypath" name="restEndPoint" mimeType="text/xml"
        doc:name="HTTP" />
<mule-ss:security-manager>
        <mule-ss:delegate-security-provider
            name="memory-provider" delegate-ref="authenticationManager" />
    </mule-ss:security-manager>
httpClient.getState().setCredentials(
                new AuthScope("localhost", 8098, "easervices-realm"),
                new UsernamePasswordCredentials("adminportal",
                        "thepassword"));
        httpClient.getParams().setAuthenticationPreemptive(true);
        httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
                Collections.singleton(AuthPolicy.BASIC));
        final PostMethod meth = new PostMethod("http://localhost:8098/horizon"
                + url);
        meth.setDoAuthentication(true);
        meth.setRequestEntity(new StringRequestEntity(xml, "text/xml",
                "ISO-8859-1"));
        // meth.addRequestHeader("Content-Type", "text/xml");

        httpClient.executeMethod(meth);