當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextHolder類代碼示例

本文整理匯總了Java中net.sf.acegisecurity.context.ContextHolder的典型用法代碼示例。如果您正苦於以下問題:Java ContextHolder類的具體用法?Java ContextHolder怎麽用?Java ContextHolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContextHolder類屬於net.sf.acegisecurity.context包,在下文中一共展示了ContextHolder類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getUserDetails

import net.sf.acegisecurity.context.ContextHolder; //導入依賴的package包/類
/**
 * We actually have an acegi object so override the default method.
 */
@Override
protected UserDetails getUserDetails(String userName)
{
    if (AuthenticationUtil.isMtEnabled())
    {
        // ALF-9403 - "manual" runAs to avoid clearing ticket, eg. when called via "validate" (->setCurrentUser->CheckCurrentUser)
        Authentication originalFullAuthentication = AuthenticationUtil.getFullAuthentication();
        try
        {
            if (originalFullAuthentication == null)
            {
                AuthenticationUtil.setFullyAuthenticatedUser(getSystemUserName(getUserDomain(userName)));
            }
            return authenticationDao.loadUserByUsername(userName);
        }
        finally
        {
            if (originalFullAuthentication == null)
            {
                ContextHolder.setContext(null); // note: does not clear ticket (unlike AuthenticationUtil.clearCurrentSecurityContext())
            }
        }
    }
    else
    {
        return authenticationDao.loadUserByUsername(userName);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:32,代碼來源:AuthenticationComponentImpl.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: clearCurrentSecurityContext

import net.sf.acegisecurity.context.ContextHolder; //導入依賴的package包/類
/**
 * Remove the current security information
 */
public static void clearCurrentSecurityContext()
{
    if (s_logger.isDebugEnabled())
        s_logger.debug("Removing the current security information.");
    ContextHolder.setContext(null);
    InMemoryTicketComponentImpl.clearCurrentSecurityContext();
    
    NDC.remove();
    
    TenantContextHolder.clearTenantDomain();
}
 
開發者ID:Alfresco,項目名稱:alfresco-data-model,代碼行數:15,代碼來源:AuthenticationUtil.java

示例11: clearCurrentSecurityContext

import net.sf.acegisecurity.context.ContextHolder; //導入依賴的package包/類
public void clearCurrentSecurityContext()
{
    ContextHolder.setContext(null);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:5,代碼來源:TestAuthenticationServiceImpl.java

示例12: afterPhase

import net.sf.acegisecurity.context.ContextHolder; //導入依賴的package包/類
@Override
public void afterPhase(PhaseEvent phaseevent)
{
    ContextHolder.setContext(null);
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:6,代碼來源:SecurityContextCleanupPhaseListener.java

示例13: doFilter

import net.sf.acegisecurity.context.ContextHolder; //導入依賴的package包/類
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException
{
    ContextHolder.setContext(null);
    chain.doFilter(servletRequest, servletResponse);
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:7,代碼來源:CmisSecurityContextCleanerFilter.java


注:本文中的net.sf.acegisecurity.context.ContextHolder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。