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


Java GrantedAuthorityImpl类代码示例

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


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

示例1: tagError

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@RequestMapping(value = "/tagerror")
@ResponseBody
public DeferredResult<List<TagError>> tagError(@RequestParam Long errorDateTimestamp, @RequestParam(required=false) String numeroId) {
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	if(numeroId==null && !auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_ADMIN")) && !auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_SUPERVISOR"))) {
		return null;
	}
	LiveQuery liveQuery = new LiveQuery(errorDateTimestamp, numeroId);
	final DeferredResult<List<TagError>> tagErrors = new DeferredResult<List<TagError>>(null, Collections.emptyList());
	
	this.suspendedTagErrorsRequests.put(tagErrors, liveQuery);

	tagErrors.onCompletion(new Runnable() {
		public void run() {
			suspendedTagErrorsRequests.remove(tagErrors);
		}
	});
	
	return tagErrors;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:21,代码来源:ErrorLongPoolController.java

示例2: loadUserByUsername

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
/**
    * Locates the user based on the username.
    *
    * @param username The username presented to the {@link DaoAuthenticationProvider}
    * @return A fully populated user record (never <code>null</code>)
    * @throws UsernameNotFoundException if the user could not be found or the user has no GrantedAuthority.
    * @throws DataAccessException       If user could not be found for a repository-specific reason.
    */
   @SuppressWarnings("deprecation")
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {

   	boolean unlocked = true;
       User user = getUserByName(username);
       
       if (user == null) {
           throw new UsernameNotFoundException("User \"" + username + "\" was not found.");
       }
       // block disabled user at logon
       if (username.equalsIgnoreCase("default") || user.isLocked()) {
       	unlocked = false;
       }
       String[] roles = userDao.getRolesForUser(username);
       List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(roles.length);
       for (int i = 0; i < roles.length; i++) {
           authorities.add(new GrantedAuthorityImpl("ROLE_" + roles[i].toUpperCase()));
       }
       // If user is LDAP authenticated, disable user. The proper authentication should in that case
       // be done by SubsonicLdapBindAuthenticator.
       boolean enabled = !user.isLdapAuthenticated();

       return new org.springframework.security.core.userdetails.User(username, user.getPassword(), enabled, true, true, unlocked, authorities);
   }
 
开发者ID:MadMarty,项目名称:madsonic-server-5.1,代码行数:33,代码来源:SecurityService.java

示例3: findGroupAuthorities

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@Override
public List<GrantedAuthority> findGroupAuthorities( String groupName ) {

    String groupToSearch = groupName;
    if ( groupName.startsWith( rolePrefix ) ) {
        groupToSearch = groupToSearch.replaceFirst( rolePrefix, "" );
    }

    UserGroup group = loadGroup( groupToSearch );

    List<GrantedAuthority> result = new ArrayList<GrantedAuthority>();
    for ( gemma.gsec.model.GroupAuthority ga : group.getAuthorities() ) {
        result.add( new GrantedAuthorityImpl( ga.getAuthority() ) );
    }

    return result;
}
 
开发者ID:PavlidisLab,项目名称:modinvreg,代码行数:18,代码来源:UserManagerImpl.java

示例4: testDeleteUserGroup

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
/**
 * Test for deleting a user group
 */
@Test
public void testDeleteUserGroup() {

    runAsAdmin();
    List<GrantedAuthority> authos = new ArrayList<GrantedAuthority>();
    authos.add( new GrantedAuthorityImpl( "GROUP_TESTING" ) );
    this.userManager.createGroup( this.groupName, authos );

    // add another user to group
    this.userManager.addUserToGroup( this.userName1, this.groupName );
    this.userManager.addUserToGroup( this.userName2, this.groupName );

    // delete the group
    this.userManager.deleteGroup( this.groupName );

}
 
开发者ID:PavlidisLab,项目名称:modinvreg,代码行数:20,代码来源:UserGroupServiceTest.java

