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

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