本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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 );
}
示例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";
}
示例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";
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}