• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AuthenticationTrustResolverImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.security.authentication.AuthenticationTrustResolverImpl的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationTrustResolverImpl类的具体用法?Java AuthenticationTrustResolverImpl怎么用?Java AuthenticationTrustResolverImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AuthenticationTrustResolverImpl类属于org.springframework.security.authentication包,在下文中一共展示了AuthenticationTrustResolverImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: auditorAwareBean

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
@Bean
public AuditorAware<String> auditorAwareBean() {
  return () -> {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null
        || new AuthenticationTrustResolverImpl().isAnonymous(authentication)) {
      return "@SYSTEM";
    }

    Object principal = authentication.getPrincipal();
    if (principal instanceof String) {
      return (String) principal;
    } else if (principal instanceof UserDetails) {
      return ((UserDetails) principal).getUsername();
    } else {
      return String.valueOf(principal);
    }
  };
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:20,代码来源:WebSecurityConfiguration.java


示例2: afterReturning

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
/**
    * After returning, grab the user, check if they've been modified and reset
    * the SecurityContext if they have.
    * 
    * @param returnValue
    *                the user object
    * @param method
    *                the name of the method executed
    * @param args
    *                the arguments to the method
    * @param target
    *                the target class
    * @throws Throwable
    *                 thrown when args[0] is null or not a User object
    */
   public void afterReturning(Object returnValue, Method method,
    Object[] args, Object target) throws Throwable {
User user = (User) args[0];

if (user.getVersion() != null) {
    // reset the authentication object if current user
    Authentication auth = SecurityContextHolder.getContext()
	    .getAuthentication();
    AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
    // allow new users to signup - this is OK b/c Signup doesn't allow
    // setting of roles
    boolean signupUser = resolver.isAnonymous(auth);
    if (auth != null && !signupUser) {
	User currentUser = getCurrentUser(auth);
	if (currentUser.getId().equals(user.getId())) {
	    auth = new UsernamePasswordAuthenticationToken(user, user
		    .getPassword(), user.getAuthorities());
	    SecurityContextHolder.getContext().setAuthentication(auth);
	}
    }
}
   }
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:38,代码来源:UserSecurityAdvice.java


示例3: afterReturning

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
/**
 * After returning, grab the user, check if they've been modified and reset the SecurityContext if they have.
 *
 * @param returnValue the user object
 * @param method      the name of the method executed
 * @param args        the arguments to the method
 * @param target      the target class
 * @throws Throwable thrown when args[0] is null or not a User object
 */
