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


Java RoleGroup类代码示例

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


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

示例1: testAuthenticationAndMappingAnnotation

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
@Test
public void testAuthenticationAndMappingAnnotation() throws Exception
{
   AuthPlusMappingAnnotatedPOJO pojo = new AuthPlusMappingAnnotatedPOJO();
   
   PicketBoxProcessor processor = new PicketBoxProcessor(); 
   processor.setSecurityInfo("anil", "pass");
   processor.process(pojo);
   
   Principal anil = new SimplePrincipal("anil");
   assertEquals("Principal == anil", anil, processor.getCallerPrincipal());
   Subject callerSubject = processor.getCallerSubject();
   assertNotNull("Subject is not null", callerSubject);
   assertTrue("Subject contains principal anil", callerSubject.getPrincipals().contains(anil));
   RoleGroup callerRoles = processor.getCallerRoles();
   assertTrue("InternalUser is a role", callerRoles.containsRole(new SimpleRole("InternalUser")));
   assertTrue("AuthorizedUser is a role", callerRoles.containsRole(new SimpleRole("AuthorizedUser")));
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:19,代码来源:PicketBoxProcessorUnitTestCase.java

示例2: addRole

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
private void addRole(String roleName, RoleGroup roleGroup)
{
   if (roleName != null)
   {
      try
      {
         SimpleRole role = new SimpleRole(roleName);
         PicketBoxLogger.LOGGER.traceAssignUserToRole(roleName);
         roleGroup.addRole(role);
      }
      catch (Exception e)
      {
         PicketBoxLogger.LOGGER.debugFailureToCreatePrincipal(roleName, e);
      }
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:17,代码来源:LdapRolesMappingProvider.java

示例3: addRolesToGroup

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
/** 
 * Create the set of roles the user belongs to by parsing the roles.properties
 * data for username=role1,role2,...
 * 
 * @param username - name of user
 * @param roleGroup - group containing the user's roles
 * @param roles - the Properties containing the user=roles mappings
 * @return Group[] containing the sets of roles
 */
static void addRolesToGroup(String username, RoleGroup roleGroup, Properties roles)
{
   String[] roleNames = null;
   if (roles.containsKey(username))
   {
      String value = roles.getProperty(username);
      PicketBoxLogger.LOGGER.traceAdditionOfRoleToGroup(value, roleGroup.getRoleName());
      roleNames = parseRoles(value);
   }
   if (roleNames != null)
   {
      for (int i = 0; i < roleNames.length; i++)
      {
         roleGroup.addRole(new SimpleRole(roleNames[i]));
      }
   }
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:27,代码来源:Util.java

示例4: testAPI

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
@Test
public void testAPI() throws Exception
{
   SecurityMappingAnnotationRolePOJO pojo = new SecurityMappingAnnotationRolePOJO();
   
   PicketBoxProcessor processor = new PicketBoxProcessor(); 
   processor.setSecurityInfo("anil", "pass");
   processor.process(pojo);
   
   Principal anil = new SimplePrincipal("anil");
   assertEquals("Principal == anil", anil, processor.getCallerPrincipal());
   Subject callerSubject = processor.getCallerSubject();
   assertNotNull("Subject is not null", callerSubject);
   assertTrue("Subject contains principal anil", callerSubject.getPrincipals().contains(anil));
   RoleGroup callerRoles = processor.getCallerRoles();
   assertTrue("InternalUser is a role", callerRoles.containsRole(new SimpleRole("InternalUser")));
   assertTrue("AuthorizedUser is a role", callerRoles.containsRole(new SimpleRole("AuthorizedUser")));
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:19,代码来源:PicketBoxProcessorUnitTestCase.java

示例5: performMapping

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
public void performMapping(Map<String, Object> contextMap, RoleGroup mappedObject)
{
   if (contextMap == null || contextMap.isEmpty())
      throw PicketBoxMessages.MESSAGES.invalidNullArgument("contextMap");

   //Obtain the principal to roles mapping
   Principal principal = getCallerPrincipal(contextMap);

   if (principal != null && rolesQuery != null)
   {
      String username = principal.getName();
      Util.addRolesToGroup(username, mappedObject, dsJndiName, rolesQuery, suspendResume, tm);
      result.setMappedObject(mappedObject);
   }

}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:17,代码来源:DatabaseRolesMappingProvider.java

示例6: mapGroup

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
private RoleGroup mapGroup(Principal principal, Map<String, Set<String>> principalRolesMap,
      RoleGroup mappedObject)
{
   Set<String> roleset = (Set<String>)principalRolesMap.get(principal.getName());
   if(roleset != null)
   {
      RoleGroup newRoles = new SimpleRoleGroup(SecurityConstants.ROLES_IDENTIFIER);
      
      if(roleset != null)
      {
         for(String r:roleset)
         {
            newRoles.addRole(new SimpleRole(r));            
         }
      }
      
      mappedObject.clearRoles();
      mappedObject.addAll(newRoles.getRoles()); 
   } 
   return mappedObject;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:22,代码来源:DeploymentRolesMappingProvider.java

示例7: getPrincipalSetFromRole

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
private Set<Principal> getPrincipalSetFromRole(Role role)
{
   Set<Principal> principalsSet = new HashSet<Principal>();
   if(role instanceof RoleGroup)
   {
      RoleGroup rg = (RoleGroup) role;
      Collection<Role> rolesList = rg.getRoles();
      for(Role r: rolesList)
      {
        principalsSet.add(new SimplePrincipal(r.getRoleName()));      
      }
   }
   else
      principalsSet.add(new SimplePrincipal(role.getRoleName()));
   return principalsSet;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:17,代码来源:AbstractJACCModuleDelegate.java

示例8: initialize

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
/**
 * @see AuthorizationModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map, org.jboss.security.identity.RoleGroup)
 */
public void initialize(Subject subject, CallbackHandler handler, Map<String,Object> sharedState,
      Map<String,Object> options, RoleGroup subjectRole)
{
   this.subject = subject;
   this.handler = handler;
   this.sharedState = sharedState;
   this.options = options;
   //Check if there is a delegate map via options
   if(options != null)
   {
      String commaSeparatedDelegates = (String)options.get("delegateMap");
      if(commaSeparatedDelegates != null && commaSeparatedDelegates.length() > 0)
         populateDelegateMap(commaSeparatedDelegates);
   } 
   this.role = subjectRole;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:20,代码来源:AbstractAuthorizationModule.java

示例9: process

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
/**
 * Process the ejb request
 * @param callerRoles
 * @return
 */ 
private int process(RoleGroup callerRoles) 
{ 
   int result = AuthorizationContext.DENY;
   EJBXACMLUtil util = new EJBXACMLUtil();
   try
   {
      RequestContext requestCtx = util.createXACMLRequest(this.ejbName,
            this.ejbMethod, this.ejbPrincipal, callerRoles);
      
      PolicyDecisionPoint pdp = util.getPDP(policyRegistration, this.policyContextID); 
      if(pdp == null)
         throw PicketBoxMessages.MESSAGES.invalidNullProperty("PDP");

      ResponseContext response = pdp.evaluate(requestCtx);
      result = response.getDecision() == XACMLConstants.DECISION_PERMIT ? 
            AuthorizationContext.PERMIT : AuthorizationContext.DENY;
   }
   catch(Exception e)
   {
      PicketBoxLogger.LOGGER.debugIgnoredException(e);
      result = AuthorizationContext.DENY;
   }  
   return result;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:30,代码来源:EJBXACMLPolicyModuleDelegate.java

示例10: createXACMLRequest

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
/**
  * 
  * @param ejbName
  * @param methodName
  * @param principal
  * @param callerRoles
  * @return
  * @throws Exception
  */
 public RequestContext createXACMLRequest(String ejbName, String methodName,
       Principal principal, RoleGroup callerRoles) throws Exception
 {  
    String action = methodName;
    //Create an action type
    ActionType actionType = getActionType( action );

    RequestContext requestCtx = this.getRequestContext(ejbName, actionType, principal, callerRoles);

    if(PicketBoxLogger.LOGGER.isDebugEnabled())
    {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();

       requestCtx.marshall(baos);
       PicketBoxLogger.LOGGER.debug(new String(baos.toByteArray()));
    }
    return requestCtx;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:28,代码来源:EJBXACMLUtil.java

示例11: getRequestContext

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
private RequestContext getRequestContext( String ejbName, ActionType actionType,
      Principal principal, RoleGroup callerRoles ) throws IOException
{
   if(principal == null)
      throw PicketBoxMessages.MESSAGES.invalidNullArgument("principal");

   RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx();

   //Create a subject type
   SubjectType subject = this.getSubjectType( principal, callerRoles ); 

   //Create a resource type
   ResourceType resourceType = getResourceType( ejbName ); 

   //Create an Environment Type (Optional)
   EnvironmentType environmentType = getEnvironmentType();

   //Create a Request Type
   RequestType requestType = getRequestType( subject, resourceType, actionType, environmentType );

   requestCtx.setRequest( requestType );
   
   return requestCtx; 
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:25,代码来源:EJBXACMLUtil.java

示例12: getSubjectType

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
private SubjectType getSubjectType( Principal principal, RoleGroup callerRoles )
{
   String subjectID_NS =  XACMLConstants.ATTRIBUTEID_SUBJECT_ID;
   String roleID_NS = XACMLConstants.ATTRIBUTEID_ROLE;
   String principalName = principal.getName();
   
   //Create a subject type
   SubjectType subject = new SubjectType();
   AttributeType attribute = RequestAttributeFactory.createStringAttributeType( subjectID_NS, "jboss.org", principalName );

   subject.getAttribute().add( attribute );

   Collection<Role> rolesList = callerRoles.getRoles();
   if(rolesList != null)
   {
      for(Role role:rolesList)
      {
         String roleName = role.getRoleName(); 
         AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType( roleID_NS , "jboss.org", roleName );
         subject.getAttribute().add(attSubjectID);
      }
   }  
   return subject;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:25,代码来源:EJBXACMLUtil.java

示例13: isValid

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
/** Does the current Subject have a role(a Principal) that equates to one
 of the role names. This method obtains the Group named 'Roles' from
 the principal set of the currently authenticated Subject as determined
 by the SecurityAssociation.getSubject() method and then creates a
 SimplePrincipal for each name in roleNames. If the role is a member of the
 Roles group, then the user has the role. This requires that the caller
 establish the correct SecurityAssociation subject prior to calling this
 method. In the past this was done as a side-effect of an isValid() call,
 but this is no longer the case.
 
 @param principal - ignored. The current authenticated Subject determines
 the active user and assigned user roles.
 @param rolePrincipals - a Set of Principals for the roles to check.
 
 @see java.security.acl.Group;
 @see Subject#getPrincipals()
 */
public boolean doesUserHaveRole(Principal principal, Set<Principal> rolePrincipals)
{
   boolean hasRole = false;
   RoleGroup roles = this.getCurrentRoles(principal);
   if (PicketBoxLogger.LOGGER.isTraceEnabled())
   {
      PicketBoxLogger.LOGGER.traceBeginDoesUserHaveRole(principal, roles != null ? roles.toString() : "");
   }
   if(roles != null)
   {
      Iterator<Principal> iter = rolePrincipals.iterator();
      while( hasRole == false && iter.hasNext() )
      {
         Principal role = iter.next();
         hasRole = doesRoleGroupHaveRole(role, roles);
      }
      PicketBoxLogger.LOGGER.traceEndDoesUserHaveRole(hasRole);
   }
   return hasRole;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:38,代码来源:JBossAuthorizationManager.java

示例14: doesRoleGroupHaveRole

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
/** Check that the indicated application domain role is a member of the
 user's assigned roles. This handles the special AnybodyPrincipal and
 NobodyPrincipal independent of the Group implementation.
 
 @param role , the application domain role required for access
 @param userRoles , the set of roles assigned to the user
 @return true if role is in userRoles or an AnybodyPrincipal instance, false
 if role is a NobodyPrincipal or no a member of userRoles
 */
protected boolean doesRoleGroupHaveRole(Principal role, RoleGroup userRoles)
{
   // First check that role is not a NobodyPrincipal
   if (role instanceof NobodyPrincipal)
      return false;
   
   // Check for inclusion in the user's role set
   boolean isMember = userRoles.containsRole(new SimpleRole(role.getName())); 
   if (isMember == false)
   {   // Check the AnybodyPrincipal special cases
      isMember = (role instanceof AnybodyPrincipal);
   }
   
   return isMember;
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:25,代码来源:JBossAuthorizationManager.java

示例15: testAuthenticationAndAuthorization

import org.jboss.security.identity.RoleGroup; //导入依赖的package包/类
@Test
public void testAuthenticationAndAuthorization() throws Exception
{
   AuthAuthorizationAnnotatedPOJO pojo = new AuthAuthorizationAnnotatedPOJO();
   
   PicketBoxProcessor processor = new PicketBoxProcessor(); 
   processor.setSecurityInfo("anil", "pass");
   processor.process(pojo);
   
   Principal anil = new SimplePrincipal("anil");
   assertEquals("Principal == anil", anil, processor.getCallerPrincipal());
   Subject callerSubject = processor.getCallerSubject();
   assertNotNull("Subject is not null", callerSubject);
   assertTrue("Subject contains principal anil", callerSubject.getPrincipals().contains(anil));
   RoleGroup callerRoles = processor.getCallerRoles();
   assertNotNull("Roles are not null", callerRoles);
}
 
开发者ID:picketbox,项目名称:picketbox,代码行数:18,代码来源:PicketBoxProcessorUnitTestCase.java


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