【问题标题】:Configure JAAS in embedded Jetty with CXF and Spring使用 CXF 和 Spring 在嵌入式 Jetty 中配置 JAAS
【发布时间】:2014-01-17 16:43:21
【问题描述】:

我正在尝试设置一个 CXF + Spring + 嵌入式码头,它具有依赖于 JAAS 的基本身份验证,但我在连接所有部分时遇到了问题。

我想使用看起来很容易配置的 CXF JAASLoginInterceptor,所以我在 ApplicationContext 中的服务定义看起来像

<jaxws:endpoint address="/soapService">
    <jaxrs:serviceBeans>
        <ref bean="serviceImpl" />
    </jaxrs:serviceBeans>
    <jaxws:inInterceptors>
        <ref bean="authenticationInterceptor"/>
    </jaxws:inInterceptors>
</jaxws:endpoint>

<bean id="authenticationInterceptor" class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
   <property name="contextName" value="jaasContext"/>
   <property name="roleClassifier" value="ROLE_"/>
</bean>

正如文档所述:“JAAS 身份验证器配置有 JAAS 登录上下文的名称(通常在服务器知道的 JAAS 配置资源中指定的名称)”

如何以最基本的方式设置“JAAS 配置资源”?

谢谢!

【问题讨论】:

    标签: java spring rest cxf jaas


    【解决方案1】:

    最后很容易做到。您唯一需要的是在类路径中放置一个包含登录模块配置的文件,并将系统属性“java.security.auth.login.config”设置为指向该文件。

    例如启用基于属性文件的身份验证的文件:

    jaasContext {
    org.eclipse.jetty.plus.jaas.spi.PropertyFileLoginModule 可选 文件="src/main/resources/credentials.props"; };

    请注意,CXF 拦截器中的 contextName 与 jaas 配置文件中的相同。

    【讨论】:

      猜你喜欢
      • 2011-10-02
      • 1970-01-01
      • 2014-12-07
      • 2016-12-21
      • 2011-08-20
      • 2013-11-01
      • 2018-11-22
      • 2013-05-22
      • 2017-07-05
      相关资源
      最近更新 更多