示例5: hasRole

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@RequestMapping(produces = "text/html")
  @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_MANAGER') or hasRole('ROLE_MEMBRE')")
  public String list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "sortFieldName", required = false) String sortFieldName, @RequestParam(value = "sortOrder", required = false) String sortOrder, Model uiModel) {

Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  	boolean isMembre = auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_MEMBRE"));
  	
  	if(isMembre) {
  		String emailAddress = auth.getName();
  		User user = User.findUsersByEmailAddress(emailAddress, null, null).getSingleResult();
  		List<PosteAPourvoir> posteapourvoirs = PosteAPourvoir.findPosteAPourvoirsByMembre(user);
  		uiModel.addAttribute("posteapourvoirs", posteapourvoirs);
  	} else if (page != null || size != null) {
          int sizeNo = size == null ? 10 : size.intValue();
          final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
          uiModel.addAttribute("posteapourvoirs", PosteAPourvoir.findPosteAPourvoirEntries(firstResult, sizeNo, sortFieldName, sortOrder));
          float nrOfPages = (float) PosteAPourvoir.countPosteAPourvoirs() / sizeNo;
          uiModel.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
      } else {
          uiModel.addAttribute("posteapourvoirs", PosteAPourvoir.findAllPosteAPourvoirs(sortFieldName, sortOrder));
      }
  	uiModel.addAttribute("textePostesMenu4Members", AppliConfig.getCacheTextePostesMenu4Members());
      addDateTimeFormatPatterns(uiModel);
      return "posteapourvoirs/list";
  }
 
开发者ID:EsupPortail,项目名称:esup-dematec,代码行数:26,代码来源:PosteAPourvoirController.java

示例6: profilChoice

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@RequestMapping
  public String profilChoice(@RequestParam(required=false) String profil) {
  	
  	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(auth.getAuthorities());
  	
  	if(profil!=null) {
	logger.info(auth.getName() + " a sélectionné le profil " + profil);
  		if("membre".equals(profil)) {
  			authorities.remove(new GrantedAuthorityImpl("ROLE_CANDIDAT"));
  		}
  		if("candidat".equals(profil)) {
  			authorities.remove(new GrantedAuthorityImpl("ROLE_MEMBRE"));
  		}
  		auth = new UsernamePasswordAuthenticationToken(auth.getPrincipal(), auth.getCredentials(), authorities);
  		SecurityContextHolder.getContext().setAuthentication(auth);
  	}
  	
  	if(auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_CANDIDAT")) && auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_MEMBRE"))) {
  		return "profilChoice";
  	} else {
  		return "index";
  	}
  }
 
开发者ID:EsupPortail,项目名称:esup-dematec,代码行数:25,代码来源:ProfilChoiceController.java

示例7: doFilter

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse res,
		FilterChain chain) throws IOException, ServletException {

	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	HttpServletRequest request = (HttpServletRequest) req;
	
	if(!request.getServletPath().startsWith("/resources/") && !"/profilChoice".equals(request.getServletPath())
		&& auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_CANDIDAT")) 
		&& auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_MEMBRE"))) {
			logger.info(auth.getName() + " est authentifié et est à la fois membre et candidat, il faut qu'il choisisse un profil.");
	        HttpServletResponse response = (HttpServletResponse) res;      
        response.sendRedirect(request.getContextPath() + "/profilChoice");
	} else {
		chain.doFilter(req, res);
	}
}
 
开发者ID:EsupPortail,项目名称:esup-dematec,代码行数:18,代码来源:CheckProfilSpringSecurityFilter.java

示例8: getAuthenticatedAppIds

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@Override
public Set<Integer> getAuthenticatedAppIds() {
	Object auth = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	if (auth != null && auth instanceof ThreadFixUserDetails) {
		if (((ThreadFixUserDetails) auth).getAuthorities().contains(
				new GrantedAuthorityImpl(Permission.READ_ACCESS.getText()))) {
			return null;
		}
		
		if (((ThreadFixUserDetails) auth).getApplicationMap() != null) {
			return ((ThreadFixUserDetails) auth).getApplicationMap().keySet();
		}
	}
	
	return null;
}
 
开发者ID:jqxin2006,项目名称:threadfixRack,代码行数:17,代码来源:PermissionServiceImpl.java

示例9: getAuthenticatedTeamIds

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
@Override
public Set<Integer> getAuthenticatedTeamIds() {
	Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	if (principal instanceof ThreadFixUserDetails) {
		ThreadFixUserDetails customDetails = ((ThreadFixUserDetails) principal);
		
		if (customDetails.getAuthorities().contains(
				new GrantedAuthorityImpl(Permission.READ_ACCESS.getText()))) {
			return null;
		}

		if (customDetails.getTeamMap() != null) {
			return customDetails.getTeamMap().keySet();
		}
	}
	
	return null;
}
 
开发者ID:jqxin2006,项目名称:threadfixRack,代码行数:19,代码来源:PermissionServiceImpl.java

