亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? testchacc.java

?? cms是開源的框架
?? JAVA
字號:
/*
 * File   : $Source: /usr/local/cvs/opencms/test/org/opencms/file/TestChacc.java,v $
 * Date   : $Date: 2005/06/27 23:22:09 $
 * Version: $Revision: 1.15 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
package org.opencms.file;

import org.opencms.main.CmsException;
import org.opencms.security.CmsAccessControlEntry;
import org.opencms.security.CmsPermissionSet;
import org.opencms.security.I_CmsPrincipal;
import org.opencms.test.OpenCmsTestCase;
import org.opencms.test.OpenCmsTestProperties;
import org.opencms.test.OpenCmsTestResourceFilter;

import java.util.Iterator;
import java.util.List;

import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * Unit test for the "chacc" method of the CmsObject.<p>
 * 
 * @author Michael Emmerich 
 * @version $Revision: 1.15 $
 */
public class TestChacc extends OpenCmsTestCase {
  
    /**
     * Default JUnit constructor.<p>
     * 
     * @param arg0 JUnit parameters
     */    
    public TestChacc(String arg0) {
        super(arg0);
    }
    
    /**
     * Test suite for this test class.<p>
     * 
     * @return the test suite
     */
    public static Test suite() {
        OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH);
        
        TestSuite suite = new TestSuite();
        suite.setName(TestChacc.class.getName());
                
        suite.addTest(new TestChacc("testChaccFileGroup"));
        suite.addTest(new TestChacc("testChaccFileUser"));
        suite.addTest(new TestChacc("testChaccAddRemove"));
               
        TestSetup wrapper = new TestSetup(suite) {
            
            protected void setUp() {
                setupOpenCms("simpletest", "/sites/default/");
            }
            
            protected void tearDown() {
                removeOpenCms();
            }
        };
        
