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


Java Group.addMember方法代码示例

本文整理汇总了Java中java.security.acl.Group.addMember方法的典型用法代码示例。如果您正苦于以下问题:Java Group.addMember方法的具体用法?Java Group.addMember怎么用?Java Group.addMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.acl.Group的用法示例。


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

示例1: transfer

import java.security.acl.Group; //导入方法依赖的package包/类
/**
 * Transfers Principals, private credentials, and public credentials from one Subject to another.
 * @param fromSubject the from Subject
 * @param toSubject the to Subject
 */
protected void transfer(Subject fromSubject, Subject toSubject) {
    if (toSubject != null && fromSubject != null && toSubject != fromSubject && !toSubject.equals(fromSubject)) {
        Set<Principal> toPrincipals = toSubject.getPrincipals();
        Group toRolesGroup = null;
        for (Principal fromPrincipal : fromSubject.getPrincipals()) {
            if (fromPrincipal instanceof Group && GroupPrincipal.ROLES.equals(fromPrincipal.getName())) {
                Group fromRolesGroup = (Group)fromPrincipal;
                if (toRolesGroup == null) {
                    toRolesGroup = getRolesGroup(toSubject);
                }
                if (toRolesGroup == fromRolesGroup) {
                    continue;
                }
                for (Principal fromRole : Collections.list(fromRolesGroup.members())) {
                    RolePrincipal toRole = fromRole instanceof RolePrincipal ? (RolePrincipal)fromRole : new RolePrincipal(fromRole.getName());
                    toRolesGroup.addMember(toRole);
                }
            } else {
                toPrincipals.add(fromPrincipal);
            }
        }
        toSubject.getPrivateCredentials().addAll(fromSubject.getPrivateCredentials());
        toSubject.getPublicCredentials().addAll(fromSubject.getPublicCredentials());
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:31,代码来源:DefaultSecurityProvider.java

示例2: parseGroupMembers

import java.security.acl.Group; //导入方法依赖的package包/类
/** Parse the comma delimited roles names given by value and add them to
 * group. The type of Principal created for each name is determined by
 * the createIdentity method.
 *
 * @see AbstractServerLoginModule#createIdentity(String)
 * 
 * @param group - the Group to add the roles to.
 * @param roles - the comma delimited role names.
 */ 
static void parseGroupMembers(Group group, String roles, AbstractServerLoginModule aslm)
{
   StringTokenizer tokenizer = new StringTokenizer(roles, ",");
   while (tokenizer.hasMoreTokens())
   {
      String token = tokenizer.nextToken();
      try
      {
         Principal p = aslm.createIdentity(token);
         group.addMember(p);
      }
      catch (Exception e)
      {
         PicketBoxLogger.LOGGER.debugFailureToCreatePrincipal(token, e);
      }
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:27,代码来源:Util.java

示例3: addRole

import java.security.acl.Group; //导入方法依赖的package包/类
/**
 * Adds a role to the authenticated user.
 * 
 * @param role
 *            The name of the role to add
 */
public boolean addRole(String role) {
	if (role == null || "".equals(role)) {
		return false;
	}

	if (!isLoggedIn()) {
		return false;
	} else {
		for (Group sg : getSubject().getPrincipals(Group.class)) {
			if (ROLES_GROUP.equals(sg.getName())) {
				return sg.addMember(new Role(role));
			}
		}

		SimpleGroup roleGroup = new SimpleGroup(ROLES_GROUP);
		roleGroup.addMember(new Role(role));
		getSubject().getPrincipals().add(roleGroup);
		return true;
	}
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:27,代码来源:Identity.java

示例4: fixPrincipal

import java.security.acl.Group; //导入方法依赖的package包/类
protected ContributorPrincipal fixPrincipal() {
	log.log(Level.FINEST, "Remove CAS principal and default group. Assertion name: {0}", this.assertion.getPrincipal().getName());
	this.subject.getPrincipals().remove(new AssertionPrincipal(this.assertion.getPrincipal().getName(), this.assertion));
	this.subject.getPrincipals().remove(new SimpleGroup(this.principalGroupName));


	log.log(Level.FINEST, "Add ContributorPrincipal");
	final ContributorPrincipal contributorPrincipal = new ContributorPrincipal(this.assertion.getPrincipal().getName(), this.assertion);
	this.subject.getPrincipals().add(contributorPrincipal);

	final Group principalGroup = new SimpleGroup(this.principalGroupName);
	principalGroup.addMember(contributorPrincipal);
	this.subject.getPrincipals().add(principalGroup);

	return contributorPrincipal;
}
 
开发者ID:searchisko,项目名称:searchisko,代码行数:17,代码来源:ContributorCasLoginModule.java

示例5: 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

示例6: getRoleSets

import java.security.acl.Group; //导入方法依赖的package包/类
/**
* Obtiene roles usuario (modificado para que no llame a createIdentity al crear cada role)
*/
protected Group[] getRoleSets() throws LoginException
  {
	  Principal principal = getIdentity ();
     
     if ( ! (principal instanceof MockPrincipal) )
     {
     	if (log.isTraceEnabled()) log.trace("Principal "+principal+" not a MockPrincipal");
     	return new Group[0];
     }
     
     String username = getUsername();
     
     List roles = null;
     try {
		roles = getUserRoles(username);	    	  	
  } catch (Exception e) {			
	log.error("Excepcion obteniendo roles",e);  
	throw new LoginException("Excepcion obteniendo roles");
  }
     
  Group rolesGroup = new SimpleGroup("Roles");            
     for (Iterator iterator = roles.iterator();iterator.hasNext();){
       	String roleName = (String) iterator.next();	        		       
       	rolesGroup.addMember(new SimplePrincipal(roleName));
     }
     HashMap setsMap = new HashMap();
     setsMap.put("Roles", rolesGroup);            

  // Montamos grupo "CallerPrincipal"
	Group principalGroup = new SimpleGroup("CallerPrincipal");
	principalGroup.addMember(principal);
	setsMap.put("CallerPrincipal", principalGroup);
       
       // Devolvemos respuesta
        Group roleSets[] = new Group[setsMap.size()];
        setsMap.values().toArray(roleSets);
        return roleSets;
  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:42,代码来源:MockCertificateLoginModule.java

示例7: getRoleSets

import java.security.acl.Group; //导入方法依赖的package包/类
/**
* Obtiene roles usuario (modificado para que no llame a createIdentity al crear cada role)
*/
protected Group[] getRoleSets() throws LoginException
  {
	  Principal principal = getIdentity ();
     
     if ( ! (principal instanceof MockPrincipal) )
     {
     	if (log.isTraceEnabled()) log.trace("Principal "+principal+" not a MockPrincipal");
     	return new Group[0];
     }
     
     String username = getUsername();
     
     List roles = null;
     try {
		roles = getUserRoles(username);
  } catch (Exception e) {			
	log.error("Excepcion obteniendo roles",e);  
	throw new LoginException("Excepcion obteniendo roles");
  }
     
  Group rolesGroup = new SimpleGroup("Roles");            
     for (Iterator iterator = roles.iterator();iterator.hasNext();){
       	String roleName = (String) iterator.next();	        		       
       	rolesGroup.addMember(new SimplePrincipal(roleName));
     }
     HashMap setsMap = new HashMap();
     setsMap.put("Roles", rolesGroup);            

  // Montamos grupo "CallerPrincipal"
	Group principalGroup = new SimpleGroup("CallerPrincipal");
	principalGroup.addMember(principal);
	setsMap.put("CallerPrincipal", principalGroup);
       
       // Devolvemos respuesta
        Group roleSets[] = new Group[setsMap.size()];
        setsMap.values().toArray(roleSets);
        return roleSets;
  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:42,代码来源:MockDatabaseLoginModule.java

示例8: createTestSubject

import java.security.acl.Group; //导入方法依赖的package包/类
private Subject createTestSubject() {
  Subject testSubject = new Subject();
  UserPrincipal p = new UserPrincipal("demo");
  testSubject.getPrincipals().add(p);
  p.putCustomProperty(UserPrincipal.LANGUAGE_PROPERTY, "en");
  Group rolesGroup = new SimpleGroup(SecurityHelper.ROLES_GROUP_NAME);
  rolesGroup.addMember(new SimplePrincipal("administrator"));
  testSubject.getPrincipals().add(rolesGroup);
  return testSubject;
}
 
开发者ID:jspresso,项目名称:hrsample-ce,代码行数:11,代码来源:FrontTestStartup.java

示例9: 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

示例10: addPrincipals

import java.security.acl.Group; //导入方法依赖的package包/类
/**
 * Add principals passed via an enumeration into a group
 * @param grp
 * @param en
 * @return
 */
public static Group addPrincipals(Group grp, Enumeration<? extends Principal> en)
{
   while(en.hasMoreElements())
      grp.addMember(en.nextElement()); 
   return grp;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:13,代码来源:MappingProviderUtil.java

示例11: appendRoles

import java.security.acl.Group; //导入方法依赖的package包/类
private void appendRoles( Group group )
{
   if( ! group.getName().equals( SecurityConstants.ROLES_IDENTIFIER ) )
     return;
     
   if(additionalRoles != null && !additionalRoles.isEmpty())
   {   
      StringTokenizer st = new StringTokenizer( additionalRoles , "," );
      while(st.hasMoreTokens())
      {
         group.addMember( new SimplePrincipal( st.nextToken().trim() ) ); 
      }
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:15,代码来源:JBossTimeBasedOTPLoginModule.java

示例12: mergeGroups

import java.security.acl.Group; //导入方法依赖的package包/类
private Group mergeGroups(Group a, Group b)
{
   Group newGroup = b;
   if(a != null)
   {
      Enumeration<? extends Principal> en = a.members();
      while(en.hasMoreElements())
      {
         newGroup.addMember(en.nextElement());
      } 
   } 
   return newGroup; 
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:14,代码来源:JBossSecurityContext.java

示例13: asGroup

import java.security.acl.Group; //导入方法依赖的package包/类
public Group asGroup()
{
   try
   {
      Group gp = IdentityFactory.createGroup("Roles");
      gp.addMember(IdentityFactory.createPrincipal(role.getRoleName()));
      return gp;
   }
   catch (Exception e)
   {
      throw new RuntimeException(e);
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:14,代码来源:SimpleIdentity.java

示例14: getRoleSets

import java.security.acl.Group; //导入方法依赖的package包/类
@Override
protected Group[] getRoleSets() throws LoginException {
    Group roles = new SimpleGroup("Roles");
    Group callerPrincipal = new SimpleGroup("CallerPrincipal");
    Group[] groups = { roles, callerPrincipal };
    callerPrincipal.addMember(getIdentity());
    return groups;
}
 
开发者ID:red-fox-mulder,项目名称:eap-6.1-quickstarts,代码行数:9,代码来源:DelegationLoginModule.java

示例15: getRoleSets

import java.security.acl.Group; //导入方法依赖的package包/类
@Override
protected Group[] getRoleSets() throws LoginException
{

   Group roles = new SimpleGroup("Roles");
   Group callerPrincipal = new SimpleGroup("CallerPrincipal");
   Group[] groups =
   {roles, callerPrincipal};
   callerPrincipal.addMember(getIdentity());
   return groups;
}
 
开发者ID:wildfly-security,项目名称:jboss-negotiation,代码行数:12,代码来源:SPNEGOLoginModule.java


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