private OAuth2MethodSecurityExpressionHandler getExpressionHandler(
DefaultMethodSecurityExpressionHandler bean) {
OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
handler.setApplicationContext(this.applicationContext);
AuthenticationTrustResolver trustResolver = findInContext(
AuthenticationTrustResolver.class);
if (trustResolver != null) {
handler.setTrustResolver(trustResolver);
}
PermissionEvaluator permissions = findInContext(PermissionEvaluator.class);
if (permissions != null) {
handler.setPermissionEvaluator(permissions);
}
handler.setExpressionParser(bean.getExpressionParser());
return handler;
}
java类org.springframework.security.authentication.AuthenticationTrustResolver的实例源码
OAuth2MethodSecurityConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 23
收藏 0
点赞 0
评论 0
OAuth2MethodSecurityConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 31
收藏 0
点赞 0
评论 0
private OAuth2MethodSecurityExpressionHandler getExpressionHandler(
DefaultMethodSecurityExpressionHandler bean) {
OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
handler.setApplicationContext(this.applicationContext);
AuthenticationTrustResolver trustResolver = findInContext(
AuthenticationTrustResolver.class);
if (trustResolver != null) {
handler.setTrustResolver(trustResolver);
}
PermissionEvaluator permissions = findInContext(PermissionEvaluator.class);
if (permissions != null) {
handler.setPermissionEvaluator(permissions);
}
handler.setExpressionParser(bean.getExpressionParser());
return handler;
}
OAuth2MethodSecurityConfiguration.java 文件源码
项目:contestparser
阅读 32
收藏 0
点赞 0
评论 0
private OAuth2MethodSecurityExpressionHandler getExpressionHandler(
DefaultMethodSecurityExpressionHandler bean) {
OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
handler.setApplicationContext(this.applicationContext);
AuthenticationTrustResolver trustResolver = findInContext(
AuthenticationTrustResolver.class);
if (trustResolver != null) {
handler.setTrustResolver(trustResolver);
}
PermissionEvaluator permissions = findInContext(PermissionEvaluator.class);
if (permissions != null) {
handler.setPermissionEvaluator(permissions);
}
handler.setExpressionParser(bean.getExpressionParser());
return handler;
}
UserSecurityAdvice.java 文件源码
项目:gisgraphy
阅读 31
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
}
UserSecurityAdvice.java 文件源码
项目:ldadmin
阅读 33
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
}
SolrTestFrameRunner.java 文件源码
项目:eHMP
阅读 26
收藏 0
点赞 0
评论 0
private void initUserContext() {
// setup mock user context
mockTrustResolver = mock(AuthenticationTrustResolver.class);
mockUser = mock(HmpUserDetails.class, Mockito.withSettings().extraInterfaces(HealthTimePrinterSetHolder.class));
mockAuthentication = mock(Authentication.class);
// setup mock authentication context
SecurityContextHolder.getContext().setAuthentication(mockAuthentication);
when(mockAuthentication.isAuthenticated()).thenReturn(true);
when(mockAuthentication.getPrincipal()).thenReturn(mockUser);
when(mockTrustResolver.isAnonymous(mockAuthentication)).thenReturn(false);
// create and register
userContext = new HmpUserContext(mockTrustResolver);
addResource(userContext);
}
UserSecurityAdvice.java 文件源码
项目:musicrecital
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
}
OAuth2MethodSecurityConfiguration.java 文件源码
项目:spring-security-oauth2-boot
阅读 31
收藏 0
点赞 0
评论 0
private OAuth2MethodSecurityExpressionHandler getExpressionHandler(
DefaultMethodSecurityExpressionHandler bean) {
OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
handler.setApplicationContext(this.applicationContext);
AuthenticationTrustResolver trustResolver = findInContext(
AuthenticationTrustResolver.class);
if (trustResolver != null) {
handler.setTrustResolver(trustResolver);
}
handler.setExpressionParser(bean.getExpressionParser());
return handler;
}
UserCounterListener.java 文件源码
项目:gisgraphy
阅读 28
收藏 0
点赞 0
评论 0
private boolean isAnonymous() {
AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
SecurityContext ctx = SecurityContextHolder.getContext();
if (ctx != null) {
Authentication auth = ctx.getAuthentication();
return resolver.isAnonymous(auth);
}
return true;
}
UserCounterListener.java 文件源码
项目:ldadmin
阅读 24
收藏 0
点赞 0
评论 0
private boolean isAnonymous() {
AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
SecurityContext ctx = SecurityContextHolder.getContext();
if (ctx != null) {
Authentication auth = ctx.getAuthentication();
return resolver.isAnonymous(auth);
}
return true;
}
HmpUserContextTests.java 文件源码
项目:eHMP
阅读 30
收藏 0
点赞 0
评论 0
@Before
public void setUp() throws Exception {
mockTrustResolver = mock(AuthenticationTrustResolver.class);
mockUser = mock(HmpUserDetails.class, Mockito.withSettings().extraInterfaces(HealthTimePrinterSetHolder.class));
mockAuthentication = mock(Authentication.class);
userContext = new HmpUserContext(mockTrustResolver);
}
UserCounterListener.java 文件源码
项目:musicrecital
阅读 32
收藏 0
点赞 0
评论 0
private boolean isAnonymous() {
AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
SecurityContext ctx = SecurityContextHolder.getContext();
if (ctx != null) {
Authentication auth = ctx.getAuthentication();
return resolver.isAnonymous(auth);
}
return true;
}
SecurityConfiguration.java 文件源码
项目:FeedbackCollectionAndMgmtSystem
阅读 31
收藏 0
点赞 0
评论 0
@Bean
public AuthenticationTrustResolver getAuthenticationTrustResolver() {
return new AuthenticationTrustResolverImpl();
}
SecurityConfiguration.java 文件源码
项目:Webstore
阅读 26
收藏 0
点赞 0
评论 0
@Bean
public AuthenticationTrustResolver getAuthenticationTrustResolver() {
return new AuthenticationTrustResolverImpl();
}
UserAction.java 文件源码
项目:gisgraphy
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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;
}
RestExceptionTranslator.java 文件源码
项目:summerb
阅读 27
收藏 0
点赞 0
评论 0
public RestExceptionTranslator(JsonResponseWriter jsonResponseHelper,
AuthenticationTrustResolver authenticationTrustResolver) {
this.jsonResponseHelper = jsonResponseHelper;
this.authenticationTrustResolver = authenticationTrustResolver;
}
RestExceptionTranslator.java 文件源码
项目:summerb
阅读 32
收藏 0
点赞 0
评论 0
public AuthenticationTrustResolver getAuthenticationTrustResolver() {
return authenticationTrustResolver;
}
RestExceptionTranslator.java 文件源码
项目:summerb
阅读 29
收藏 0
点赞 0
评论 0
public void setAuthenticationTrustResolver(AuthenticationTrustResolver authenticationTrustResolver) {
this.authenticationTrustResolver = authenticationTrustResolver;
}
HmpUserContext.java 文件源码
项目:eHMP
阅读 25
收藏 0
点赞 0
评论 0
@Autowired
public HmpUserContext(AuthenticationTrustResolver authenticationTrustResolver) {
this.authenticationTrustResolver = authenticationTrustResolver;
}
SpringSecurityContext.java 文件源码
项目:musicrecital
阅读 31
收藏 0
点赞 0
评论 0
public boolean isRememberMe() {
AuthenticationTrustResolver resolver = new AuthenticationTrustResolverImpl();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
return resolver.isRememberMe(authentication);
}
SecurityExpressionOperationsSupplier.java 文件源码
项目:spring-security-play2
阅读 23
收藏 0
点赞 0
评论 0
public void setAuthenticationTrustResolver(AuthenticationTrustResolver authenticationTrustResolver) {
this.authenticationTrustResolver = authenticationTrustResolver;
}
SpringSecurityAction.java 文件源码
项目:spring-security-play2
阅读 28
收藏 0
点赞 0
评论 0
public void setAuthenticationTrustResolver(AuthenticationTrustResolver authenticationTrustResolver) {
this.authenticationTrustResolver = authenticationTrustResolver;
}