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


Java AccessMgr.addActiveRole方法代码示例

本文整理汇总了Java中org.apache.directory.fortress.core.AccessMgr.addActiveRole方法的典型用法代码示例。如果您正苦于以下问题:Java AccessMgr.addActiveRole方法的具体用法?Java AccessMgr.addActiveRole怎么用?Java AccessMgr.addActiveRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.directory.fortress.core.AccessMgr的用法示例。

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

示例1: addActiveRole

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
FortResponse addActiveRole( FortRequest request )
{
    FortResponse response = createResponse();
    
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( request.getContextId() );
        UserRole uRole = (UserRole)request.getEntity();
        Session session = request.getSession();
        accessMgr.addActiveRole( session, uRole );
        response.setSession( session );
    }
    catch ( SecurityException se )
    {
        createError( response, LOG, se );
    }
    
    return response;
}
 
开发者ID:apache,项目名称:directory-fortress-enmasse,代码行数:20,代码来源:AccessMgrImpl.java


示例2: testAddActiveRoles

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * The addActivateRole API allows only Roles that have been assigned to a given User to be activated in their
 * RBAC Session.  The API will also ensure that a given Role has passed its constraint tests which include
 * Static Separation of Duty (SSD) and RBAC Role temporal constraint validations.
 */
public static void testAddActiveRoles()
{
    String szLocation = ".testAddActiveRoles";
    try
    {
        // Instantiate the AccessMgr implementation.
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );
        // authenticate will check the password but will not activated any roles into Session.
        Session session = authenticate( CreateUserSample.TEST_USERID, CreateUserSample.TEST_PASSWORD,
            accessMgr );
        assertNotNull( session );
        // now, activate roles into User's Session one at a time:
        for ( int i = 1; i < 11; i++ )
        {
            UserRole addUserRole = new UserRole( CreateUserSample.TEST_USERID, CreateRoleSample.TEST_ROLE_PREFIX
                + i );
            accessMgr.addActiveRole( session, addUserRole );
            LOG.info( szLocation + " userId [" + addUserRole.getUserId() + "] activated role ["
                + addUserRole.getName() + "] added to session" );
        }
    }
    catch ( SecurityException ex )
    {
        LOG.error( szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:33,代码来源:AccessMgrSample.java



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