Java Code Examples for org.jboss.security.SecurityConstants#ROLES_IDENTIFIER

The following examples show how to use org.jboss.security.SecurityConstants#ROLES_IDENTIFIER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentRolesMappingProvider.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: DeploymentRoleToRolesMappingProvider.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtains the deployment roles via the context map and applies it
 * on the mappedObject
 * @see MappingProvider#performMapping(Map, Object)
 */ 
@SuppressWarnings("unchecked")
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 = (Principal) contextMap.get(SecurityConstants.PRINCIPAL_IDENTIFIER);
   Map<String,Set<String>> roleToRolesMap = (Map<String,Set<String>>)contextMap.get(SecurityConstants.DEPLOYMENT_PRINCIPAL_ROLES_MAP);
   Set<Principal> subjectPrincipals = (Set<Principal>) contextMap.get(SecurityConstants.PRINCIPALS_SET_IDENTIFIER);      
   PicketBoxLogger.LOGGER.debugMappingProviderOptions(principal, roleToRolesMap, subjectPrincipals);
   
   
   if(roleToRolesMap == null || roleToRolesMap.isEmpty())
   {
      result.setMappedObject(mappedObject);
      return ; // No Mapping
   }

   RoleGroup newRoles = new SimpleRoleGroup(SecurityConstants.ROLES_IDENTIFIER);
   
   RoleGroup assignedRoles = (SimpleRoleGroup)contextMap.get(SecurityConstants.ROLES_IDENTIFIER);

   if(assignedRoles != null){      
      for (Role r: assignedRoles.getRoles()) {

         boolean mappedRoleIncluded = false;
         for (String mappedRole: roleToRolesMap.keySet()) {
            if (roleToRolesMap.get(mappedRole).contains(r.getRoleName())) {
               newRoles.addRole(new SimpleRole(mappedRole));
               mappedRoleIncluded = true;
            }
         }
      
         if (!mappedRoleIncluded) {
            newRoles.addRole(r);
         }
      
      }
   }

   if(assignedRoles != null){
      mappedObject.clearRoles();
      mappedObject.addAll(newRoles.getRoles());
   } 
   result.setMappedObject(mappedObject);
   
}
 
Example 3
Source File: JBossAuthorizationManager.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private RoleGroup getEmptyRoleGroup()
{
   return new SimpleRoleGroup(SecurityConstants.ROLES_IDENTIFIER);
}