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


Java AccessMgr.authenticate方法代码示例

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

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

示例1: createResponse

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * ************************************************************************************************************************************
 * BEGIN ACCESSMGR
 * **************************************************************************************************************************************
 */
/* No qualifier */ FortResponse authenticate( FortRequest request )
{
    FortResponse response = createResponse();
    
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( request.getContextId() );
        User inUser = (User) request.getEntity();
        Session outSession = accessMgr.authenticate( inUser.getUserId(), inUser.getPassword() );
        response.setSession( outSession );
        response.setErrorCode( GlobalErrIds.NO_ERROR );
    }
    catch ( SecurityException se )
    {
        createError( response, LOG, se );
    }
    
    return response;
}
 
开发者ID:apache,项目名称:directory-fortress-enmasse,代码行数:25,代码来源:AccessMgrImpl.java


示例2: getUserIds

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * @param msg
 * @param uArray
 */
public static void getUserIds( String msg, String[][] uArray )
{
    LogUtil.logIt( msg );
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );
        for ( String[] usr : uArray )
        {
            User user = UserTestData.getUser( usr );
            Session session = accessMgr.authenticate( user.getUserId(), user.getPassword() );
            assertNotNull( session );
            String userId = accessMgr.getUserId( session );
            assertTrue( "getUserIds failed compare found userId [" + userId + "] valid userId ["
                + UserTestData.getUserId( usr ) + "]", userId.equalsIgnoreCase( UserTestData.getUserId( usr ) ) );
        }
        LOG.debug( "getUserIds successful" );
    }
    catch ( SecurityException ex )
    {
        LOG.error(
            "getUserIds: failed with SecurityException rc=" + ex.getErrorId() + ", msg="
                + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:30,代码来源:AccessMgrImplTest.java


示例3: authenticate

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * The authenticate API is used for use cases where RBAC authorization is not required.  This API will authenticate
 * the User's password and will check password policies but will not activate User's Roles into the return Session.
 *
 * @param userId   String contains case insensitive userId field.
 * @param password String contains case sensitive, clear text password field.
 * @return User Session that has no Roles activated thus will fail checkAccess and sessionPermission calls.
 */
private static Session authenticate( String userId, String password, AccessMgr accessMgr )
{
    String szLocation = ".authenticate";
    Session session = null;
    try
    {
        // authenticate will check the password but will not activated any roles into Session.
        session = accessMgr.authenticate( userId, password );
        LOG.info( szLocation + " successful" );
    }
    catch ( SecurityException ex )
    {
        LOG.error( szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
    return session;
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:26,代码来源:AccessMgrSample.java


示例4: authenticateUsers

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * @param msg
 * @param uArray
 * @param multiplier
 */
private static void authenticateUsers( String msg, String[][] uArray, int multiplier )
{
    LogUtil.logIt( msg );
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );
        for ( String[] usr : uArray )
        {
            User user = UserTestData.getUser( usr );
            Session session = accessMgr.authenticate( user.getUserId(), user.getPassword() );
            assertNotNull( session );
            // todo: need to test to ensure roles are not added to session.
            // now try negative test case:
            try
            {
                accessMgr.authenticate( user.getUserId(), "wrongpw" );
                fail( "authenticateUsers failed negative test" );
            }
            catch ( SecurityException se )
            {
                assertTrue( "authenticateUsers reset excep id check",
                    se.getErrorId() == GlobalErrIds.USER_PW_INVLD );
                // pass
            }
        }
        LOG.debug( "authenticateUsers successful" );
    }
    catch ( SecurityException ex )
    {
        LOG.error( "authenticateUsers: failed with SecurityException rc=" + ex.getErrorId() + ", msg="
            + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:40,代码来源:AccessMgrImplTest.java


示例5: authenticateLockedUsers

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * @param msg
 * @param uArray
 */
private static void authenticateLockedUsers( String msg, String[][] uArray )
{
    LogUtil.logIt( msg );
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );
        for ( String[] usr : uArray )
        {
            User user = UserTestData.getUser( usr );
            // now try negative test case:
            try
            {
                accessMgr.authenticate( user.getUserId(), user.getPassword() );
                fail( CLS_NM + ".authenticateLockedUsers failed test" );
            }
            catch ( SecurityException se )
            {
                assertTrue( CLS_NM + "authenticateLockedUsers reset excep id check",
                    se.getErrorId() == GlobalErrIds.USER_PW_LOCKED );
                // pass
                //LOG.error("locked=" + se.getMsgid() + " msg=" + se.getMessage());
            }
        }
        LOG.debug( "authenticateLockedUsers successful" );
    }
    catch ( SecurityException ex )
    {
        LOG.error( "authenticateLockedUsers: failed with SecurityException rc=" + ex.getErrorId()
            + ", msg=" + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:37,代码来源:AccessMgrImplTest.java


示例6: authenticateResetUsers

import org.apache.directory.fortress.core.AccessMgr; //导入方法依赖的package包/类
/**
 * @param msg
 * @param uArray
 */
private static void authenticateResetUsers( String msg, String[][] uArray, String[] plcy )
{
    LogUtil.logIt( msg );
    try
    {
        AccessMgr accessMgr = AccessMgrFactory.createInstance( TestUtils.getContext() );
        PwPolicyMgr policyMgr = PswdPolicyMgrImplTest.getManagedPswdMgr();
        for ( String[] usr : uArray )
        {
            User user = UserTestData.getUser( usr );
            // update this user with pw policy that requires change after reset:
            policyMgr.updateUserPolicy( user.getUserId(), PolicyTestData.getName( plcy ) );
            // now try negative test case:
            try
            {
                accessMgr.authenticate( user.getUserId(), user.getPassword() );
                //accessMgr.authenticate( user.getUserId(), user.getPassword() );
                fail( CLS_NM + ".authenticateResetUsers failed test" );
            }
            catch ( SecurityException se )
            {
                assertTrue( CLS_NM + "authenticateResetUsers reset excep id check",
                    se.getErrorId() == GlobalErrIds.USER_PW_RESET );
                // pass
            }
        }
        LOG.debug( "authenticateResetUsers successful" );
    }
    catch ( SecurityException ex )
    {
        LOG.error( "authenticateResetUsers: failed with SecurityException rc=" + ex.getErrorId()
            + ", msg=" + ex.getMessage(), ex );
        fail( ex.getMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:40,代码来源:AccessMgrImplTest.java



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