Coverage report

  %line %branch
org.apache.jetspeed.security.spi.impl.DefaultSecurityMappingHandler
0% 
0% 

 1  
 /* 
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.security.spi.impl;
 18  
 
 19  
 import java.security.Principal;
 20  
 import java.util.Collection;
 21  
 import java.util.HashSet;
 22  
 import java.util.Iterator;
 23  
 import java.util.Set;
 24  
 import java.util.prefs.Preferences;
 25  
 
 26  
 import org.apache.jetspeed.security.HierarchyResolver;
 27  
 import org.apache.jetspeed.security.SecurityException;
 28  
 import org.apache.jetspeed.security.impl.GeneralizationHierarchyResolver;
 29  
 import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
 30  
 import org.apache.jetspeed.security.impl.RolePrincipalImpl;
 31  
 import org.apache.jetspeed.security.impl.UserPrincipalImpl;
 32  
 import org.apache.jetspeed.security.om.InternalGroupPrincipal;
 33  
 import org.apache.jetspeed.security.om.InternalRolePrincipal;
 34  
 import org.apache.jetspeed.security.om.InternalUserPrincipal;
 35  
 import org.apache.jetspeed.security.om.impl.InternalGroupPrincipalImpl;
 36  
 import org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl;
 37  
 import org.apache.jetspeed.security.spi.SecurityAccess;
 38  
 import org.apache.jetspeed.security.spi.SecurityMappingHandler;
 39  
 
 40  
 /**
 41  
  * @see org.apache.jetspeed.security.spi.SecurityMappingHandler
 42  
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
 43  
  */
 44  
 public class DefaultSecurityMappingHandler implements SecurityMappingHandler
 45  
 {
 46  
 
 47  
     /** The role hierarchy resolver. */
 48  0
     HierarchyResolver roleHierarchyResolver = new GeneralizationHierarchyResolver();
 49  
 
 50  
     /** The group hierarchy resolver. */
 51  0
     HierarchyResolver groupHierarchyResolver = new GeneralizationHierarchyResolver();
 52  
 
 53  
     /** Common queries. */
 54  0
     private SecurityAccess commonQueries = null;
 55  
 
 56  
     /**
 57  
      * <p>
 58  
      * Constructor providing access to the common queries.
 59  
      * </p>
 60  
      */
 61  
     public DefaultSecurityMappingHandler(SecurityAccess commonQueries)
 62  0
     {
 63  0
         this.commonQueries = commonQueries;
 64  0
     }
 65  
 
 66  
     /**
 67  
      * <p>
 68  
      * Constructor providing access to the common queries and hierarchy
 69  
      * resolvers.
 70  
      * </p>
 71  
      */
 72  
     public DefaultSecurityMappingHandler(SecurityAccess commonQueries, HierarchyResolver roleHierarchyResolver,
 73  
             HierarchyResolver groupHierarchyResolver)
 74  0
     {
 75  0
         this.commonQueries = commonQueries;
 76  0
         if (null != roleHierarchyResolver)
 77  
         {
 78  0
             this.roleHierarchyResolver = roleHierarchyResolver;
 79  
         }
 80  0
         if (null != groupHierarchyResolver)
 81  
         {
 82  0
             this.groupHierarchyResolver = groupHierarchyResolver;
 83  
         }
 84  0
     }
 85  
 
 86  
     /**
 87  
      * @return Returns the roleHierarchyResolver.
 88  
      */
 89  
     public HierarchyResolver getRoleHierarchyResolver()
 90  
     {
 91  0
         return roleHierarchyResolver;
 92  
     }
 93  
 
 94  
     /**
 95  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setRoleHierarchyResolver(org.apache.jetspeed.security.HierarchyResolver)
 96  
      */
 97  
     public void setRoleHierarchyResolver(HierarchyResolver roleHierarchyResolver)
 98  
     {
 99  0
         this.roleHierarchyResolver = roleHierarchyResolver;
 100  0
     }
 101  
 
 102  
     /**
 103  
      * @return Returns the groupHierarchyResolver.
 104  
      */
 105  
     public HierarchyResolver getGroupHierarchyResolver()
 106  
     {
 107  0
         return groupHierarchyResolver;
 108  
     }
 109  
 
 110  
     /**
 111  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setGroupHierarchyResolver(org.apache.jetspeed.security.HierarchyResolver)
 112  
      */
 113  
     public void setGroupHierarchyResolver(HierarchyResolver groupHierarchyResolver)
 114  
     {
 115  0
         this.groupHierarchyResolver = groupHierarchyResolver;
 116  0
     }
 117  
 
 118  
     /**
 119  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRolePrincipals(java.lang.String)
 120  
      */
 121  
     public Set getRolePrincipals(String username)
 122  
     {
 123  0
         Set rolePrincipals = new HashSet();
 124  0
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
 125  0
         if (null != internalUser)
 126  
         {
 127  0
             Collection internalRoles = internalUser.getRolePrincipals();
 128  0
             if (null != internalRoles)
 129  
             {
 130  0
                 Iterator internalRolesIter = internalRoles.iterator();
 131  0
                 while (internalRolesIter.hasNext())
 132  
                 {
 133  0
                     InternalRolePrincipal internalRole = (InternalRolePrincipal) internalRolesIter.next();
 134  0
                     Preferences preferences = Preferences.userRoot().node(internalRole.getFullPath());
 135  0
                     String[] fullPaths = roleHierarchyResolver.resolve(preferences);
 136  0
                     for (int i = 0; i < fullPaths.length; i++)
 137  
                     {
 138  0
                         Principal rolePrincipal = new RolePrincipalImpl(RolePrincipalImpl
 139  
                                 .getPrincipalNameFromFullPath(fullPaths[i]));
 140  0
                         if (!rolePrincipals.contains(rolePrincipal))
 141  
                         {
 142  0
                             rolePrincipals.add(rolePrincipal);
 143  
                         }
 144  
                     }
 145  0
                 }
 146  
             }
 147  
         }
 148  0
         return rolePrincipals;
 149  
     }
 150  
 
 151  
     /**
 152  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setUserPrincipalInRole(java.lang.String,
 153  
      *      java.lang.String)
 154  
      */
 155  
     public void setUserPrincipalInRole(String username, String roleFullPathName) throws SecurityException
 156  
     {
 157  0
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
 158  0
         boolean isMappingOnly = false;
 159  0
         if (null == internalUser)
 160  
         {
 161  
             // This is a record for mapping only.
 162  0
             isMappingOnly = true;
 163  0
             internalUser = new InternalUserPrincipalImpl(UserPrincipalImpl.getFullPathFromPrincipalName(username));
 164  
         }
 165  0
         Collection internalRoles = internalUser.getRolePrincipals();
 166  
         // This should not be null. Check for null should be made by the caller.
 167  0
         InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
 168  
                 .getFullPathFromPrincipalName(roleFullPathName));
 169  
         // Check anyway.
 170  0
         if (null == internalRole)
 171  
         {
 172  0
             throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
 173  
         }
 174  0
         internalRoles.add(internalRole);
 175  0
         internalUser.setRolePrincipals(internalRoles);
 176  0
         commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
 177  0
     }
 178  
 
 179  
     /**
 180  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeUserPrincipalInRole(java.lang.String,
 181  
      *      java.lang.String)
 182  
      */
 183  
     public void removeUserPrincipalInRole(String username, String roleFullPathName) throws SecurityException
 184  
     {
 185  0
         boolean isMappingOnly = false;
 186  
         // Check is the record is used for mapping only.
 187  0
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username, false);
 188  0
         if (null == internalUser)
 189  
         {
 190  0
             internalUser = commonQueries.getInternalUserPrincipal(username, true);
 191  0
             isMappingOnly = true;
 192  
         }
 193  0
         if (null != internalUser)
 194  
         {
 195  0
             Collection internalRoles = internalUser.getRolePrincipals();
 196  
             // This should not be null. Check for null should be made by the caller.
 197  0
             InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
 198  
                     .getFullPathFromPrincipalName(roleFullPathName));
 199  
             // Check anyway.
 200  0
             if (null == internalRole)
 201  
             {
 202  0
                 throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleFullPathName));
 203  
             }
 204  0
             internalRoles.remove(internalRole);
 205  
             // Remove dead mapping records. I.e. No mapping is associated with the specific record.
 206  0
             if (isMappingOnly && internalRoles.isEmpty() && internalUser.getGroupPrincipals().isEmpty()
 207  
                     && internalUser.getPermissions().isEmpty())
 208  
             {
 209  0
                 commonQueries.removeInternalUserPrincipal(internalUser);
 210  
             }
 211  
             else
 212  
             {
 213  0
                 internalUser.setRolePrincipals(internalRoles);
 214  0
                 commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
 215  
             }
 216  0
         }
 217  
         else
 218  
         {
 219  0
             throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(username));
 220  
         }
 221  0
     }
 222  
 
 223  
     /**
 224  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getRolePrincipalsInGroup(java.lang.String)
 225  
      */
 226  
     public Set getRolePrincipalsInGroup(String groupFullPathName)
 227  
     {
 228  0
         Set rolePrincipals = new HashSet();
 229  
 
 230  0
         Preferences preferences = Preferences.userRoot().node(
 231  
                 GroupPrincipalImpl.getFullPathFromPrincipalName(groupFullPathName));
 232  0
         String[] fullPaths = groupHierarchyResolver.resolve(preferences);
 233  0
         for (int i = 0; i < fullPaths.length; i++)
 234  
         {
 235  0
             InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(fullPaths[i]);
 236  0
             if (null != internalGroup)
 237  
             {
 238  0
                 Collection internalRoles = internalGroup.getRolePrincipals();
 239  0
                 if (null != internalRoles)
 240  
                 {
 241  0
                     Iterator internalRolesIter = internalRoles.iterator();
 242  0
                     while (internalRolesIter.hasNext())
 243  
                     {
 244  0
                         InternalRolePrincipal internalRole = (InternalRolePrincipal) internalRolesIter.next();
 245  0
                         Principal rolePrincipal = new RolePrincipalImpl(UserPrincipalImpl
 246  
                                 .getPrincipalNameFromFullPath(internalRole.getFullPath()));
 247  0
                         if (!rolePrincipals.contains(rolePrincipal))
 248  
                         {
 249  0
                             rolePrincipals.add(rolePrincipal);
 250  
                         }
 251  0
                     }
 252  
                 }
 253  
             }
 254  
         }
 255  0
         return rolePrincipals;
 256  
     }
 257  
 
 258  
     /**
 259  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setRolePrincipalInGroup(java.lang.String,
 260  
      *      java.lang.String)
 261  
      */
 262  
     public void setRolePrincipalInGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
 263  
     {
 264  0
         InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
 265  
                 .getFullPathFromPrincipalName(groupFullPathName));
 266  0
         boolean isMappingOnly = false;
 267  0
         if (null == internalGroup)
 268  
         {
 269  
             // This is a record for mapping only.
 270  0
             isMappingOnly = true;
 271  0
             internalGroup = new InternalGroupPrincipalImpl(groupFullPathName);
 272  
         }        
 273  0
         Collection internalRoles = internalGroup.getRolePrincipals();
 274  0
         InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
 275  
                 .getFullPathFromPrincipalName(roleFullPathName));
 276  0
         internalRoles.add(internalRole);
 277  0
         internalGroup.setRolePrincipals(internalRoles);
 278  0
         commonQueries.setInternalGroupPrincipal(internalGroup, isMappingOnly);
 279  0
     }
 280  
 
 281  
     /**
 282  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeRolePrincipalInGroup(java.lang.String,
 283  
      *      java.lang.String)
 284  
      */
 285  
     public void removeRolePrincipalInGroup(String groupFullPathName, String roleFullPathName) throws SecurityException
 286  
     {
 287  0
         InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
 288  
                 .getFullPathFromPrincipalName(groupFullPathName));
 289  0
         boolean isMappingOnly = false;
 290  0
         if (null == internalGroup)
 291  
         {
 292  
             // This is a record for mapping only.
 293  0
             isMappingOnly = true;
 294  0
             internalGroup = new InternalGroupPrincipalImpl(groupFullPathName);
 295  
         }                
 296  0
         if (null == internalGroup)
 297  
         {
 298  0
             throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(internalGroup));
 299  
         }
 300  0
         Collection internalRoles = internalGroup.getRolePrincipals();
 301  0
         InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(RolePrincipalImpl
 302  
                 .getFullPathFromPrincipalName(roleFullPathName));
 303  0
         internalRoles.remove(internalRole);
 304  0
         internalGroup.setRolePrincipals(internalRoles);
 305  0
         commonQueries.setInternalGroupPrincipal(internalGroup, isMappingOnly);
 306  0
     }
 307  
 
 308  
     /**
 309  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getGroupPrincipals(java.lang.String)
 310  
      */
 311  
     public Set getGroupPrincipals(String username)
 312  
     {
 313  0
         Set groupPrincipals = new HashSet();
 314  0
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
 315  0
         if (null != internalUser)
 316  
         {
 317  0
             Collection internalGroups = internalUser.getGroupPrincipals();
 318  0
             if (null != internalGroups)
 319  
             {
 320  0
                 Iterator internalGroupsIter = internalGroups.iterator();
 321  0
                 while (internalGroupsIter.hasNext())
 322  
                 {
 323  0
                     InternalGroupPrincipal internalGroup = (InternalGroupPrincipal) internalGroupsIter.next();
 324  0
                     Preferences preferences = Preferences.userRoot().node(internalGroup.getFullPath());
 325  0
                     String[] fullPaths = groupHierarchyResolver.resolve(preferences);
 326  0
                     for (int i = 0; i < fullPaths.length; i++)
 327  
                     {
 328  0
                         groupPrincipals.add(new GroupPrincipalImpl(GroupPrincipalImpl
 329  
                                 .getPrincipalNameFromFullPath(fullPaths[i])));
 330  
                     }
 331  0
                 }
 332  
             }
 333  
         }
 334  0
         return groupPrincipals;
 335  
     }
 336  
 
 337  
     /**
 338  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getGroupPrincipalsInRole(java.lang.String)
 339  
      */
 340  
     public Set getGroupPrincipalsInRole(String roleFullPathName)
 341  
     {
 342  0
         Set groupPrincipals = new HashSet();
 343  
 
 344  0
         Preferences preferences = Preferences.userRoot().node(
 345  
                 RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName));
 346  0
         String[] fullPaths = roleHierarchyResolver.resolve(preferences);
 347  0
         for (int i = 0; i < fullPaths.length; i++)
 348  
         {
 349  0
             InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(fullPaths[i]);
 350  0
             if (null != internalRole)
 351  
             {
 352  0
                 Collection internalGroups = internalRole.getGroupPrincipals();
 353  0
                 if (null != internalGroups)
 354  
                 {
 355  0
                     Iterator internalGroupsIter = internalGroups.iterator();
 356  0
                     while (internalGroupsIter.hasNext())
 357  
                     {
 358  0
                         InternalGroupPrincipal internalGroup = (InternalGroupPrincipal) internalGroupsIter.next();
 359  0
                         Principal groupPrincipal = new GroupPrincipalImpl(GroupPrincipalImpl
 360  
                                 .getPrincipalNameFromFullPath(internalGroup.getFullPath()));
 361  0
                         if (!groupPrincipals.contains(groupPrincipal))
 362  
                         {
 363  0
                             groupPrincipals.add(groupPrincipal);
 364  
                         }
 365  0
                     }
 366  
                 }
 367  
             }
 368  
         }
 369  0
         return groupPrincipals;
 370  
     }
 371  
 
 372  
     /**
 373  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getUserPrincipalsInRole(java.lang.String)
 374  
      */
 375  
     public Set getUserPrincipalsInRole(String roleFullPathName)
 376  
     {
 377  0
         Set userPrincipals = new HashSet();
 378  
 
 379  0
         Preferences preferences = Preferences.userRoot().node(
 380  
                 RolePrincipalImpl.getFullPathFromPrincipalName(roleFullPathName));
 381  0
         String[] fullPaths = roleHierarchyResolver.resolve(preferences);
 382  0
         for (int i = 0; i < fullPaths.length; i++)
 383  
         {
 384  0
             InternalRolePrincipal internalRole = commonQueries.getInternalRolePrincipal(fullPaths[i]);
 385  0
             if (null != internalRole)
 386  
             {
 387  0
                 Collection internalUsers = internalRole.getUserPrincipals();
 388  0
                 if (null != internalUsers)
 389  
                 {
 390  0
                     Iterator internalUsersIter = internalUsers.iterator();
 391  0
                     while (internalUsersIter.hasNext())
 392  
                     {
 393  0
                         InternalUserPrincipal internalUser = (InternalUserPrincipal) internalUsersIter.next();
 394  0
                         Principal userPrincipal = new UserPrincipalImpl(UserPrincipalImpl
 395  
                                 .getPrincipalNameFromFullPath(internalUser.getFullPath()));
 396  0
                         if (!userPrincipals.contains(userPrincipal))
 397  
                         {
 398  0
                             userPrincipals.add(userPrincipal);
 399  
                         }
 400  0
                     }
 401  
                 }
 402  
             }
 403  
         }
 404  0
         return userPrincipals;
 405  
     }
 406  
 
 407  
     /**
 408  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#getUserPrincipalsInGroup(java.lang.String)
 409  
      */
 410  
     public Set getUserPrincipalsInGroup(String groupFullPathName)
 411  
     {
 412  0
         Set userPrincipals = new HashSet();
 413  
 
 414  0
         Preferences preferences = Preferences.userRoot().node(
 415  
                 GroupPrincipalImpl.getFullPathFromPrincipalName(groupFullPathName));
 416  0
         String[] fullPaths = groupHierarchyResolver.resolve(preferences);
 417  0
         for (int i = 0; i < fullPaths.length; i++)
 418  
         {
 419  0
             InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(fullPaths[i]);
 420  0
             if (null != internalGroup)
 421  
             {
 422  0
                 Collection internalUsers = internalGroup.getUserPrincipals();
 423  0
                 if (null != internalUsers)
 424  
                 {
 425  0
                     Iterator internalUsersIter = internalUsers.iterator();
 426  0
                     while (internalUsersIter.hasNext())
 427  
                     {
 428  0
                         InternalUserPrincipal internalUser = (InternalUserPrincipal) internalUsersIter.next();
 429  0
                         Principal userPrincipal = new UserPrincipalImpl(UserPrincipalImpl
 430  
                                 .getPrincipalNameFromFullPath(internalUser.getFullPath()));
 431  0
                         if (!userPrincipals.contains(userPrincipal))
 432  
                         {
 433  0
                             userPrincipals.add(userPrincipal);
 434  
                         }
 435  0
                     }
 436  
                 }
 437  
             }
 438  
         }
 439  0
         return userPrincipals;
 440  
     }
 441  
 
 442  
     /**
 443  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#setUserPrincipalInGroup(java.lang.String,
 444  
      *      java.lang.String)
 445  
      */
 446  
     public void setUserPrincipalInGroup(String username, String groupFullPathName) throws SecurityException
 447  
     {
 448  0
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username);
 449  0
         boolean isMappingOnly = false;
 450  0
         if (null == internalUser)
 451  
         {
 452  
             // This is a record for mapping only.
 453  0
             isMappingOnly = true;
 454  0
             internalUser = new InternalUserPrincipalImpl(UserPrincipalImpl.getFullPathFromPrincipalName(username));
 455  
         }
 456  0
         Collection internalGroups = internalUser.getGroupPrincipals();
 457  
         // This should not be null. Check for null should be made by the caller.
 458  0
         InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
 459  
                 .getFullPathFromPrincipalName(groupFullPathName));
 460  
         // Check anyway.
 461  0
         if (null == internalGroup)
 462  
         {
 463  0
             throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName));
 464  
         }
 465  0
         internalGroups.add(internalGroup);
 466  0
         internalUser.setGroupPrincipals(internalGroups);
 467  0
         commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
 468  0
     }
 469  
 
 470  
     /**
 471  
      * @see org.apache.jetspeed.security.spi.SecurityMappingHandler#removeUserPrincipalInGroup(java.lang.String,
 472  
      *      java.lang.String)
 473  
      */
 474  
     public void removeUserPrincipalInGroup(String username, String groupFullPathName) throws SecurityException
 475  
     {
 476  0
         boolean isMappingOnly = false;
 477  
         // Check is the record is used for mapping only.
 478  0
         InternalUserPrincipal internalUser = commonQueries.getInternalUserPrincipal(username, false);
 479  0
         if (null == internalUser)
 480  
         {
 481  0
             internalUser = commonQueries.getInternalUserPrincipal(username, true);
 482  0
             isMappingOnly = true;
 483  
         }
 484  0
         if (null != internalUser)
 485  
         {
 486  0
             Collection internalGroups = internalUser.getGroupPrincipals();
 487  
             // This should not be null. Check for null should be made by the caller.
 488  0
             InternalGroupPrincipal internalGroup = commonQueries.getInternalGroupPrincipal(GroupPrincipalImpl
 489  
                     .getFullPathFromPrincipalName(groupFullPathName));
 490  
             // Check anyway.
 491  0
             if (null == internalGroup)
 492  
             {
 493  0
                 throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName));
 494  
             }
 495  0
             internalGroups.remove(internalGroup);
 496  
             // Remove dead mapping records. I.e. No mapping is associated with the specific record.
 497  0
             if (isMappingOnly && internalGroups.isEmpty() && internalUser.getRolePrincipals().isEmpty()
 498  
                     && internalUser.getPermissions().isEmpty())
 499  
             {
 500  0
                 commonQueries.removeInternalUserPrincipal(internalUser);
 501  
             }
 502  
             else
 503  
             {
 504  0
             internalUser.setGroupPrincipals(internalGroups);
 505  0
             commonQueries.setInternalUserPrincipal(internalUser, isMappingOnly);
 506  
             }
 507  0
         }
 508  
         else
 509  
         {
 510  0
             throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST.create(username));
 511  
         }
 512  0
     }
 513  
     
 514  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.