示例10: _USER02

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
private UserAuth _USER02() {
	logger.debug("_USER02");
	UserAuth userAuth = new UserAuth();
	userAuth.setUsername("user02");
	userAuth.setPersonId(3);
	userAuth.setPassword("7c4a8d09ca3762af61e59520943dc26494f8941b");
	userAuth.setFirstName("Andrei");
	userAuth.setLastName("Vidreanu");
	
	//Permisiuni
	List<GrantedAuthority> authories = new ArrayList<GrantedAuthority>();
	authories.add(new GrantedAuthorityImpl("SUPER"));
	authories.add(new GrantedAuthorityImpl("DM_BASIC"));
	authories.add(new GrantedAuthorityImpl("DM_CategoryDelete"));
	authories.add(new GrantedAuthorityImpl("DM_CategoryAdd"));
	authories.add(new GrantedAuthorityImpl("DM_CategoryUpdate"));
	authories.add(new GrantedAuthorityImpl("DM_DocumentAdd"));
	authories.add(new GrantedAuthorityImpl("DM_CollectionZoneView"));
	
	userAuth.setAuthorities(authories);
	
	return userAuth;
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:24,代码来源:TSUserDetailsService.java

示例11: _USER03

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
private UserAuth _USER03() {
	logger.debug("_USER03");
	UserAuth userAuth = new UserAuth();
	userAuth.setUsername("user03");
	userAuth.setPersonId(3);
	userAuth.setPassword("7c4a8d09ca3762af61e59520943dc26494f8941b");
	userAuth.setFirstName("Ilie");
	userAuth.setLastName("Nastasescu");
	
	//Permisiuni
	List<GrantedAuthority> authories = new ArrayList<GrantedAuthority>();
	authories.add(new GrantedAuthorityImpl("AUDIT_BASIC"));
	userAuth.setAuthorities(authories);
	
	return userAuth;
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:17,代码来源:TSUserDetailsService.java

示例12: _USER04

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
private UserAuth _USER04() {
	logger.debug("_USER04");
	UserAuth userAuth = new UserAuth();
	userAuth.setUsername("user04");
	userAuth.setPersonId(4);
	userAuth.setPassword("7c4a8d09ca3762af61e59520943dc26494f8941b");
	userAuth.setFirstName("Grabriel");
	userAuth.setLastName("Contabitza");
	
	//Permisiuni
	List<GrantedAuthority> authories = new ArrayList<GrantedAuthority>();
	authories.add(new GrantedAuthorityImpl("DM_BASIC"));
	
	userAuth.setAuthorities(authories);
	
	return userAuth;
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:18,代码来源:TSUserDetailsService.java

示例13: _USER05

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
private UserAuth _USER05() {
	logger.debug("_USER05");
	UserAuth userAuth = new UserAuth();
	userAuth.setUsername("user05");
	userAuth.setPersonId(5);
	userAuth.setPassword("7c4a8d09ca3762af61e59520943dc26494f8941b");
	userAuth.setFirstName("Mircea");
	userAuth.setLastName("Badescu");

	//Permisiuni
	List<GrantedAuthority> authories = new ArrayList<GrantedAuthority>();
	authories.add(new GrantedAuthorityImpl("DM_BASIC"));
	
	userAuth.setAuthorities(authories);
	
	return userAuth;
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:18,代码来源:TSUserDetailsService.java

示例14: obtainGrantedAuthorities

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
private Set<GrantedAuthority> obtainGrantedAuthorities(AcctUser user) {
	Set<GrantedAuthority> authSet = Sets.newHashSet();
	for (AcctRole role : user.getRoleList()) {
		for (AcctAuthority authority : role.getAuthorityList()) {
			authSet.add(new GrantedAuthorityImpl(authority.getPrefixedName()));
		}
	}
	return authSet;
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:10,代码来源:MyUserDetailsServiceImpl.java

示例15: obtainGrantedAuthorities

import org.springframework.security.core.authority.GrantedAuthorityImpl; //导入依赖的package包/类
/**
 * 获得用户�?有角色的权限集合.
 */
private Set<GrantedAuthority> obtainGrantedAuthorities(AcctUser user) {
	Set<GrantedAuthority> authSet = Sets.newHashSet();
	for (AcctRole role : user.getRoleList()) {
		for (AcctAuthority authority : role.getAuthorityList()) {
			authSet.add(new GrantedAuthorityImpl(authority.getPrefixedName()));
		}
	}
	return authSet;
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:13,代码来源:UserDetailsServiceImpl.java


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