如何在war层中实现Picketlink Authenticator

时间:2014-05-13 13:18:34

标签: jboss jboss7.x wildfly

正如标题所说,我在war层中创建了一个用@Picketlink注释的类。请注意,我有一个耳朵部署结构(ejb,war)。

自定义身份验证器:

@PicketLink
public class PicketlinkAuthenticator extends BaseAuthenticator { }

如果我把那个类放在ejb层中,那么认证是可以的,但是当我把它放到war层时,它似乎没有被项目找到,因为它正在抛出:

20:49:46,027 INFO  [org.picketlink.common] (default task-10) Using logger implementation: org.picketlink.common.DefaultPicketLinkLogger
20:49:46,043 INFO  [org.picketlink.idm] (default task-10) PLIDM001000: Bootstrapping PicketLink Identity Manager
20:49:46,068 WARN  [org.picketlink.idm] (default task-10) PLIDM001101: Working directory [\tmp\pl-idm] is marked to be always created. All your existing data will be lost.
20:49:46,111 INFO  [org.picketlink.idm] (default task-10) PLIDM001100: Using working directory [\tmp\pl-idm].
20:49:46,127 DEBUG [org.picketlink.idm] (default task-10) No partitions to load from \tmp\pl-idm\pl-idm-partitions.db
20:49:46,152 DEBUG [org.picketlink.idm] (default task-10) Initializing Partition [6a373282-0173-4b7d-bd6a-ff0e5dc43436] with id [6a373282-0173-4b7d-bd6a-ff0e5dc43436].
20:49:46,153 DEBUG [org.picketlink.idm] (default task-10) Loaded Agents for Partition [6a373282-0173-4b7d-bd6a-ff0e5dc43436].
20:49:46,154 DEBUG [org.picketlink.idm] (default task-10) Loaded Credentials for Partition [6a373282-0173-4b7d-bd6a-ff0e5dc43436].

为什么不将验证者移到ejb端? - >因为我投掷了用户过期等自定义错误,我需要jsf发布这些错误消息。

为什么不在网络层中移动picketlink依赖关系? - >因为我的帐户扩展了picketlink帐户绑定到我的服务。

正如我在此建议的那样,我已经在war项目中添加了picketlink模块: https://docs.jboss.org/author/display/PLINK/JBoss+Modules

<jboss-deployment-structure>
  <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
  <sub-deployment name="THE-WAR-MODULE-THAT-REQUIRES-PICKETLINK.war">
    <dependencies>
      <module name="org.picketlink" />
    </dependencies>
  </sub-deployment>
</jboss-deployment-structure>

无论如何?我只是想显示一些自定义错误: - (

2 个答案:

答案 0 :(得分:0)

我无法解决这个问题,但我有一个解决方法,那就是将picketlink模块移动到Web层,然后将身份实例传递给需要它的服务。

答案 1 :(得分:0)

我现在已经错过了同样的问题一段时间了(现在是2016年......)。似乎使它工作的是添加以下CDI注释:

@PicketLink
@Name
@RequestScoped
public class PicketlinkAuthenticator extends BaseAuthenticator { }

我原本希望核心身份验证管理器只根据@PicketLink注释来选择它,但如果没有CDI注释,自定义Authenticator类永远不会被加载。也许有另一种方式需要我们引导PicketLink - 但我找不到任何参考。