SpringSecurityActuator.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:cibet 作者:
private Authentication swapAuthentication() {
   if (secondPrincipal) {
      Object secP = Context.internalSessionScope().getProperty(InternalSessionScope.SECOND_PRINCIPAL);
      if (secP == null) {
         throw new AuthenticationCredentialsNotFoundException(
               "No Authentication object found in CibetContext.getSecondPrincipal()");
      }

      if (!(secP instanceof Authentication)) {
         throw new AccessDeniedException("CibetContext.getSecondPrincipal() is expected to be of type "
               + Authentication.class.getName() + " but is of type " + secP.getClass().getName());
      }

      log.debug("SpringSecurity actuator for second principal " + secP);
      Authentication auth = (Authentication) secP;
      Authentication original = SecurityContextHolder.getContext().getAuthentication();
      SecurityContextHolder.getContext().setAuthentication(auth);
      return original;
   }
   return null;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号