本文整理汇总了Java中net.sf.acegisecurity.context.ContextHolder.setContext方法的典型用法代码示例。如果您正苦于以下问题:Java ContextHolder.setContext方法的具体用法?Java ContextHolder.setContext怎么用?Java ContextHolder.setContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.acegisecurity.context.ContextHolder
的用法示例。
在下文中一共展示了ContextHolder.setContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: 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();
}
示例5: clearCurrentSecurityContext
import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
public void clearCurrentSecurityContext()
{
ContextHolder.setContext(null);
}
示例6: afterPhase
import net.sf.acegisecurity.context.ContextHolder; //导入方法依赖的package包/类
@Override
public void afterPhase(PhaseEvent phaseevent)
{
ContextHolder.setContext(null);
}
示例7: 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);
}