Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1152477

Summary: Annotation @RolesAllowed doesn't work for generic types in EJBs
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Josef Cacek <jcacek>
Component: EJB, SecurityAssignee: Stuart Douglas <sdouglas>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Slavicek <pslavice>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3.2CC: bdawidow, david.lloyd, dehort, kkhan, okotek, sdouglas
Target Milestone: DR10   
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
RolesAllowed-reproducer.zip none

Description Josef Cacek 2014-10-14 08:58:45 UTC
Created attachment 946764 [details]
RolesAllowed-reproducer.zip

If generic types are used, the AuthorizationInterceptor is not correctly configured. The problem is the MethodPermissionsMergingProcessor adds permission based on the type parameter, but EJBSecurityViewConfigurator checks a base type for the parameter 

Example:

public class BaseObject {
...
}

public class TestItem extends BaseObject {
...
}

@Local
public interface TestInterface<T extends BaseObject> {
  public void testMethodWithArgs(T t) throws Exception;
}


@Stateless
@Local
@SecurityDomain("test")
public class TestImplementation implements TestInterface<TestItem> {

  @RolesAllowed("JBossAdmin")
  public void testMethodWithArgs(TestItem t) throws Exception {
	// whatever
  }
}

When deploying the TestImplementation bean, it does following:

1)
The MethodPermissionsMergingProcessor.handleAnnotations() method sets AnnotationMethodPermissions attribute for:

className: jboss.example.ejb.TestImplementation
methodName: testMethodWithArgs
methodParams: ["jboss.example.ejb.TestItem"]

2)
The org.jboss.as.ejb3.security.EJBSecurityViewConfigurator.handlePermissions() method reads permission for:

className: jboss.example.ejb.TestImplementation
methodName: testMethodWithArgs
methodParams: ["jboss.example.ejb.BaseObject"]


==================
Attaching also original reproducer from Derek Horton. Usage:
- configure a "jmx-console" security domain with a user in role "JBossAdmin"
- deploy the EAR
- go to http://localhost:8080/SimpleWar/Hello
- check log files

Comment 1 David M. Lloyd 2014-10-20 18:01:17 UTC
Looking at the code, I suspect this problem also exists in upstream?

Comment 4 Stuart Douglas 2014-11-10 01:30:00 UTC
I think this was fixed upstream by https://github.com/wildfly/wildfly/commit/233075c