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


Java Group.isMember方法代碼示例

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


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

示例1: processRoles

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * Process the group with the roles that are mapped in the 
 * properies file
 * @param group Group that needs to be processed
 * @param props Properties file
 */
private void processRoles(Group group,Properties props) //throws Exception
{
   Enumeration<?> enumer = props.propertyNames();
   while(enumer.hasMoreElements())
   {
      String roleKey = (String)enumer.nextElement();
      String comma_separated_roles = props.getProperty(roleKey);
      try {
          Principal pIdentity = createIdentity(roleKey);
          if (group != null)
          {
              if(group.isMember(pIdentity))
                  Util.parseGroupMembers(group,comma_separated_roles,this);
              if(REPLACE_ROLE)
                  group.removeMember(pIdentity);
          }
      }
      catch(Exception e) {
          PicketBoxLogger.LOGGER.debugFailureToCreatePrincipal(roleKey, e);
      }
   }
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:29,代碼來源:RoleMappingLoginModule.java

示例2: authorize

import java.security.acl.Group; //導入方法依賴的package包/類
@Override
protected void authorize(LoginContext context) throws LoginException {
    HashSet<String> required = new HashSet<>(requiredRoles);
    Set<Group> groups = context.getSubject().getPrincipals(Group.class);
    if (groups != null) {
        for (Group group : groups) {
            if ("Roles".equals(group.getName())) {
                for (String role : requiredRoles) {
                    if (group.isMember(new SimplePrincipal(role))) {
                        required.remove(role);
                    }
                }
            }
        }
    }
    if (!required.isEmpty())
        throw new LoginException("User does not have required roles: " + required);
}
 
開發者ID:wildfly-extras,項目名稱:wildfly-camel,代碼行數:19,代碼來源:DomainAuthorizationPolicy.java

示例3: isMemberRecurse

import java.security.acl.Group; //導入方法依賴的package包/類
private boolean isMemberRecurse(Principal principal, Vector<Principal> vector)
{
    for(Enumeration<Principal> enumeration = members(); enumeration.hasMoreElements();)
    {
        boolean flag = false;
        Principal principal1 = (Principal)enumeration.nextElement();
        if(principal1.equals(principal))
            return true;
        if(principal1 instanceof SecurityGroup)
        {
           SecurityGroup groupimpl = (SecurityGroup)principal1;
            vector.addElement(this);
            if(!vector.contains(groupimpl))
                flag = groupimpl.isMemberRecurse(principal, vector);
        } 
        else
        if(principal1 instanceof Group)
        {
            Group group1 = (Group)principal1;
            if(!vector.contains(group1))
                flag = group1.isMember(principal);
        }

        if(flag)
            return flag;
    }

    return false;
}
 
開發者ID:nyla-solutions,項目名稱:nyla,代碼行數:30,代碼來源:SecurityGroup.java

示例4: hasRole

import java.security.acl.Group; //導入方法依賴的package包/類
public boolean hasRole(String role) {
	tryLogin();

	for (Group sg : getSubject().getPrincipals(Group.class)) {
		if (ROLES_GROUP.equals(sg.getName())) {
			return sg.isMember(new Role(role));
		}
	}
	return false;
}
 
開發者ID:GluuFederation,項目名稱:oxCore,代碼行數:11,代碼來源:Identity.java

示例5: isSubjectGranted

import java.security.acl.Group; //導入方法依賴的package包/類
/**
 * Tests whether the passed subject has sufficient roles.
 *
 * @param subject
 *          the subject to test.
 * @param securable
 *          the securable to test.
 * @return true if the subject has sufficient privilege.
 */
public static boolean isSubjectGranted(Subject subject, ISecurable securable) {
  if (securable == null) {
    return true;
  }
  Collection<String> grantedRoles = securable.getGrantedRoles();
  if (grantedRoles == null) {
    return true;
  }
  if (subject == null) {
    return false;
  }

  grantedRoles = new HashSet<>(grantedRoles);
  Collection<String> ungrantedRoles = new HashSet<>();
  for (String role : new HashSet<>(grantedRoles)) {
    if (role.startsWith("!")) {
      grantedRoles.remove(role);
      ungrantedRoles.add(role.substring(1));
    }
  }

  Group subjectRoles = getRolesGroup(subject);
  if (subjectRoles != null) {
    boolean granted = false;
    if (!grantedRoles.isEmpty()) {
      for (String grantedRole : grantedRoles) {
        if (subjectRoles.isMember(new SimplePrincipal(grantedRole))) {
          granted = true;
          break;
        }
      }
    }
    if (!granted && !ungrantedRoles.isEmpty()) {
      granted = true;
      for (String ungrantedRole : ungrantedRoles) {
        if (subjectRoles.isMember(new SimplePrincipal(ungrantedRole))) {
          granted = false;
          break;
        }
      }
    }
    return granted;
  }
  return false;
}
 
開發者ID:jspresso,項目名稱:jspresso-ce,代碼行數:55,代碼來源:SecurityHelper.java


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