The group principal.
296297298299300301302303304305306
{ username, groupFullPathName}, new String[] { "username", "groupFullPathName"}, "addUserToGroup(java.lang.String, java.lang.String)"); // Get the group principal to add to user. GroupPrincipal groupPrincipal = groupSecurityHandler.getGroupPrincipal(groupFullPathName); if (null == groupPrincipal) { throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupFullPathName)); } // Check that user exists. Principal userPrincipal = atnProviderProxy.getUserPrincipal(username);
5152535455565758596061
/** * @see org.apache.jetspeed.security.spi.GroupSecurityHandler#getGroupPrincipal(java.lang.String) */ public GroupPrincipal getGroupPrincipal(String groupFullPathName) { GroupPrincipal groupPrincipal = null; InternalGroupPrincipal internalGroup = commonQueries .getInternalGroupPrincipal(GroupPrincipalImpl .getFullPathFromPrincipalName(groupFullPathName)); if (null != internalGroup) {
354355356357358359360361362363364
* @param groupFullPathName * @throws SecurityException */ private void verifyGroupAndRoleExist(String groupFullPathName, String roleFullPathName) throws SecurityException { GroupPrincipal group = getGroup(groupFullPathName); RolePrincipal role = getRole(roleFullPathName); if ((null == group) && (null == role)) { throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST); }
370371372373374375376377378379380
* @throws SecurityException */ private void verifyUserAndGroupExist(String username, String groupFullPathName) throws SecurityException { UserPrincipal user = getUser(username); GroupPrincipal group = getGroup(groupFullPathName); if ((null == user) && (null == group)) { throw new SecurityException(SecurityException.USER_DOES_NOT_EXIST); } }
402403404405406407408409410411412413414
*/ private void createResolvedGroupPrincipalSet(String username, Set groupPrincipals, String[] groups, int i) { LOG.debug("Group [" + i + "] for user[" + username + "] is [" + groups[i] + "]"); GroupPrincipal group = new GroupPrincipalImpl(groups[i]); Preferences preferences = Preferences.userRoot().node(group.getFullPath()); LOG.debug("Group name:" + group.getName()); String[] fullPaths = groupHierarchyResolver.resolve(preferences); for (int n = 0; n < fullPaths.length; n++) { LOG.debug("Group [" + i + "] for user[" + username + "] is [" + GroupPrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n]) + "]");
5354555657585960
crHandler.setPassword(uid, "", password); } public static void seedGroupData(String gpUid) throws Exception { GroupPrincipal gp = new GroupPrincipalImpl(gpUid); grHandler.setGroupPrincipal(gp); }
7172737475767778
userHandler.removeUserPrincipal(up); } public static void removeGroupData(String gpUid) throws Exception { GroupPrincipal gp = new GroupPrincipalImpl(gpUid); grHandler.removeGroupPrincipal(gp); }
50515253545556575859
*/ public void testGetGroupPrincipal() throws Exception { String fullPath = (new GroupPrincipalImpl(gpUid1)).getFullPath(); //GroupPrincipal groupPrincipal = grHandler.getGroupPrincipal(fullPath); GroupPrincipal groupPrincipal = grHandler.getGroupPrincipal(gpUid1); assertNotNull("Group was not found.", groupPrincipal); assertEquals(gpUid1,groupPrincipal.getName()); assertEquals(fullPath,groupPrincipal.getFullPath()); }
/** * @throws Exception */ public void testGetNonExistingGroupPrincipal() throws Exception { GroupPrincipal group = grHandler.getGroupPrincipal(gpUid1 + "FAKE"); assertNull(group); }
808182838485868788899091
/** * @throws Exception */ public void testRemoveExistantUserPrincipal() throws Exception { GroupPrincipal gp = new GroupPrincipalImpl(gpUid1); grHandler.removeGroupPrincipal(gp); GroupPrincipal groupPrincipal = grHandler.getGroupPrincipal(gp.getFullPath()); assertNull("Group was found and should have been removed.", groupPrincipal); List groups = grHandler.getGroupPrincipals(""); assertEquals(0,groups.size()); }