Java 煤层2.0至2.1(2.2)迁移

Java 煤层2.0至2.1(2.2)迁移,java,jboss,migration,seam,Java,Jboss,Migration,Seam,我很好奇,在将我的应用程序从seam 2.0迁移到2.1时,您遇到了什么样的障碍 在中提到了一些显而易见的问题,但我遇到了一些基于规则的安全性问题,这些问题在中没有提到 首先,我想发布关于我的问题和迁移解决方案的描述,这样人们可以从中受益(我在网络上没有找到任何解决方案)——我将发布它作为一个答案:) 第二,我想问您在迁移时遇到了什么问题,以及您是如何解决的,因此它在web中处于一个位置。我的主要问题是基于规则的安全性。从seam 2.0到2.2,安全子系统有主要的耐火材料 无RuleBased

我很好奇,在将我的应用程序从seam 2.0迁移到2.1时,您遇到了什么样的障碍

在中提到了一些显而易见的问题,但我遇到了一些基于规则的安全性问题,这些问题在中没有提到

首先,我想发布关于我的问题和迁移解决方案的描述,这样人们可以从中受益(我在网络上没有找到任何解决方案)——我将发布它作为一个答案:)


第二,我想问您在迁移时遇到了什么问题,以及您是如何解决的,因此它在web中处于一个位置。

我的主要问题是基于规则的安全性。从seam 2.0到2.2,安全子系统有主要的耐火材料

RuleBasedIdentity
RuleBasedIdentity
RuleBasedPermissionResolver
替换

引用迁移指南:

  If you are using rule-based security in your project, the configuration for the 
  security rules in components.xml has changed.  Previously, the rules were configured
  as a property of the Identity component as such:

    <security:identity security-rules="#{securityRules}" authenticate-method="#{authenticator.authenticate}"/>

  In Seam 2.1, rule-based permission checks are now carried out by the RuleBasedPermissionResolver,
  requiring that it is configured with the security rules instead of Identity:

    <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
与:

c : PermissionCheck( target == 'fooHome' , action == "edit", granted == false )
此外,如果使用regexp:

c : PermissionCheck( name matches "\w*List")
需要替换为:

c : PermissionCheck( target.toString matches "\w*List")
标识的不同处理。hasPermission
它具有以下签名
Identity.hasPermissio(字符串名称、字符串操作、对象…参数)

在2.1之前的
hasPermission
创建了名为
PermissionCheck
PermissionCheck,以及从调用参数获取的操作属性,并将所有参数添加到drools上下文中

因此,以下调用
Identity.hasPermission(“fooHome”、“edit”、fooInstance)
将导致权限检查,该检查符合以下规则:

rule foo
    when
    c : PermissionCheck( name == "fooHome", action == "edit")
    f : Foo()
    then
    ...
end
现在
hasPermission
的工作原理如下:

 public boolean hasPermission(String name, String action, Object...arg)
     {      
        if (!securityEnabled) return true;
        if (systemOp != null && Boolean.TRUE.equals(systemOp.get())) return true;   
        if (permissionMapper == null) return false;

        if (arg != null)
        {
      return permissionMapper.resolvePermission(arg[0], action);
        }
        else
        {
      return permissionMapper.resolvePermission(name, action);
        }
     }
因此,如果传递了参数,name将根本无法访问
PermissionCheck
。你需要重写这样的规则:

rule foo
  when
  f : Foo()
  c : PermissionCheck( target = f, action == "edit")

  then
   ...
end

如前所述,安全处理已更改(请参阅Seam发行版中的migration.txt)

此外,构建架构已经发生了巨大的变化。如果使用生成的build.xml,则应重新生成它并手动重做所做的更改。其他一些与构建相关的工件也是如此,一些文件现在依赖于概要文件,可部署的lib在deployed jars ear/war.list中指定。最简单的方法是在两个生成的项目之间进行合并,这种方法的更改非常明显


除了这两个,我从2.0升级到2.2没有任何问题。

我只是使用seam gen创建了一个新项目,然后复制了所有源文件,并合并了其余文件。
rule foo
  when
  f : Foo()
  c : PermissionCheck( target = f, action == "edit")

  then
   ...
end