當前位置: 首頁>>代碼示例>>Java>>正文


Java Group.members方法代碼示例

本文整理匯總了Java中java.security.acl.Group.members方法的典型用法代碼示例。如果您正苦於以下問題:Java Group.members方法的具體用法?Java Group.members怎麽用?Java Group.members使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.acl.Group的用法示例。


在下文中一共展示了Group.members方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRoles

import java.security.acl.Group; //導入方法依賴的package包/類
public static String[] getRoles(Subject subject, String[] defalt) {
	ArrayList<String> roles = new ArrayList<String>();
	Set<Group> principals = subject.getPrincipals(Group.class);
	if ((principals != null) && (principals.size() > 0)) {
		for (Group group : principals) {
			if (group.getName().equalsIgnoreCase("roles")) { //$NON-NLS-1$
				Enumeration<? extends Principal> members = group.members();
				while(members.hasMoreElements()) {
					Principal member = members.nextElement();
					roles.add(member.getName());
				}
			}
		}
		return roles.toArray(new String[roles.size()]);
	}
	return defalt;
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:18,代碼來源:ConnectionContext.java

示例2: getUserRoles

import java.security.acl.Group; //導入方法依賴的package包/類
private Set<String> getUserRoles() {
	if (getSubject() == null) {
		return Collections.emptySet();
	}
	
	Set<String> roles = new HashSet<String>();
	Set<Principal> principals = getSubject().getPrincipals();
	for(Principal p: principals) {
		// this JBoss specific, but no code level dependencies
		if ((p instanceof Group) && p.getName().equals("Roles")){ //$NON-NLS-1$
			Group g = (Group)p;
			Enumeration<? extends Principal> rolesPrinciples = g.members();
			while(rolesPrinciples.hasMoreElements()) {
				roles.add(rolesPrinciples.nextElement().getName());	
			}
		}
	}
	return roles;
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:20,代碼來源:DQPWorkContext.java

示例3: getCallerPrincipal

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public Principal getCallerPrincipal(String securityDomain) {
    Principal callerPrincipal = null;
    Subject subject = getSubject(securityDomain, false);
    if (subject != null) {
        outerLoop : for (Principal principal : subject.getPrincipals()) {
            if (principal instanceof Group) {
                Group group = (Group)principal;
                if (group.getName().equalsIgnoreCase(CALLER_PRINCIPAL)) {
                    Enumeration<? extends Principal> members = group.members();
                    while (members.hasMoreElements()) {
                        callerPrincipal = members.nextElement();
                        break outerLoop;
                    }
                }
            } else if (callerPrincipal == null && principal != null) {
                // the second case (the simple name comparison) is here to support Karaf
                if (principal instanceof UserPrincipal || principal.getClass().getSimpleName().equals("UserPrincipal")) {
                    callerPrincipal = principal;
                }
            }
        }
    }
    return callerPrincipal;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:29,代碼來源:DefaultSecurityContext.java

示例4: isCallerInRole

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public boolean isCallerInRole(String roleName, String securityDomain) {
    Subject subject = getSubject(securityDomain, false);
    if (subject != null) {
        for (Principal principal : subject.getPrincipals()) {
            if (principal instanceof Group) {
                Group group = (Group)principal;
                if (group.getName().equalsIgnoreCase(ROLES)) {
                    Enumeration<? extends Principal> roles = group.members();
                    while (roles.hasMoreElements()) {
                        Principal role = roles.nextElement();
                        if (role.getName().equals(roleName)) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:25,代碼來源:DefaultSecurityContext.java

示例5: getRoleNames

import java.security.acl.Group; //導入方法依賴的package包/類
public String[] getRoleNames(String roleGroup)
{
   Group group = roleGroups.get(roleGroup);
   String[] names = {};
   if( group != null )
   {
      ArrayList<String> tmp = new ArrayList<String>();
      Enumeration<? extends Principal> iter = group.members();
      while( iter.hasMoreElements() )
      {
         Principal p = iter.nextElement();
         tmp.add(p.getName());
      }
      names = new String[tmp.size()];
      tmp.toArray(names);
   }
   return names;
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:19,代碼來源:Users.java

示例6: authorize

import java.security.acl.Group; //導入方法依賴的package包/類
public int authorize(Resource resource)
{ 
   Set<Principal> principals = subject.getPrincipals();
   for(Principal p: principals)
   {
      if(p instanceof Group)
      {
         Group group = (Group) p;
         if(group.getName().equalsIgnoreCase("Roles"))
         {
            Enumeration<? extends Principal> roles = group.members();
            while(roles.hasMoreElements())
            {
               Principal role = roles.nextElement();
               if(rolesSet.contains(role.getName()))
                  return AuthorizationContext.PERMIT;
            } 
         }
      }
   }
   return AuthorizationContext.DENY;
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:23,代碼來源:PicketBoxAuthorizationModule.java

示例7: commit

import java.security.acl.Group; //導入方法依賴的package包/類
/**
    * Method to commit the authentication process (phase 2).
    */
   @Override
   public boolean commit() throws LoginException {
if (loginOK == false) {
    return false;
}

/*
 * If the login method completed successfully as indicated by
 * loginOK == true, this method adds the identity value to the subject's principals set. It also adds the
 * members of
 * each Group returned by getRoleSets() to the subject's principals Set.
 */
Set<Principal> principals = subject.getPrincipals();
principals.add(identity);
for (Group group : getRoleSets()) {
    String name = group.getName();
    Group subjectGroup = createGroup(name, principals);
    // Copy the group members to the Subject group
    Enumeration<? extends Principal> members = group.members();
    while (members.hasMoreElements()) {
	Principal role = members.nextElement();
	subjectGroup.addMember(role);
    }
}

UniversalLoginModule.log.info("User logged in: " + getUserName());
return true;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:UniversalLoginModule.java

示例8: getRoles

import java.security.acl.Group; //導入方法依賴的package包/類
private Set<String> getRoles() {
	Set<String> roles = new HashSet<String>();
	
	Set<Principal> principals = this.subject.getPrincipals();
	for(Principal p: principals) {
		if ((p instanceof Group) && p.getName().equals("Roles")){ //$NON-NLS-1$
			Group g = (Group)p;
			Enumeration<? extends Principal> rolesPrinciples = g.members();
			while(rolesPrinciples.hasMoreElements()) {
				roles.add(rolesPrinciples.nextElement().getName());	
			}
		}
	}
	return roles;
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:16,代碼來源:RoleBasedCredentialMapIdentityLoginModule.java

示例9: getRoles

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * Extracts the role names contained in this JAAS subject.
 *
 * @param subject
 *          the subject to extract the roles for.
 * @return the roles list.
 */
public static List<String> getRoles(Subject subject) {
  List<String> roles = new ArrayList<>();
  Group subjectRoles = getRolesGroup(subject);
  if (subjectRoles != null) {
    for (Enumeration<? extends Principal> rolesEnum = subjectRoles.members(); rolesEnum
        .hasMoreElements();) {
      roles.add(rolesEnum.nextElement().getName());
    }
  }
  return roles;
}
 
開發者ID:jspresso,項目名稱:jspresso-ce,代碼行數:19,代碼來源:SecurityHelper.java

示例10: commit

import java.security.acl.Group; //導入方法依賴的package包/類
/** 
    * Method to commit the authentication process (phase 2). If the login
    * method completed successfully as indicated by loginOk == true, this
    * method adds the getIdentity() value to the subject getPrincipals() Set.
    * It also adds the members of each Group returned by getRoleSets()
    * to the subject getPrincipals() Set.
    * @return true always.
    */
@Override
public boolean commit() throws LoginException {
	Set<Principal> principals = this.subject.getPrincipals();
	if (this.identity != null) {
		principals.add(this.identity);
	}
	if (this.usernameIdentity != null) {
		principals.add(this.usernameIdentity);
	}
	if (this.roles != null) {
		for (Group group : this.roles) {

			String name = group.getName();
			Group subjectGroup = createGroup(name, principals);
			
			if (subjectGroup instanceof NestableGroup) {
				SimpleGroup sg = new SimpleGroup("Roles");
		        subjectGroup.addMember(sg);
		        subjectGroup = sg;
			}
			
			Enumeration<? extends Principal> members = group.members();
			while (members.hasMoreElements()) {
				Principal role = (Principal) members.nextElement();
				subjectGroup.addMember(role);
			}
		}
	}
	return true;	
}
 
開發者ID:robsonsmartins,項目名稱:fiap-mba-java-projects,代碼行數:39,代碼來源:SICidDBLoginModule.java

示例11: getCallerPrincipal

import java.security.acl.Group; //導入方法依賴的package包/類
protected Principal getCallerPrincipal(Map<String, Object> map)
{
   Principal principal = (Principal) map.get(SecurityConstants.PRINCIPAL_IDENTIFIER);
   Principal callerPrincipal = null;
   if (principal == null)
   {
      @SuppressWarnings("unchecked")
      Set<Principal> principals = (Set<Principal>) map.get(SecurityConstants.PRINCIPALS_SET_IDENTIFIER);
      if (principals != null && !principals.isEmpty())
      {
         for (Principal p : principals) {
            if (!(p instanceof Group) && principal == null) {
               principal = p;
            }
            if (p instanceof Group) {
               Group g = Group.class.cast(p);
               if (g.getName().equals(SecurityConstants.CALLER_PRINCIPAL_GROUP) && callerPrincipal == null) {
                  Enumeration<? extends Principal> e = g.members();
                  if (e.hasMoreElements())
                     callerPrincipal = e.nextElement();
               }
            }
         }
      }
   }
   return callerPrincipal == null ? principal : callerPrincipal;
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:28,代碼來源:AbstractRolesMappingProvider.java

示例12: removePrincipals

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * Remove all the principals from the group
 * @param grp
 * @return
 */
public static Group removePrincipals(Group grp)
{
   HashSet<Principal> removeset = new HashSet<Principal>();
   Enumeration<? extends Principal> en = grp.members();
   while(en.hasMoreElements())
   {
      removeset.add(en.nextElement());
   }
   
   for(Principal p:removeset)
      grp.removeMember(p);
   return grp;
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:19,代碼來源:MappingProviderUtil.java

示例13: getPrincipalClass

import java.security.acl.Group; //導入方法依賴的package包/類
private static Class<?> getPrincipalClass(Group roles)
{
   //Assume that the roles all belong to the same principal class 
   Class<?> principalClass = SimplePrincipal.class;
   Enumeration<? extends Principal> en = roles.members();
   if(en.hasMoreElements())
   {
      principalClass = roles.members().nextElement().getClass(); 
   }
   return principalClass;
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:12,代碼來源:MappingProviderUtil.java

示例14: IndexEnumeration

import java.security.acl.Group; //導入方法依賴的package包/類
IndexEnumeration()
{
    if( rolesStack.size() > 0 )
    {
        Group grp = (Group) rolesStack.get(0);
        iter = grp.members();
    }
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:9,代碼來源:NestableGroup.java

示例15: copyGroups

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * Copy the principals from the second group into the first.
 * If the first group is null and the second group is not, the
 * first group will be made equal to the second group
 * @param source
 * @param toCopy
 */
private RoleGroup copyGroups(RoleGroup source, Group toCopy)
{
   if(toCopy == null)
      return source;
   if(source == null && toCopy != null) 
      source = this.getEmptyRoleGroup();
   Enumeration<? extends Principal> en = toCopy.members();
   while(en.hasMoreElements())
   {
      source.addRole(new SimpleRole(en.nextElement().getName())); 
   }
    
   return source;
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:22,代碼來源:JBossAuthorizationManager.java


注:本文中的java.security.acl.Group.members方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。