        return wrapper;
    }     
    
    /**
     * Test the chacc method on a file and a group.<p>
     * 
     * @param tc the OpenCmsTestCase
     * @param cms the CmsObject
     * @param resource1 the resource to change permissions
     * @param group the group to change the permissions from
     * @param permissions the new permission set for this group
     * @param flags the flags for modifying the permission set
     * @throws Throwable if something goes wrong
     */
    public static void chaccFileGroup(OpenCmsTestCase tc, CmsObject cms, String resource1, CmsGroup group, CmsPermissionSet permissions, int flags) throws Throwable {            
       
        tc.storeResources(cms, resource1);
                
        cms.lockResource(resource1);
        cms.chacc(resource1, I_CmsPrincipal.PRINCIPAL_GROUP, group.getName(), permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), flags);
        cms.unlockResource(resource1);
        
        // now evaluate the result
        tc.assertFilter(cms, resource1, OpenCmsTestResourceFilter.FILTER_CHACC);
        // test the ace of the new permission
        // add the group flag to the acl
        CmsResource res = cms.readResource(resource1, CmsResourceFilter.ALL);
 
        CmsAccessControlEntry ace = 
               new CmsAccessControlEntry(res.getResourceId(), group.getId(), 
                   permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), 
                   flags + CmsAccessControlEntry.ACCESS_FLAGS_GROUP);      
        tc.assertAce(cms, resource1, ace);
         // test the acl with the permission set        
         int denied = permissions.getDeniedPermissions();
         if (flags == CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE) {
            denied = 0;
         }
        CmsPermissionSet permission = new CmsPermissionSet(permissions.getAllowedPermissions(), denied);
        tc.assertAcl(cms, resource1, group.getId(), permission);
    }
    
    /**
     * Test the chacc method on a file and a group.<p>
     * 
     * @param tc the OpenCmsTestCase
     * @param cms the CmsObject
     * @param resource1 the resource to change permissions
     * @param group the group to change the permissions from
     * @param permissions the new permission set for this group
     * @param flags the flags for modifying the permission set
     * @throws Throwable if something goes wrong
     */
    public static void chaccFolderGroup(OpenCmsTestCase tc, CmsObject cms, String resource1, CmsGroup group, CmsPermissionSet permissions, int flags) throws Throwable {            
       
        tc.storeResources(cms, resource1);
                
        cms.lockResource(resource1);
        cms.chacc(resource1, I_CmsPrincipal.PRINCIPAL_GROUP, group.getName(), permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), flags);
        cms.unlockResource(resource1);

        // now evaluate the result
        tc.assertFilter(cms, resource1, OpenCmsTestResourceFilter.FILTER_CHACC);
        // test the ace of the new permission
        // add the group flag to the acl
        CmsResource res = cms.readResource(resource1, CmsResourceFilter.ALL);
 
        CmsAccessControlEntry ace = 
               new CmsAccessControlEntry(res.getResourceId(), group.getId(), 
                   permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), 
                   flags + CmsAccessControlEntry.ACCESS_FLAGS_GROUP);      
        tc.assertAce(cms, resource1, ace);
         // test the acl with the permission set        
         int denied = permissions.getDeniedPermissions();
         if ((flags & CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE) > 0) {
            denied = 0;
         }
        CmsPermissionSet permission = new CmsPermissionSet(permissions.getAllowedPermissions(), denied);
        tc.assertAcl(cms, resource1, group.getId(), permission);
        
        // now check all the subresources in the folder, access must be modified as well
        List subresources = tc.getSubtree(cms, resource1);
        Iterator j = subresources.iterator();
        
        while (j.hasNext()) {
            CmsResource subRes = (CmsResource)j.next();
            String subResName = cms.getSitePath(subRes);
            // now evaluate the result
            tc.assertFilter(cms, subResName, OpenCmsTestResourceFilter.FILTER_CHACC);
            // test the ace of the new permission
            // add the group and the inherited flag to the acl
            ace = new CmsAccessControlEntry(res.getResourceId(), group.getId(), 
                      permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), 
                      flags + CmsAccessControlEntry.ACCESS_FLAGS_GROUP + CmsAccessControlEntry.ACCESS_FLAGS_INHERITED); 
            tc.assertAce(cms, subResName, ace);
            
            // test the acl with the permission set     
           permission = new CmsPermissionSet(permissions.getAllowedPermissions(), denied);  
           tc.assertAcl(cms, resource1, subResName, group.getId(), permission);
            
        }  
    }

    /**
     * Test the chacc method on a file and a user.<p>
     * 
     * @param tc the OpenCmsTestCase
     * @param cms the CmsObject
     * @param resource1 the resource to change permissions
     * @param user the user to change the permissions from
     * @param permissions the new permission set for this group
     * @param flags the flags for modifying the permission set
     * @throws Throwable if something goes wrong
     */
    public static void chaccFileUser(OpenCmsTestCase tc, CmsObject cms, String resource1, CmsUser user, CmsPermissionSet permissions, int flags) throws Throwable {            
       
        tc.storeResources(cms, resource1);
                
        cms.lockResource(resource1);
        cms.chacc(resource1, I_CmsPrincipal.PRINCIPAL_USER, user.getName(), permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), flags);
        cms.unlockResource(resource1);

        // now evaluate the result
        tc.assertFilter(cms, resource1, OpenCmsTestResourceFilter.FILTER_CHACC);
        // test the ace of the new permission
        // add the user flag to the acl
        CmsResource res = cms.readResource(resource1, CmsResourceFilter.ALL);
 
        CmsAccessControlEntry ace = 
               new CmsAccessControlEntry(res.getResourceId(), user.getId(), 
                   permissions.getAllowedPermissions(), permissions.getDeniedPermissions(), 
                   flags + CmsAccessControlEntry.ACCESS_FLAGS_USER);      
        tc.assertAce(cms, resource1, ace);
         // test the acl with the permission set
         int denied = permissions.getDeniedPermissions();
         if (flags == CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE) {
            denied = 0;
         }
        CmsPermissionSet permission = new CmsPermissionSet(permissions.getAllowedPermissions(), denied);
        tc.assertAcl(cms, resource1, user.getId(), permission);
    }
    
    /**
     * Test the chacc method on a file and a group.<p>
     * 
     * @throws Throwable if something goes wrong
     */
    public void testChaccFileGroup() throws Throwable {

        CmsObject cms = getCmsObject();     
        echo("Testing chacc on a file and a group");
        chaccFileGroup(this, cms, "/index.html", cms.readGroup("Users"), CmsPermissionSet.ACCESS_READ, CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE);   
    }  
    
    /**
     * Test the chacc method on a file and a user.<p>
     * 
     * @throws Throwable if something goes wrong
     */
    public void testChaccFileUser() throws Throwable {

        CmsObject cms = getCmsObject();     
        echo("Testing chacc on a file and a user");
        chaccFileUser(this, cms, "/folder1/index.html", cms.readUser("Guest"), CmsPermissionSet.ACCESS_WRITE, 0);   
    }  
    
    /**
     * Test the chacc method on a folder and a group.<p>
     * 
     * @throws Throwable if something goes wrong
     */
    public void testChaccFolderGroup() throws Throwable {
        //TODO: This test is not working correctly so far!
        CmsObject cms = getCmsObject();     
        echo("Testing chacc on a folder and a group");
        chaccFolderGroup(this, cms, "/folder2/", cms.readGroup("Guests"), CmsPermissionSet.ACCESS_READ, CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE + CmsAccessControlEntry.ACCESS_FLAGS_INHERIT);   
    }
    
    /**
     * Test the creation and deletion of access control entries and checks permissions of a test user.<p>
     *  
     * @throws Throwable if something goes wrong
     */
    public void testChaccAddRemove() throws Throwable {
        
        echo("Testing adding and removing ACEs on files and folders");
        
        CmsObject cms = getCmsObject();
        cms.createGroup("Testgroup", "A test group", 0, null);
        CmsGroup testGroup = cms.readGroup("Testgroup");
        cms.createUser("testuser", "test", "A test user", null);
        cms.addUserToGroup("testuser", "Testgroup");
        CmsUser testUser = cms.readUser("testuser");
        
        CmsProject offline = cms.readProject("Offline");
        
        String resName = "/folder2/";
        
        cms.lockResource(resName);
        cms.chacc(resName, I_CmsPrincipal.PRINCIPAL_USER, testUser.getName(), "+r+w+v+i");
        cms.chacc(resName, I_CmsPrincipal.PRINCIPAL_GROUP, testGroup.getName(), "+r+v+i");
        cms.unlockResource(resName);
        cms.publishProject(); 
        
        CmsPermissionSet permissions = new CmsPermissionSet(CmsPermissionSet.PERMISSION_READ
            | CmsPermissionSet.PERMISSION_VIEW
            | CmsPermissionSet.PERMISSION_WRITE, 0);
        
        
        // check set permissions for the test user
        cms.loginUser("testuser", "test");
        cms.getRequestContext().setCurrentProject(offline);
        cms.lockResource(resName);
        assertTrue(cms.hasPermissions(cms.readResource(resName), permissions));
        assertTrue(cms.hasPermissions(cms.readResource("/folder2/index.html"), permissions));
        boolean success = false;
        try {
            assertFalse(cms.hasPermissions(cms.readResource("/folder1/"), permissions));
        } catch (CmsException e) {
            success = true;
        }
        if (! success) {
            throw new Exception("Test user has permissions +r+v+w set on /folder1/"); 
        }
        cms.unlockResource(resName);
        
        // switch back to Admin user and remove ACE
        cms.loginUser("Admin", "admin");       
        cms.getRequestContext().setCurrentProject(offline);
        cms.lockResource(resName);
        cms.rmacc(resName, I_CmsPrincipal.PRINCIPAL_USER, testUser.getName());
        cms.unlockResource(resName);
        cms.publishProject();         
        
        cms.loginUser("testuser", "test");        
        cms.getRequestContext().setCurrentProject(offline);
        assertFalse(cms.hasPermissions(cms.readResource(resName), CmsPermissionSet.ACCESS_WRITE));
        
        cms.loginUser("Admin", "admin");       
        cms.getRequestContext().setCurrentProject(offline);
        cms.lockResource(resName);
        cms.rmacc(resName, I_CmsPrincipal.PRINCIPAL_GROUP, testGroup.getName());
        cms.unlockResource(resName);
        cms.publishProject();
        
        // re-check permissions of test user after removing ACE
        cms.loginUser("testuser", "test");     
        success = false;
        try {
            assertFalse(cms.hasPermissions(cms.readResource(resName), permissions));
        }  catch (CmsException e) {
            success = true;
        }
        if (! success) {
            throw new Exception("Test user has permissions +r+v set on /folder2/ after removal of ACE"); 
        }
    }    
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品欧美极品| 国产高清成人在线| 福利一区在线观看| 欧美精品高清视频| 国产精品嫩草久久久久| 亚洲h精品动漫在线观看| 波多野结衣精品在线| 日韩亚洲欧美成人一区| 亚洲一区中文日韩| 99精品视频一区二区| xnxx国产精品| 免费高清不卡av| 7777女厕盗摄久久久| 亚洲人精品午夜| 95精品视频在线| 日本一区二区不卡视频| 国产一区激情在线| 欧美va在线播放| 蜜臀精品久久久久久蜜臀| 欧美在线免费观看亚洲| 国产精品久久久久久久久图文区| 国产一区二区三区在线观看精品| 欧美一二三四区在线| 日本不卡一二三| 91精品国产91久久久久久一区二区| 亚洲精品日韩一| 日本高清不卡视频| 亚洲综合视频网| 欧美日韩一区二区三区四区| 一区二区高清视频在线观看| 91久久精品一区二区| 一区二区三区不卡视频在线观看 | 9色porny自拍视频一区二区| 国产午夜精品福利| 国产成人av一区二区三区在线 | 日本一区二区免费在线观看视频 | 成人久久视频在线观看| 国产三区在线成人av| 懂色av中文一区二区三区| 国产欧美一区二区精品婷婷 | 中文字幕高清不卡| caoporn国产精品| 亚洲男同性视频| 欧美三级电影精品| 丝袜美腿亚洲综合| 精品国产成人在线影院 | 国产精品久久久久久亚洲毛片| 国产69精品久久99不卡| 18欧美亚洲精品| 欧美在线一区二区三区| 日韩高清不卡一区| 久久久五月婷婷| 色香蕉成人二区免费| 午夜精品久久久| 久久综合色婷婷| 91亚洲精品久久久蜜桃网站| 香蕉成人啪国产精品视频综合网| 日韩三级在线免费观看| 国产成人精品三级| 一区av在线播放| 2023国产精品自拍| 99精品视频免费在线观看| 性欧美疯狂xxxxbbbb| 2022国产精品视频| 日本韩国一区二区| 久久福利资源站| 亚洲女同ⅹxx女同tv| 日韩亚洲欧美一区二区三区| 99久久免费国产| 粉嫩av一区二区三区| 一区二区三区四区视频精品免费 | 国产激情偷乱视频一区二区三区 | 国产精品色在线| 91麻豆精品国产综合久久久久久| 国产精品一级黄| 日韩高清欧美激情| 亚洲视频一二区| 久久久亚洲精品一区二区三区| 欧美手机在线视频| av亚洲精华国产精华精华| 日本不卡的三区四区五区| 亚洲欧美在线高清| 久久婷婷色综合| 在线不卡a资源高清| av亚洲精华国产精华精| 国模冰冰炮一区二区| 性做久久久久久免费观看欧美| 国产精品久久久久影院| 日韩欧美一区二区在线视频| 色婷婷av久久久久久久| 国产成人在线色| 麻豆高清免费国产一区| 五月婷婷久久综合| 伊人夜夜躁av伊人久久| 中文字幕一区二区在线播放| 2020国产精品| 日韩无一区二区| 欧美男生操女生| 欧美日韩在线观看一区二区| 91在线精品一区二区三区| 国产精品一区二区x88av| 精品在线一区二区| 久久99久久99小草精品免视看| 亚洲福利国产精品| 亚洲一二三四区| 亚洲与欧洲av电影| 亚洲猫色日本管| 亚洲蜜臀av乱码久久精品蜜桃| 久久精品在这里| 久久久久国产成人精品亚洲午夜| 欧美电影一区二区| 91精品国产入口| 欧美大胆人体bbbb| 欧美一级理论性理论a| 日韩一级视频免费观看在线| 欧美一区二区在线不卡| 91精品国产一区二区三区蜜臀| 欧美性大战久久| 91精品国模一区二区三区| 欧美日韩黄色一区二区| 7777精品伊人久久久大香线蕉的 | 国产一区二区三区久久久| 经典一区二区三区| 激情图片小说一区| 国产精品伊人色| 成人性生交大合| 91免费观看视频在线| 欧美亚一区二区| 91精品国产综合久久福利| 欧美精品一区二区久久婷婷| 久久久蜜桃精品| 综合久久一区二区三区| 亚洲国产毛片aaaaa无费看| 日本亚洲一区二区| 九九**精品视频免费播放| 91麻豆国产在线观看| 色噜噜狠狠色综合欧洲selulu| 欧美视频精品在线观看| 91精品免费在线| 欧美国产综合一区二区| 亚洲国产精品自拍| 韩国精品免费视频| 色成年激情久久综合| 欧美一区二区人人喊爽| 国产偷v国产偷v亚洲高清| 亚洲欧美日韩国产成人精品影院| 亚洲va天堂va国产va久| 狠狠色狠狠色综合| 在线观看一区二区精品视频| 精品久久久久久无| 亚洲精品成人a在线观看| 久久精品噜噜噜成人88aⅴ| 成人av综合在线| 欧美一级久久久| 亚洲欧美日韩国产手机在线 | 精品国产免费人成电影在线观看四季 | 国产在线播精品第三| 91麻豆国产精品久久| 欧美电影免费观看完整版 | 日本一区二区三区国色天香| 亚洲国产一区二区三区 | 亚洲色图第一区| 久久精品国产成人一区二区三区| 福利一区二区在线观看| 日韩免费在线观看| 亚洲一二三四在线观看| yourporn久久国产精品| 日韩午夜小视频| 亚洲第一激情av| 不卡一二三区首页| 亚洲精品一区二区三区福利 | 91.麻豆视频| 亚洲欧美一区二区三区极速播放| 久久福利视频一区二区| 欧美三级午夜理伦三级中视频| 中文字幕免费不卡| 黄色精品一二区| 91精品国产色综合久久ai换脸| 亚洲精选视频在线| 懂色av一区二区三区免费看| 欧美v国产在线一区二区三区| 亚洲一区二区成人在线观看| 99国产欧美另类久久久精品| 国产婷婷精品av在线| 久久成人免费网站| 日韩精品中文字幕一区二区三区 | 国产欧美一区二区精品性| 久久99精品久久久久久国产越南| 欧美少妇bbb| 亚洲午夜一二三区视频| av电影在线不卡| 国产精品久久久久影院| 成人综合婷婷国产精品久久 | 亚洲成人资源在线| 色激情天天射综合网| 亚洲天堂精品视频| 色综合久久综合网97色综合 | 亚洲欧洲精品天堂一级| 国产成人免费视频精品含羞草妖精| 精品对白一区国产伦|