My main problems were with rule based security. From seam 2.0 to 2.2 there were major refractorings to security subsystem.
No RuleBasedIdentity
RuleBasedIdentity
was replaced by RuleBasedPermissionResolver
.
Quoting from migration guide:
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}"/>
Additionally if you youd app needs to work with RuleBasedIdentity
(for example to give additional facts to security context) you need to use RuleBasedPermissionResolver.instance()
instead.
No name parameter in PermissionCheck
Name parameter was replaced by target parameter, that is an Object
not String
.
So in your rules you have to replace:
c : PermissionCheck( name == 'fooHome' , action == "edit", granted == false )
with:
c : PermissionCheck( target == 'fooHome' , action == "edit", granted == false )
Also if you use regexps:
c : PermissionCheck( name matches "\w*List")
needs to be replaced with:
c : PermissionCheck( target.toString matches "\w*List")
Different handling of Identity.hasPermission
It has following signature Identity.hasPermissio(String name, String action, Object... args)
Prior to 2.1 hasPermission
created PermissionCheck with name
, and action properties taken from invocation parameters, and it added all args to drools context.
So following invocation Identity.hasPermission("fooHome", "edit", fooInstance)
would result in permission check that is matched by following rule:
rule foo
when
c : PermissionCheck( name == "fooHome", action == "edit")
f : Foo()
then
...
end
Now hasPermission
works like that:
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);
}
}
so if there are args passed, name will not get to PermissionCheck
at all. And you need rewrite rules like that:
rule foo
when
f : Foo()
c : PermissionCheck( target = f, action == "edit")
then
...
end
enter code here