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


Java ContextHolder.getContext方法代码示例

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


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

示例1: applyPostQueryPermissions

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
@Override
protected List<R> applyPostQueryPermissions(List<R> results, int requestedCount)
{
    Context context = ContextHolder.getContext();
    if ((context == null) || (! (context instanceof AlfrescoSecureContext)))
    {
        // This indicates that we have come via the internal service methods
        if (logger.isDebugEnabled())
        {
            logger.debug("Ignoring post-query permissions.  The secure context is empty: " + this);
        }
        return results;
    }
    Authentication authentication = (((SecureContext) context).getAuthentication());
    
    List<R> resultsOut = (List<R>) methodSecurity.applyPermissions(results, authentication, requestedCount);
    // Done
    return resultsOut;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:AbstractCannedQueryPermissions.java

示例2: getCurrentUserName

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
public String getCurrentUserName() throws AuthenticationException
{
    Context context = ContextHolder.getContext();
    if ((context == null) || !(context instanceof SecureContext))
    {
        return null;
    }
    return getUserName(((SecureContext) context).getAuthentication());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:TestAuthenticationServiceImpl.java

示例3: setFullAuthentication

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
/**
 * Re-authenticate using a previously-created authentication.
 */
public static Authentication setFullAuthentication(Authentication authentication)
{
    if (authentication == null)
    {
        clearCurrentSecurityContext();
        return null;
    }
    else
    {
        if (s_logger.isDebugEnabled())
            s_logger.debug("Setting fully authenticated principal: " + authentication.getName());
        Context context = ContextHolder.getContext();
        AlfrescoSecureContext sc = null;
        if ((context == null) || !(context instanceof AlfrescoSecureContext))
        {
            if (s_logger.isDebugEnabled())
                s_logger.debug("Creating new secure context.");
            sc = new AlfrescoSecureContextImpl();
            ContextHolder.setContext(sc);
        }
        else
        {
            sc = (AlfrescoSecureContext) context;
        }
        authentication.setAuthenticated(true);
        // Sets real and effective
        sc.setRealAuthentication(authentication);
        sc.setEffectiveAuthentication(authentication);
        return authentication;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:35,代码来源:AuthenticationUtil.java

示例4: setRunAsAuthentication

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
static Authentication setRunAsAuthentication(Authentication authentication)
{
    if (authentication == null)
    {
        clearCurrentSecurityContext();
        return null;
    }
    else
    {
        if (s_logger.isDebugEnabled())
            s_logger.debug("Setting RunAs principal: " + authentication.getName());
        Context context = ContextHolder.getContext();
        AlfrescoSecureContext sc = null;
        if ((context == null) || !(context instanceof AlfrescoSecureContext))
        {
            if (s_logger.isDebugEnabled())
                s_logger.debug("Creating new secure context.");
            sc = new AlfrescoSecureContextImpl();
            ContextHolder.setContext(sc);
        }
        else
        {
            sc = (AlfrescoSecureContext) context;
        }
        authentication.setAuthenticated(true);
        if (sc.getRealAuthentication() == null)
        {
            if (s_logger.isDebugEnabled())
                s_logger.debug("There is no fully authenticated prinipal. Setting fully authenticated principal: " + authentication.getName());
            sc.setRealAuthentication(authentication);
        }
        sc.setEffectiveAuthentication(authentication);
        return authentication;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:36,代码来源:AuthenticationUtil.java

示例5: getRunAsAuthentication

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
/**
 * Get the current authentication for application of permissions.  This includes
 * the any overlay details set by {@link #setRunAsUser(String)}.
 * 
 * @return Authentication               Returns the running authentication
 * @throws AuthenticationException
 */
public static Authentication getRunAsAuthentication() throws AuthenticationException
{
    Context context = ContextHolder.getContext();
    if ((context == null) || !(context instanceof AlfrescoSecureContext))
    {
        return null;
    }
    return ((AlfrescoSecureContext) context).getEffectiveAuthentication();
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:17,代码来源:AuthenticationUtil.java

示例6: getFullAuthentication

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
/**
 * <b>WARN: Advanced usage only.</b><br/>
 * Get the authentication for that was set by an real authentication.
 * 
 * @return Authentication               Returns the real authentication
 * @throws AuthenticationException
 */
public static Authentication getFullAuthentication() throws AuthenticationException
{
    Context context = ContextHolder.getContext();
    if ((context == null) || !(context instanceof AlfrescoSecureContext))
    {
        return null;
    }
    return ((AlfrescoSecureContext) context).getRealAuthentication();
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:17,代码来源:AuthenticationUtil.java

示例7: getRunAsUser

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
/**
 * Get the user that is currently in effect for purposes of authentication.  This includes
 * any overlays introduced by {@link #setRunAsUser(String) runAs}.
 * 
 * @return              Returns the name of the user
 * @throws AuthenticationException
 */
public static String getRunAsUser() throws AuthenticationException
{
    Context context = ContextHolder.getContext();
    if ((context == null) || !(context instanceof AlfrescoSecureContext))
    {
        return null;
    }
    AlfrescoSecureContext ctx = (AlfrescoSecureContext) context;
    if (ctx.getEffectiveAuthentication() == null)
    {
        return null;
    }
    return getUserName(ctx.getEffectiveAuthentication());
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:22,代码来源:AuthenticationUtil.java

示例8: getFullyAuthenticatedUser

import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
/**
 * Get the fully authenticated user. 
 * It returns the name of the user that last authenticated and excludes any overlay authentication set
 * by {@link #runAs(org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork, String) runAs}.
 * 
 * @return              Returns the name of the authenticated user
 * @throws AuthenticationException
 */
public static String getFullyAuthenticatedUser() throws AuthenticationException
{
    Context context = ContextHolder.getContext();
    if ((context == null) || !(context instanceof AlfrescoSecureContext))
    {
        return null;
    }
    AlfrescoSecureContext ctx = (AlfrescoSecureContext) context;
    if (ctx.getRealAuthentication() == null)
    {
        return null;
    }
    return getUserName(ctx.getRealAuthentication());
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:23,代码来源:AuthenticationUtil.java


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