Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 78273 invoked from network); 12 Jan 2009 03:31:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Jan 2009 03:31:23 -0000 Received: (qmail 59441 invoked by uid 500); 12 Jan 2009 03:31:23 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 59420 invoked by uid 500); 12 Jan 2009 03:31:23 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 59187 invoked by uid 99); 12 Jan 2009 03:31:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2009 19:31:22 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2009 03:31:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A345D234C498 for ; Sun, 11 Jan 2009 19:30:59 -0800 (PST) Message-ID: <1074479145.1231731059667.JavaMail.jira@brutus> Date: Sun, 11 Jan 2009 19:30:59 -0800 (PST) From: "Sean Qiu (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6021) [java6][classlib][security] Policy getPermissions(ProtectionDomain) may return different type of PermissionCollection from RI In-Reply-To: <1371509995.1226978984341.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-6021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12662867#action_12662867 ] Sean Qiu commented on HARMONY-6021: ----------------------------------- If no one objects, I'll apply this patch. > [java6][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 > > Attachments: HARMONY-6021.diff > > Original Estimate: 72h > Remaining Estimate: 72h > > --------- > Test > --------- > 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 permissions = new Vector(); > @Override > public void add(Permission permission) { > if(this.isReadOnly()){ throw new java.lang.SecurityException(); } > if(permission instanceof MockPermission){ permissions.add(permission); } > } > @Override > public Enumeration elements() { return permissions.elements(); } > @Override > 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(); > readPC.add(read); > 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); > assertTrue(permissions.implies(read)); > assertFalse(permissions.implies(write)); > } > ---------------- > Description > ---------------- > 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.