本文整理汇总了Java中org.apache.jackrabbit.api.security.user.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于org.apache.jackrabbit.api.security.user包,在下文中一共展示了Group类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addUserGroupMember
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
/**
* Add a user or another group as a member of a specified group.
*
* Function will log an error and do nothing if either the specified group
* or group member cannot be found, or if the specified group is not actually
* a group (i.e. a user).
*
* @param groupName The name of the group to add the member to.
* @param memberName The name of the user or group to add as a member.
* @throws RepositoryException
*/
protected void addUserGroupMember(String groupName, String memberName) throws RepositoryException {
UserManager userManager = AccessControlUtil.getUserManager(session);
Authorizable group = userManager.getAuthorizable(groupName);
Authorizable member = userManager.getAuthorizable(memberName);
if (group == null) {
logger.error("Cannot add member '{}' to group '{}' because '{}' does not exist", memberName, groupName, groupName);
} else if (!group.isGroup()) {
logger.error("Cannot add member '{}' to group '{}' because '{}' is not a group", memberName, groupName, groupName);
} else if (member == null) {
logger.error("Cannot add member '{}' to group '{}' because '{}' does not exist", memberName, groupName, memberName);
} else {
logger.info("Adding member '{}' to group '{}'", memberName, groupName);
((Group) group).addMember(member);
}
}
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:28,代码来源:OnDeployScriptBase.java
示例2: getGroupIfExists
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
public static Group getGroupIfExists(Context context, String id)
throws RepositoryException, ActionExecutionException {
if (checkIfRemoved(context, id)) {
return null;
}
Authorizable authorizable = context.getAuthorizables().get(id);
if (authorizable == null) {
authorizable = context.getUserManager().getAuthorizable(id);
}
if (authorizable == null) {
return null;
}
if (authorizable instanceof User) {
throw new ActionExecutionException(
"Authorizable with id " + id + " exists but is a user not a group");
}
context.getAuthorizables().put(id, authorizable);
return (Group) authorizable;
}
开发者ID:Cognifide,项目名称:APM,代码行数:25,代码来源:AuthorizablesUtils.java
示例3: getGroup
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
public static Group getGroup(Context context, String id)
throws ActionExecutionException, RepositoryException {
if (checkIfRemoved(context, id)) {
throw new ActionExecutionException("Group with id " + id + " not found");
}
Authorizable authorizable = context.getAuthorizables().get(id);
if (authorizable == null) {
authorizable = context.getUserManager().getAuthorizable(id);
}
if (authorizable == null) {
throw new ActionExecutionException("Group with id " + id + " not found");
}
if (authorizable instanceof User) {
throw new ActionExecutionException(
"Authorizable with id " + id + " exists but is a user not a group");
}
context.getAuthorizables().put(id, authorizable);
return (Group) authorizable;
}
开发者ID:Cognifide,项目名称:APM,代码行数:25,代码来源:AuthorizablesUtils.java
示例4: getUserIfExists
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
public static User getUserIfExists(Context context, String id)
throws ActionExecutionException, RepositoryException {
if (checkIfRemoved(context, id)) {
return null;
}
Authorizable authorizable = context.getAuthorizables().get(id);
if (authorizable == null) {
authorizable = context.getUserManager().getAuthorizable(id);
}
if (authorizable == null) {
return null;
}
if (authorizable instanceof Group) {
throw new ActionExecutionException(
"Authorizable with id " + id + " exists but is a group not a user");
}
context.getAuthorizables().put(id, authorizable);
return (User) authorizable;
}
开发者ID:Cognifide,项目名称:APM,代码行数:25,代码来源:AuthorizablesUtils.java
示例5: getUser
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
public static User getUser(Context context, String id)
throws ActionExecutionException, RepositoryException {
if (checkIfRemoved(context, id)) {
throw new ActionExecutionException("User with id " + id + " not found");
}
Authorizable authorizable = context.getAuthorizables().get(id);
if (authorizable == null) {
authorizable = context.getUserManager().getAuthorizable(id);
}
if (authorizable == null) {
throw new ActionExecutionException("User with id " + id + " not found");
}
if (authorizable instanceof Group) {
throw new ActionExecutionException(
"Authorizable with id " + id + " exists but is a group not a user");
}
context.getAuthorizables().put(id, authorizable);
return (User) authorizable;
}
开发者ID:Cognifide,项目名称:APM,代码行数:25,代码来源:AuthorizablesUtils.java
示例6: process
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
Group group = tryGetGroup(context, actionResult);
if (group == null) {
return actionResult;
}
List<String> errors = new ArrayList<>();
boolean checkFailed = checkMembers(context, actionResult, group, errors);
if (execute && checkFailed) {
actionResult.logError(ActionUtils.ASSERTION_FAILED_MSG);
return actionResult;
}
ActionUtils.logErrors(errors, actionResult);
return actionResult;
}
开发者ID:Cognifide,项目名称:APM,代码行数:22,代码来源:CheckExcludes.java
示例7: checkMembers
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
private boolean checkMembers(final Context context, final ActionResult actionResult, final Group group,
final List<String> errors) {
boolean checkFailed = false;
for (String authorizableId : authorizableIds) {
try {
Authorizable authorizable = AuthorizablesUtils
.getAuthorizableIfExists(context, authorizableId);
if (authorizable == null) {
actionResult.logWarning(MessagingUtils.authorizableNotExists(authorizableId));
continue;
}
if (group.isMember(authorizable)) {
actionResult.logError(authorizable.getID() + " belongs to group " + groupId);
checkFailed = true;
}
} catch (RepositoryException e) {
errors.add(MessagingUtils.createMessage(e));
}
}
return checkFailed;
}
开发者ID:Cognifide,项目名称:APM,代码行数:22,代码来源:CheckExcludes.java
示例8: process
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
Group authorizable = tryGetGroup(context, actionResult);
if (authorizable == null) {
return actionResult;
}
List<String> errors = new ArrayList<>();
boolean checkFailed = checkMembers(context, actionResult, authorizable, errors);
if (execute && checkFailed) {
actionResult.logError(ActionUtils.ASSERTION_FAILED_MSG);
return actionResult;
}
ActionUtils.logErrors(errors, actionResult);
return actionResult;
}
开发者ID:Cognifide,项目名称:APM,代码行数:22,代码来源:CheckIncludes.java
示例9: checkMembers
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
private boolean checkMembers(final Context context, final ActionResult actionResult,
final Group authorizable, final List<String> errors) {
boolean checkFailed = false;
for (String id : groupIds) {
try {
Authorizable group = AuthorizablesUtils.getAuthorizable(context, id);
if (!authorizable.isMember(group)) {
actionResult.logError(id + " is excluded from group " + authorizableId);
checkFailed = true;
}
actionResult.logMessage(id + " is a member of group " + authorizableId);
} catch (RepositoryException | ActionExecutionException e) {
errors.add(MessagingUtils.createMessage(e));
}
}
return checkFailed;
}
开发者ID:Cognifide,项目名称:APM,代码行数:19,代码来源:CheckIncludes.java
示例10: process
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
public ActionResult process(final Context context) {
ActionResult actionResult = new ActionResult();
try {
if (shouldBeGroup) {
Group group = AuthorizablesUtils.getGroup(context, id);
context.setCurrentAuthorizable(group);
actionResult.logMessage("Group with id: " + group.getID() + " set as current authorizable");
} else {
User user = AuthorizablesUtils.getUser(context, id);
context.setCurrentAuthorizable(user);
actionResult.logMessage("User with id: " + user.getID() + " set as current authorizable");
}
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
开发者ID:Cognifide,项目名称:APM,代码行数:20,代码来源:ForAuthorizable.java
示例11: detachMembersFromGroup
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
public ActionResult detachMembersFromGroup() {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = context.getCurrentAuthorizable();
if (authorizable.isGroup()) {
final Group group = context.getCurrentGroup();
LOGGER.info(String.format("Removing all members of group with id = %s", group.getID()));
Iterator<Authorizable> groupMembers = getGroupMembers(actionResult, group);
detachAllMembers(actionResult, group, groupMembers);
} else {
actionResult.logError("Child members can only be removed from groups");
}
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
开发者ID:Cognifide,项目名称:APM,代码行数:21,代码来源:ClearFromGroupDetacher.java
示例12: isAuthorable
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
/**
* Get the authorable status of the current user.
*
* @param session The current session.
* @return true if the current user is an admin or author.
*/
public boolean isAuthorable(Session session) {
boolean authorable = false;
JackrabbitSession js = (JackrabbitSession)session;
try {
Group authors = (Group)js.getUserManager().getAuthorizable(PublickConstants.GROUP_ID_AUTHORS);
User user = (User)js.getUserManager().getAuthorizable(js.getUserID());
authorable = user.isAdmin() || authors.isMember(user);
} catch (RepositoryException e) {
LOGGER.error("Could not determine group membership", e);
}
return authorable;
}
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:23,代码来源:UserServiceImpl.java
示例13: isAuthorable
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
/**
* Get the authorable status of the current user.
* TODO: remove and use UserService
*
* @return true if the current user is an admin or author.
*/
public boolean isAuthorable() {
boolean authorable = false;
JackrabbitSession js = (JackrabbitSession)getSession();
try {
Group authors = (Group)js.getUserManager().getAuthorizable(PublickConstants.GROUP_ID_AUTHORS);
User user = (User)js.getUserManager().getAuthorizable(js.getUserID());
authorable = user.isAdmin() || authors.isMember(user);
} catch (RepositoryException e) {
LOGGER.error("Could not determine group membership", e);
}
return authorable;
}
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:23,代码来源:WCMUse.java
示例14: getMembership
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
/**
* Retrieve the group membership of this authorizable.
*
* @param includeInherited Flag indicating whether the resulting iterator only
* contains groups this authorizable is declared member of or if inherited
* group membership is respected.
*
* @return Iterator of groups this authorizable is (declared) member of.
* @throws RepositoryException If an error occurs.
*/
@Nonnull
private Iterator<Group> getMembership(boolean includeInherited) throws RepositoryException {
if (isEveryone()) {
return Collections.<Group>emptySet().iterator();
}
MembershipProvider mMgr = getMembershipProvider();
Iterator<String> oakPaths = mMgr.getMembership(getTree(), includeInherited);
Authorizable everyoneGroup = userManager.getAuthorizable(EveryonePrincipal.getInstance());
if (everyoneGroup instanceof GroupImpl) {
String everyonePath = ((GroupImpl) everyoneGroup).getTree().getPath();
oakPaths = Iterators.concat(oakPaths, ImmutableSet.of(everyonePath).iterator());
}
if (oakPaths.hasNext()) {
AuthorizableIterator groups = AuthorizableIterator.create(oakPaths, userManager, AuthorizableType.GROUP);
return new RangeIteratorAdapter(groups, groups.getSize());
} else {
return RangeIteratorAdapter.EMPTY;
}
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:32,代码来源:AuthorizableImpl.java
示例15: createGroup
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
@Override
public Group createGroup(String groupID, Principal principal, @Nullable String intermediatePath) throws RepositoryException {
checkValidID(groupID);
checkValidPrincipal(principal, true);
if (intermediatePath != null) {
intermediatePath = namePathMapper.getOakPathKeepIndex(intermediatePath);
}
Tree groupTree = userProvider.createGroup(groupID, intermediatePath);
setPrincipal(groupTree, principal);
Group group = new GroupImpl(groupID, groupTree, this);
onCreate(group);
log.debug("Group created: " + groupID);
return group;
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:18,代码来源:UserManagerImpl.java
示例16: testAuthenticateResolvesToGroup
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
@Test
public void testAuthenticateResolvesToGroup() throws Exception {
Group g = getUserManager(root).createGroup("g1");
SimpleCredentials sc = new SimpleCredentials(g.getID(), "pw".toCharArray());
Authentication a = new UserAuthentication(sc.getUserID(), getUserManager(root));
try {
a.authenticate(sc);
fail("Authenticating Group should fail");
} catch (LoginException e) {
// success
} finally {
if (g != null) {
g.remove();
root.commit();
}
}
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:19,代码来源:UserAuthenticationTest.java
示例17: testManyMemberships
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
@Test
public void testManyMemberships() throws Exception {
Set<String> memberships = new HashSet<String>();
User usr = createUser();
for (int i=0; i<NUM_GROUPS; i++) {
Group grp = createGroup();
grp.addMember(usr);
memberships.add(grp.getID());
}
root.commit();
Iterator<Group> iter = usr.declaredMemberOf();
while (iter.hasNext()) {
Group group = iter.next();
Assert.assertTrue(memberships.remove(group.getID()));
}
assertEquals(0, memberships.size());
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:19,代码来源:MembershipProviderTest.java
示例18: testNestedMemberships
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
@Test
public void testNestedMemberships() throws Exception {
Set<String> memberships = new HashSet<String>();
User user = createUser();
Group grp = createGroup();
memberships.add(grp.getID());
for (int i=0; i<10; i++) {
Group g1 = createGroup();
grp.addMember(g1);
memberships.add(g1.getID());
for (int j=0; j<10; j++) {
Group g2 = createGroup();
g1.addMember(g2);
memberships.add(g2.getID());
g2.addMember(user);
}
}
root.commit();
Iterator<Group> iter = user.memberOf();
while (iter.hasNext()) {
Group group = iter.next();
Assert.assertTrue(memberships.remove(group.getID()));
}
assertEquals(0, memberships.size());
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:27,代码来源:MembershipProviderTest.java
示例19: testDeclaredMemberOf
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
@Test
public void testDeclaredMemberOf() throws Exception {
User u = mgr.createUser("u", "u");
Group g = mgr.createGroup("g");
assertTrue(g.addMember(u));
Iterator<Group> groups = u.declaredMemberOf();
assertTrue(groups.hasNext());
Group gAgain = groups.next();
assertTrue(gAgain instanceof GroupImpl);
assertTrue(gAgain.removeMember(u));
assertFalse(root.hasPendingChanges());
assertFalse(u.declaredMemberOf().hasNext());
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:17,代码来源:AutoSaveEnabledManagerTest.java
示例20: testMemberOf
import org.apache.jackrabbit.api.security.user.Group; //导入依赖的package包/类
@Test
public void testMemberOf() throws Exception {
User u = mgr.createUser("u", "u");
Group g = mgr.createGroup("g");
assertTrue(g.addMember(u));
Iterator<Group> groups = u.memberOf();
assertTrue(groups.hasNext());
Group gAgain = groups.next();
assertTrue(gAgain instanceof GroupImpl);
assertTrue(gAgain.removeMember(u));
assertFalse(root.hasPendingChanges());
assertFalse(u.declaredMemberOf().hasNext());
}
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:17,代码来源:AutoSaveEnabledManagerTest.java
注:本文中的org.apache.jackrabbit.api.security.user.Group类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论