From do-not-reply at jboss.org Fri Jun 11 06:02:19 2010 Content-Type: multipart/mixed; boundary="===============0640820646760631731==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: exo-jcr-commits at lists.jboss.org Subject: [exo-jcr-commits] exo-jcr SVN: r2552 - kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure. Date: Fri, 11 Jun 2010 06:02:19 -0400 Message-ID: <201006111002.o5BA2JQD000990@svn01.web.mwc.hst.phx2.redhat.com> --===============0640820646760631731== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: natasha.vakulenko Date: 2010-06-11 06:02:18 -0400 (Fri, 11 Jun 2010) New Revision: 2552 Added: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecureList.java kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecureSet.java Removed: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecureCollectionsList.java kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecureCollectionsSet.java kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecutiryManager.java Log: EXOJCR-770: renamed classes TestSecureCollectionList -> TestSecureList and = TestSecureCollectionSet -> TestSecureSet. Removed unnecessary class TestSec= urityManager. Deleted: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/comm= ons/utils/secure/TestSecureCollectionsList.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureCollectionsList.java 2010-06-11 09:49:45 UTC (rev 255= 1) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureCollectionsList.java 2010-06-11 10:02:18 UTC (rev 255= 2) @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2003-2010 eXo Platform SAS. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see. - */ -package org.exoplatform.commons.utils.secure; - -import java.security.Permission; -import java.security.PrivilegedExceptionAction; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.ListIterator; - -/** - * @author Natasha Vakule= nko - * @version $Revision$ - */ - -public class TestSecureCollectionsList extends AbstractSecureCollectionsTe= st -{ - private List list =3D SecureCollections.secureList(new ArrayLis= t(), MODIFY_PERMISSION); - - /** - * establishment of protected list prior to each test = - */ - protected void setUp() - { - list =3D SecureCollections.secureList(new ArrayList(), MODIF= Y_PERMISSION); - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - list.add("firstString"); - list.add("secondString"); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - } - } - - /** - * cleaning protected list after each test - */ - - protected void tearDown() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - list.clear(); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - } - } - - public void testSecureListAddDenied() - { - try - { - // giving no permissions - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - list.add("string"); - return null; - } - }); - fail("Modification should be denied."); - } - catch (Exception e) - { - } - } - - public void testSecureListAddPermitted() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - list.add(0, "string"); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - fail("Modification should be permitted."); - } - } - - public void testSecureListClearDenied() - { - try - { - // giving no permissions - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - list.clear(); - return null; - } - }); - fail("Modification should be denied."); - } - catch (Exception e) - { - } - } - - public void testSecureListIteratorPermitted() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - ListIterator it =3D list.listIterator(); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - fail("Modification should be permitted."); - } - } - - public void testSecureListRemoveDenied() - { - try - { - // giving no permissions - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - list.remove(0); - return null; - } - }); - fail("Modification should be denied."); - } - catch (Exception e) - { - } - } - - public void testSecureIteratorPermitted() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - Iterator it =3D list.iterator(); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - fail("Modification should be permitted."); - } - } -} Deleted: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/comm= ons/utils/secure/TestSecureCollectionsSet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureCollectionsSet.java 2010-06-11 09:49:45 UTC (rev 2551) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureCollectionsSet.java 2010-06-11 10:02:18 UTC (rev 2552) @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2003-2010 eXo Platform SAS. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see. - */ -package org.exoplatform.commons.utils.secure; - -import java.security.Permissions; -import java.security.PrivilegedExceptionAction; -import java.util.HashSet; -import java.util.Set; -import java.util.Iterator; - -/** - * @author Natasha Vakule= nko - * @version $Revision$ - */ - -public class TestSecureCollectionsSet extends AbstractSecureCollectionsTest -{ - private Set set; - - /** - * establishment of protected set prior to each test = - */ - protected void setUp() - { - set =3D SecureCollections.secureSet(new HashSet(), MODIFY_PE= RMISSION); - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.add("firstString"); - set.add("secondString"); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - } - } - - /** - * cleaning protected set after each test - */ - protected void tearDown() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.clear(); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - } - } - - public void testSecureSetAddPermitted() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.add("string"); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - fail("Modification should be permitted."); - } - } - - public void testSecureSetAddDenied() - { - try - { - // giving no permissions - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.add("string"); - return null; - } - }); - fail("Modification should be denied."); - } - catch (Exception e) - { - } - } - - public void testSecureSetRemoveDenied() - { - try - { - // giving no permissions - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.remove(0); - return null; - } - }); - fail("Modification should be denied."); - } - catch (Exception e) - { - } - } - - public void testSecureSetRemovePermitted() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.remove(0); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - fail("Modification should be permitted."); - } - } - - public void testSecureSetIteratorPermitted() - { - try - { - // giving MODIFY_PERMISSION - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - Iterator iterator =3D set.iterator(); - return null; - } - }, MODIFY_PERMISSION); - } - catch (Exception e) - { - fail("Modification should be permitted."); - } - } - - public void testSecureSetClearDenied() - { - try - { - // giving no permissions - doActionWithPermissions(new PrivilegedExceptionAction() - { - public Object run() throws Exception - { - set.clear(); - return null; - } - }); - fail("Modification should be denied."); - } - catch (Exception e) - { - } - } -} Added: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/common= s/utils/secure/TestSecureList.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureList.java (rev 0) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureList.java 2010-06-11 10:02:18 UTC (rev 2552) @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2003-2010 eXo Platform SAS. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see. + */ +package org.exoplatform.commons.utils.secure; + +import java.security.Permission; +import java.security.PrivilegedExceptionAction; +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.ListIterator; + +/** + * @author Natasha Vakule= nko + * @version $Revision$ + */ + +public class TestSecureList extends AbstractSecureCollectionsTest +{ + private List list; + + @Override + protected void setUp() + { + // establishment of protected set prior to each test = + list =3D SecureCollections.secureList(new ArrayList(), MODIF= Y_PERMISSION); + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + list.add("firstString"); + list.add("secondString"); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + } + } + + @Override + protected void tearDown() + { + // cleaning protected list after each test + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + list.clear(); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + } + } + + public void testSecureListAddDenied() + { + try + { + // giving no permissions + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + list.add("string"); + return null; + } + }); + fail("Modification should be denied."); + } + catch (Exception e) + { + } + } + + public void testSecureListAddPermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + list.add(0, "string"); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } + + public void testSecureListClearDenied() + { + try + { + // giving no permissions + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + list.clear(); + return null; + } + }); + fail("Modification should be denied."); + } + catch (Exception e) + { + } + } + + public void testSecureListIteratorRemovePermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + ListIterator iterator =3D list.listIterator(); + iterator.next(); + iterator.remove(); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } + + public void testSecureListRemoveDenied() + { + try + { + // giving no permissions + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + list.remove(0); + return null; + } + }); + fail("Modification should be denied."); + } + catch (Exception e) + { + } + } + + public void testSecureIteratorPermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + Iterator it =3D list.iterator(); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } +} Property changes on: kernel/trunk/exo.kernel.commons/src/test/java/org/exop= latform/commons/utils/secure/TestSecureList.java ___________________________________________________________________ Name: svn:eol-style + native Added: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/common= s/utils/secure/TestSecureSet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureSet.java (rev 0) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureSet.java 2010-06-11 10:02:18 UTC (rev 2552) @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2003-2010 eXo Platform SAS. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see. + */ +package org.exoplatform.commons.utils.secure; + +import java.security.Permissions; +import java.security.PrivilegedExceptionAction; +import java.util.HashSet; +import java.util.Set; +import java.util.Iterator; + +/** + * @author Natasha Vakule= nko + * @version $Revision$ + */ + +public class TestSecureSet extends AbstractSecureCollectionsTest +{ + private Set set; + + @Override + protected void setUp() + { + // establishment of protected set prior to each test = + set =3D SecureCollections.secureSet(new HashSet(), MODIFY_PE= RMISSION); + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.add("firstString"); + set.add("secondString"); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + } + } + + @Override + protected void tearDown() + { + // cleaning protected set after each test + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.clear(); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + } + } + + public void testSecureSetAddPermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.add("string"); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } + + public void testSecureSetAddDenied() + { + try + { + // giving no permissions + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.add("string"); + return null; + } + }); + fail("Modification should be denied."); + } + catch (Exception e) + { + } + } + + public void testSecureSetRemoveDenied() + { + try + { + // giving no permissions + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.remove(0); + return null; + } + }); + fail("Modification should be denied."); + } + catch (Exception e) + { + } + } + + public void testSecureSetRemovePermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.remove(0); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } + + public void testSecureSetIteratorPermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + Iterator iterator =3D set.iterator(); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } + + public void testSecureSetIteratorRemovePermitted() + { + try + { + // giving MODIFY_PERMISSION + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + Iterator iterator =3D set.iterator(); + iterator.next(); + iterator.remove(); + return null; + } + }, MODIFY_PERMISSION); + } + catch (Exception e) + { + fail("Modification should be permitted."); + } + } + + public void testSecureSetClearDenied() + { + try + { + // giving no permissions + doActionWithPermissions(new PrivilegedExceptionAction() + { + public Object run() throws Exception + { + set.clear(); + return null; + } + }); + fail("Modification should be denied."); + } + catch (Exception e) + { + } + } +} Property changes on: kernel/trunk/exo.kernel.commons/src/test/java/org/exop= latform/commons/utils/secure/TestSecureSet.java ___________________________________________________________________ Name: svn:eol-style + native Deleted: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/comm= ons/utils/secure/TestSecutiryManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecutiryManager.java 2010-06-11 09:49:45 UTC (rev 2551) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecutiryManager.java 2010-06-11 10:02:18 UTC (rev 2552) @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2003-2010 eXo Platform SAS. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see. - */ -package org.exoplatform.commons.utils.secure; - -import junit.framework.TestCase; - -/** - * @author Nikolay Zamosenchuk - * @version $Id: TestSecureSet.java 34360 2009-07-22 23:58:59Z nzamosenchu= k $ - */ - -public class TestSecutiryManager extends TestCase -{ - - public void testSecurityManagerExists() - { - // check if SM is installed - assertNotNull("Security Manager is not installed", System.getSecurit= yManager()); - } -} --===============0640820646760631731==--