当前位置: 首页>>代码示例>>C++>>正文


C++ CAccessControlListGroup::AddACL方法代码示例

本文整理汇总了C++中CAccessControlListGroup::AddACL方法的典型用法代码示例。如果您正苦于以下问题:C++ CAccessControlListGroup::AddACL方法的具体用法?C++ CAccessControlListGroup::AddACL怎么用?C++ CAccessControlListGroup::AddACL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAccessControlListGroup的用法示例。


在下文中一共展示了CAccessControlListGroup::AddACL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: aclGroupAddACL

int CLuaACLDefs::aclGroupAddACL ( lua_State* luaVM )
{
//  bool aclGroupAddACL ( aclgroup theGroup, acl theACL )
    CAccessControlListGroup* pGroup; CAccessControlList* pACL;
    
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pGroup );
    argStream.ReadUserData ( pACL );
    
    if ( !argStream.HasErrors () )
    {
        // Add the ACL to the group
        pGroup->AddACL ( pACL );
        CLogger::LogPrintf ( "ACL: %s: ACL '%s' added to group '%s'\n", GetResourceName ( luaVM ), pACL->GetName (), pGroup->GetGroupName () );
        // Return success
        lua_pushboolean ( luaVM, true );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:superherohay4,项目名称:mtasa-blue,代码行数:24,代码来源:CLuaACLDefs.cpp

示例2: Load

bool CAccessControlListManager::Load ( void )
{
    // Eventually destroy the previously loaded xml
    if ( m_pXML )
    {
        delete m_pXML;
    }

    // Load the XML
    m_pXML = g_pServerInterface->GetXML ()->CreateXML ( GetFileName ().c_str () );
    if ( !m_pXML )
    {
        CLogger::ErrorPrintf ( "Error loading Access Control List file\n" );
        return false;
    }

    // Parse it
    if ( !m_pXML->Parse () )
    {
        CLogger::ErrorPrintf ( "Error parsing Access Control List file\n" );
        return false;
    }

    // Grab the XML root node
    m_pRootNode = m_pXML->GetRootNode ();
    if ( !m_pRootNode )
    {
        CLogger::ErrorPrintf ( "Missing root node ('ACL')\n" );
        return false;
    }

    // Clear previous ACL stuff
    ClearACLs ();
    ClearGroups ();

    // load the acl's
    CXMLNode* pSubNode = NULL;
    unsigned int uiSubNodesCount = m_pRootNode->GetSubNodeCount ();
    for ( unsigned int i = 0 ; i < uiSubNodesCount ; i++ )
    {
        pSubNode = m_pRootNode->GetSubNode ( i );
        if ( !pSubNode ) continue;

        if ( pSubNode->GetTagName ().compare ( "acl" ) == 0 )
        {
            CXMLAttribute* pAttribute = pSubNode->GetAttributes ().Find ( "name" );
            if ( pAttribute )
            {
                CAccessControlList* pACL = AddACL ( pAttribute->GetValue ().c_str () );

                CXMLNode* pSubSubNode = NULL;
                unsigned int uiSubSubNodesCount = pSubNode->GetSubNodeCount ();
                for ( unsigned int j = 0 ; j < uiSubSubNodesCount ; j++ )
                {
                    // If this subnode doesn't exist, return to the for loop and continue it
                    pSubSubNode = pSubNode->GetSubNode ( j );
                    if ( !pSubSubNode ) continue;

                    // Check that this subsub node is named "right"
                    if ( pSubSubNode->GetTagName ().compare ( "right" ) == 0 )
                    {
                        // Grab the name and the access attributes
                        CXMLAttribute* pNameAttribute = pSubSubNode->GetAttributes ().Find ( "name" );
                        CXMLAttribute* pAccessAttribute = pSubSubNode->GetAttributes ().Find ( "access" );
                        if ( pNameAttribute && pAccessAttribute )
                        {
                            // See if the access attribute is true or false
                            bool bAccess = false;
                            std::string strAccess = pAccessAttribute->GetValue ();

                            if ( stricmp ( strAccess.c_str (), "true" ) == 0 ||
                                 stricmp ( strAccess.c_str (), "yes" ) == 0 ||
                                 strcmp ( strAccess.c_str (), "1" ) == 0 )
                            {
                                bAccess = true;
                            }

                            // Grab the name of the 'right' name
                            const char *szRightName = pNameAttribute->GetValue ().c_str ();

                            // Create the rights control list
                            CAccessControlListRight* pRight = NULL;
                            if ( StringBeginsWith ( szRightName, "command." ) )
                            {
                                pRight = pACL->AddRight ( &szRightName[8], CAccessControlListRight::RIGHT_TYPE_COMMAND, bAccess );
                            }
                            else if ( StringBeginsWith ( szRightName, "function." ) )
                            {
                                pRight = pACL->AddRight ( &szRightName[9], CAccessControlListRight::RIGHT_TYPE_FUNCTION, bAccess );
                            }
                            else if ( StringBeginsWith ( szRightName, "resource." ) )
                            {
                                pRight = pACL->AddRight ( &szRightName[9], CAccessControlListRight::RIGHT_TYPE_RESOURCE, bAccess );
                            }
                            else if ( StringBeginsWith ( szRightName, "general." ) )
                            {
                                pRight = pACL->AddRight ( &szRightName[8], CAccessControlListRight::RIGHT_TYPE_GENERAL, bAccess );
                            }
                            else continue;

//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:openvice,代码行数:101,代码来源:CAccessControlListManager.cpp

示例3: RefreshAutoPermissions

///////////////////////////////////////////////////////////////
//
// CResource::RefreshAutoPermissions
//
// Update group and acl used aclrequest items
//
///////////////////////////////////////////////////////////////
bool CResource::RefreshAutoPermissions ( CXMLNode* pNodeAclRequest )
{
    // Ensure group and acl exist
    CAccessControlListGroup* pAutoGroup = g_pGame->GetACLManager()->AddGroup ( GetAutoGroupName () );
    pAutoGroup->AddACL ( GetAutoAcl () );
    pAutoGroup->AddObject ( GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE );

    // Track unused right names
    std::vector < CAclRightName > unusedRightNameMap;
    std::vector < SAclRequest > unusedRequestList;
    GetAclRequests ( unusedRequestList );
    for ( uint i = 0 ; i < unusedRequestList.size () ; i++ )
       unusedRightNameMap.push_back ( unusedRequestList[i].rightName );

    // Track any pending requests
    bool bHasPending = false;

    for ( uint uiIndex = 0 ; true ; uiIndex++ )
    {
        CXMLNode* pNodeRight = pNodeAclRequest->FindSubNode ( "right", uiIndex );
        if ( !pNodeRight )
            break;

        // Find existing
        SAclRequest request ( CAclRightName ( pNodeRight->GetAttributeValue ( "name" ) ) );
        if ( !FindAclRequest ( request ) )
        {
            // Add new request
            request.bAccess = false;
            request.bPending = true;
            request.strWho = "";
            request.strDate = "";

            // Validate request
            if ( !request.rightName.IsValid () || !StringToBool ( pNodeRight->GetAttributeValue ( "access" ) ) )
            {
                CLogger::ErrorPrintf ( "Invalid aclrequest line in %s (%s)\n", GetName ().c_str (), *request.rightName.GetFullName () );
                return false;
            }

            CommitAclRequest ( request );
        }

        // This right is used
        ListRemove ( unusedRightNameMap, request.rightName );

        // Update flag
        bHasPending |= request.bPending;
    }

    // Remove rights not requested
    for ( std::vector < CAclRightName >::iterator iter = unusedRightNameMap.begin () ; iter != unusedRightNameMap.end () ; ++iter )
        GetAutoAcl ()->RemoveRight ( iter->GetName (), iter->GetType () );

    // If any rights are pending, print message
    if ( bHasPending )
    {
        CLogger::LogPrintf ( "Resource '%s' requests some acl rights. Use the command 'aclrequest list %s'\n", GetName ().c_str (), GetName ().c_str () );
    }

    return bHasPending;
}
开发者ID:pombredanne,项目名称:openvice,代码行数:69,代码来源:CResource.AclRequest.cpp


注:本文中的CAccessControlListGroup::AddACL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。