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


Java SecurityContextHolder.getContext方法代码示例

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


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

示例1: doFilter

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {


    if(1 + 1 == 2) {
        SecurityContext oldCtx = SecurityContextHolder.getContext();
        SecurityContextHolder.setContext(null); //
        try {
            super.doFilter(req, res, chain);
        } finally {
            SecurityContextHolder.setContext(oldCtx);
        }
    }
    else {
        super.doFilter(req, res, chain);
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:18,代码来源:AcegiSafeSessionFilter.java

示例2: retrieveDataElement

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public CommonDataElement retrieveDataElement(Long dataElementId, Float dataElementVersion)
throws ConnectionException {
    // Satish Patel informed me that the cadsrApi clears out the SecurityContext after they're done with it,
    // they are working on a fix but as a workaround I need to store the context and set it again after
    // I am done with all of the caDSR domain objects.  --TJ
    SecurityContext originalContext = SecurityContextHolder.getContext();
    try {
        List<Object> cadsrDataElements = searchDataElement(dataElementId, dataElementVersion);
        gov.nih.nci.cadsr.domain.DataElement latestCadsrDataElement = getLatestDataElement(cadsrDataElements);
        return convertCadsrDataElementToDataElements(latestCadsrDataElement);
    } catch (Exception e) {
        throw new ConnectionException("Couldn't connect to the caDSR server", e);
    } finally {
        // Restore context as described above.
        SecurityContextHolder.setContext(originalContext);
    }
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:22,代码来源:CaDSRFacadeImpl.java

示例3: test

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
@Override
public void test() {
    SecurityContext sc = SecurityContextHolder.getContext();
    if (sc.getAuthentication() != null)
        System.out.println(sc.getAuthentication().getName()
                + " logged by test");

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:TestImpl.java

示例4: triggerJobs

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
public GogsResults triggerJobs(String jobName, String deliveryID) {
  SecurityContext saveCtx = null;
  GogsResults result = new GogsResults();

  try {
    saveCtx = SecurityContextHolder.getContext();

    Jenkins instance = Jenkins.getActiveInstance();
    if (instance!=null) {
      ACL acl = instance.getACL();
      acl.impersonate(ACL.SYSTEM);

      BuildableItem project = GogsUtils.find(jobName, BuildableItem.class);
      if (project != null) {
        Cause cause = new GogsCause(deliveryID);
        project.scheduleBuild(0, cause);
        result.setMessage(String.format("Job '%s' is executed",jobName));
      } else {
        String msg = String.format("Job '%s' is not defined in Jenkins",jobName);
        result.setStatus(404, msg);
        LOGGER.warning(msg);
      }
    }
  } catch (Exception e) {
  } finally {
      SecurityContextHolder.setContext(saveCtx);
  }

  return result;
}
 
开发者ID:jenkinsci,项目名称:gogs-webhook-plugin,代码行数:31,代码来源:GogsPayloadProcessor.java

示例5: retrieveValueDomainForDataElement

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ValueDomain retrieveValueDomainForDataElement(Long dataElementId, Float dataElementVersion)
throws ConnectionException {
    ValueDomain valueDomain = new ValueDomain();
    // Satish Patel informed me that the cadsrApi clears out the SecurityContext after they're done with it,
    // they are working on a fix but as a workaround I need to store the context and set it again after
    // I am done with all of the caDSR domain objects.  --TJ
    SecurityContext originalContext = SecurityContextHolder.getContext();
    try {
        List<Object> cadsrDataElements = searchDataElement(dataElementId, dataElementVersion);

        if (!cadsrDataElements.isEmpty()) {
            gov.nih.nci.cadsr.domain.ValueDomain cadsrValueDomain =
                ((gov.nih.nci.cadsr.domain.DataElement) cadsrDataElements.get(0)).getValueDomain();
            // Default will be String, Character, Alphanumeric, and Alpha DVG
            AnnotationTypeEnum annotationType = AnnotationTypeEnum.STRING;
            String cadsrDataType = cadsrValueDomain.getDatatypeName();
            if (cadsrDataType.matches("DATE")) {
                annotationType = AnnotationTypeEnum.DATE;
            }
            if (cadsrDataType.matches("NUMBER")) {
                annotationType = AnnotationTypeEnum.NUMERIC;
            }
            valueDomain.setDataType(annotationType);
            valueDomain.setLongName(cadsrValueDomain.getLongName());
            valueDomain.setPublicID(cadsrValueDomain.getPublicID());
            if (cadsrValueDomain instanceof EnumeratedValueDomain) {
                retrievePermissibleValues(valueDomain, cadsrValueDomain);
            }
        }
        return valueDomain;
    } catch (Exception e) {
        throw new ConnectionException("Couldn't connect to the caDSR server", e);
    } finally {
        // Restore context as described above.
        SecurityContextHolder.setContext(originalContext);
    }
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:42,代码来源:CaDSRFacadeImpl.java

示例6: getLogin

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
protected String getLogin() {
    SecurityContext sc = SecurityContextHolder.getContext();
    if (sc.getAuthentication() == null)
        return null;
    return sc.getAuthentication().getName();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:7,代码来源:UserProviderImpl.java

示例7: getSecurityContext

import org.acegisecurity.context.SecurityContextHolder; //导入方法依赖的package包/类
private SecurityContext getSecurityContext() {
    return SecurityContextHolder.getContext();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:4,代码来源:ServerAccessRules.java


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