harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6021) [classlib][security] Policy getPermissions(ProtectionDomain) may return different type of PermissionCollection from RI
Date Tue, 18 Nov 2008 03:29:44 GMT
[classlib][security] Policy getPermissions(ProtectionDomain) may return different type of PermissionCollection
from RI

                 Key: HARMONY-6021
                 URL: https://issues.apache.org/jira/browse/HARMONY-6021
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M8
            Reporter: Sean Qiu
            Assignee: Sean Qiu
             Fix For: 5.0M9

private static class MockPermission extends BasicPermission{

public MockPermission(String name) { super(name); }

public MockPermission(String name, String action) { super(name,action); }


static class MockPermissions extends PermissionCollection{
private Vector<Permission> permissions = new Vector();

public void add(Permission permission) {
if(this.isReadOnly()){ throw new java.lang.SecurityException(); }
if(permission instanceof MockPermission){ permissions.add(permission); }

public Enumeration<Permission> elements() { return permissions.elements(); }

public boolean implies(Permission permission) {
if(permissions.size()==0){ return false; }
if(permission instanceof MockPermission){
for(Permission perm : permissions){
if( perm.implies(permission)){ return true; }

return false;


public void testGetPermissions() throws Exception{ 
    MockPermission read = new MockPermission("read"); 
    MockPermission write = new MockPermission("write"); 
    PermissionCollection readPC = new MockPermissions(); 
    ProtectionDomain pd = new ProtectionDomain(null, null); 
    TestProvider policy = new TestProvider(); 
     policy.pc = readPC; 
     PermissionCollection permissions = policy.getPermissions(pd); 
     assertTrue(permissions instanceof MockPermissions); 
     assertSame(permissions, readPC); 

Harmony'll failed in this testcase since it returns a new Permissions instance rather than
use the customized PermissionCollection.
The new created Permissions have different implies contact which leads to the failures.
It doesn't make sense to create a new Permissions here, since customer may extension the default
permission and permission collection here.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message