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


Java AccessMgr.sessionPermissions方法代码示例

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

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

示例1: getPermissions

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * Retrieve RBAC session permissions from Fortress and place in the Wicket session.
 */
static void getPermissions( Component component, AccessMgr accessMgr )
{
    try
    {
        if ( IS_PERM_CACHED )
        {
            FtSession session = ( FtSession ) component.getSession();
            List<Permission> permissions = accessMgr.sessionPermissions( session.getSession() );
            ( ( FtSession ) FtSession.get() ).setPermissions( permissions );
        }
    }
    catch ( org.apache.directory.fortress.core.SecurityException se )
    {
        String error = "getPermissions caught SecurityException=" + se;
        LOG.error( error );
        throw new RuntimeException( error );
    }
}
 
开发者ID:shawnmckinney,项目名称:fortress-saml-demo,代码行数:22,代码来源:SecUtils.java


示例2: sessionPermissions

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


示例3: testSessionPermissions

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * The sessionPermissions API is useful for GUI programs that need to cache all of the User's Permissions in the
 * HTTP Session or application cache.  This is useful when providing access control lists for menu items and other
 * controls that sometimes need to check authorizations on.  This API will return all permissions that are granted
 * to User's activated Roles along with Permissions that have been granted directly to the User entity itself.
 */
public static void testSessionPermissions()
{
    String szLocation = ".testSessionPermissions";
    try
    {
        // Instantiate the AccessMgr implementation.
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );

        // utility function will create an Fortress Session.  The Session contains the user's activated
        // roles along with other related attributes and status information (i.e. password status)
        Session session = createSession( CreateUserSample.TEST_USERID,
            CreateUserSample.TEST_PASSWORD, accessMgr );
        assertNotNull( session );
        List<Permission> perms = accessMgr.sessionPermissions( session );
        assertNotNull( perms );
        assertTrue( szLocation + " list check, expected: 5, actual:" + perms.size(), perms.size() == 5 );

        // iterate over expected permissions to make sure they are returned from sessionPermissions API.
        for ( int i = 1; i < 6; i++ )
        {
            // A Permission consists of an object name and operation name.
            Permission checkPerm = new Permission( CreatePermSample.TEST_PERM_OBJECT,
                CreatePermSample.TEST_PERM_OPERATION_PREFIX + i );
            boolean result = accessMgr.checkAccess( session, checkPerm );
            assertTrue( szLocation, result );
            LOG.info( szLocation + " user [" + session.getUserId() + "] permission object ["
                + checkPerm.getObjName() + "] operation name [" + checkPerm.getOpName() + "] success" );
        }
    }
    catch ( SecurityException ex )
    {
        LOG.error( szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:42,代码来源:AccessMgrSample.java


示例4: sessionPermissions

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * @param msg
 * @param uArray
 * @param oArray
 * @param opArray
 */
public static void sessionPermissions( String msg, String[][] uArray, String[][] oArray, String[][] opArray )
{
    LogUtil.logIt( msg );
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );
        for ( String[] usr : uArray )
        {
            User user = UserTestData.getUser( usr );
            Session session = accessMgr.createSession( user, false );
            assertNotNull( session );
            List<Permission> pOps = accessMgr.sessionPermissions( session );
            assertNotNull( pOps );
            // There should be objs * ops number of perms in the list returned from sessionPermissions method:
            assertEquals( CLS_NM +
                ".sessionPermissions failed list size user[" + user.getUserId() + "]",
                oArray.length * opArray.length, pOps.size() );

            // Iterate over objs x ops, see if every expected valid permission is contained within the returned list:
            for ( String[] obj : oArray )
            {
                for ( String[] op : opArray )
                {
                    Permission validPOp = PermTestData.getOp( PermTestData.getName( obj ), op );
                    assertTrue( CLS_NM +
                        ".sessionPermissions failed perm list compare USER [" + user.getUserId() +
                        "] PERM Obj [" + PermTestData.getName( obj ) + "] " +
                        "OPER [" + PermTestData.getName( op ) + "]",
                        pOps.contains( validPOp ) );
                }
            }
        }
    }
    catch ( SecurityException ex )
    {
        LOG.error( "sessionPermissions: failed with SecurityException rc=" + ex.getErrorId() + ", msg="
            + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:47,代码来源:AccessMgrImplTest.java



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