public void afterReturning(Object returnValue, Method method, Object[] args, Object target)
        throws Throwable {
    User user = (User) args[0];

    if (user.getVersion() != null) {
        // reset the authentication object if current user
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
        // allow new users to signup - this is OK b/c Signup doesn't allow setting of roles
        boolean signupUser = resolver.isAnonymous(auth);
        if (auth != null && !signupUser) {
            UserManager userManager = (UserManager) target;
            User currentUser = getCurrentUser(auth, userManager);
            if (currentUser.getId().equals(user.getId())) {
                auth = new UsernamePasswordAuthenticationToken(user, user.getPassword(), user.getAuthorities());
                SecurityContextHolder.getContext().setAuthentication(auth);
            }
        }
    }
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:30,代码来源:UserSecurityAdvice.java


示例4: createSecurityExpressionRoot

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
@Override
protected SecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication, FilterInvocation fi) {
    WebSecurityExpressionRoot root = new CustomWebSecurityExpressionRoot(authentication, fi);
    root.setPermissionEvaluator(getPermissionEvaluator());
    root.setTrustResolver(new AuthenticationTrustResolverImpl());
    root.setRoleHierarchy(getRoleHierarchy());
    return root;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:9,代码来源:CustomWebSecurityExpressionHandler.java


示例5: createSecurityExpressionRoot

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
@Override
protected MethodSecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication, MethodInvocation invocation) {
    CustomMethodSecurityExpressionRoot root = new CustomMethodSecurityExpressionRoot(authentication);
    root.setThis(invocation.getThis());
    root.setPermissionEvaluator(getPermissionEvaluator());
    root.setTrustResolver(new AuthenticationTrustResolverImpl());
    root.setRoleHierarchy(getRoleHierarchy());

    return root;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:11,代码来源:CustomMethodSecurityExpressionHandler.java


示例6: isAnonymous

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
private boolean isAnonymous() {
AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
SecurityContext ctx = SecurityContextHolder.getContext();
if (ctx != null) {
    Authentication auth = ctx.getAuthentication();
    return resolver.isAnonymous(auth);
}
return true;
   }
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:10,代码来源:UserCounterListener.java


示例7: isAnonymous

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
private boolean isAnonymous() {
    AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
    SecurityContext ctx = SecurityContextHolder.getContext();
    if (ctx != null) {
        Authentication auth = ctx.getAuthentication();
        return resolver.isAnonymous(auth);
    }
    return true;
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:10,代码来源:UserCounterListener.java


示例8: getAuthenticationTrustResolver

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
@Bean
public AuthenticationTrustResolver getAuthenticationTrustResolver() {
    return new AuthenticationTrustResolverImpl();
}
 
开发者ID:mustafamym,项目名称:FeedbackCollectionAndMgmtSystem,代码行数:5,代码来源:SecurityConfiguration.java


示例9: edit

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
/**
    * Grab the user from the database based on the "id" passed in.
    * 
    * @return success if user found
    * @throws IOException
    *                 can happen when sending a "forbidden" from
    *                 response.sendError()
    */
   public String edit() throws IOException {
HttpServletRequest request = getRequest();
boolean editProfile = (request.getRequestURI().indexOf("editProfile") > -1);

// if URL is "editProfile" - make sure it's the current user
if (editProfile) {
    // reject if id passed in or "list" parameter passed in
    // someone that is trying this probably knows the AppFuse code
    // but it's a legitimate bug, so I'll fix it. ;-)
    if ((request.getParameter("id") != null)
	    || (request.getParameter("from") != null)) {
	ServletActionContext.getResponse().sendError(
		HttpServletResponse.SC_FORBIDDEN);
	log.warn("User '" + request.getRemoteUser()
		+ "' is trying to edit user '"
		+ request.getParameter("id") + "'");

	return null;
    }
}

// if a user's id is passed in
if (id != null) {
    // lookup the user using that id
    user = userManager.getUser(id);
} else if (editProfile) {
    user = userManager.getUserByUsername(request.getRemoteUser());
} else {
    user = new User();
    user.addRole(new Role(Constants.USER_ROLE));
}

if (user.getUsername() != null) {
    user.setConfirmPassword(user.getPassword());

    // if user logged in with remember me, display a warning that they
    // can't change passwords
    log.debug("checking for remember me login...");

    AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
    SecurityContext ctx = SecurityContextHolder.getContext();

    if (ctx != null) {
	Authentication auth = ctx.getAuthentication();

	if (resolver.isRememberMe(auth)) {
	    getSession().setAttribute("cookieLogin", "true");
	    saveMessage(getText("userProfile.cookieLogin"));
	}
    }
}

return SUCCESS;
   }
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:63,代码来源:UserAction.java


示例10: RestExceptionTranslator

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
public RestExceptionTranslator() {
	jsonResponseHelper = new JsonResponseWriterGsonImpl();
	authenticationTrustResolver = new AuthenticationTrustResolverImpl();
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:5,代码来源:RestExceptionTranslator.java


示例11: addSecurityContextHolderAwareRequestFilter

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
private void addSecurityContextHolderAwareRequestFilter(List<Filter> filters) throws ServletException {
    SecurityContextHolderAwareRequestFilter securityFilter = new SecurityContextHolderAwareRequestFilter();
    securityFilter.setTrustResolver(new AuthenticationTrustResolverImpl());
    securityFilter.afterPropertiesSet();
    filters.add(securityFilter);
}
 
开发者ID:motech,项目名称:motech,代码行数:7,代码来源:SecurityRuleBuilder.java


示例12: isRememberMe

import org.springframework.security.authentication.AuthenticationTrustResolverImpl; //导入依赖的package包/类
public boolean isRememberMe() {
    AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

    return resolver.isRememberMe(authentication);
}
 
开发者ID:dlwhitehurst,项目名称:musicrecital,代码行数:7,代码来源:SpringSecurityContext.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RIPEMD128Digest类代码示例发布时间:2022-05-21
下一篇:
Java FieldSelectorResult类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap