本文整理汇总了Java中org.apache.jackrabbit.api.security.user.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于org.apache.jackrabbit.api.security.user包,在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}