public static EntityEnum getEntityEnum(Class<?> entityTypeClazz, boolean isGroup) { EntityEnum rslt = null; for (EntityEnum val : EntityEnum.values()) { if (val.getClazz().equals(entityTypeClazz) && val.isGroup() == isGroup) { rslt = val; break; } } return rslt; }
@Override public Set<Entity> getGroupsForMember(String memberName) { Set<Entity> groups = new HashSet<Entity>(); if (StringUtils.isNotEmpty(memberName)) { EntityIdentifier[] identifiers = GroupService.searchForEntities( memberName, GroupService.SearchMethod.DISCRETE, EntityEnum.PERSON.getClazz()); for (EntityIdentifier entityIdentifier : identifiers) { if (entityIdentifier.getType().equals(EntityEnum.PERSON.getClazz())) { IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier); if (memberName.equalsIgnoreCase(groupMember.getKey())) { Iterator it = GroupService.findParentGroups(groupMember); while (it.hasNext()) { IEntityGroup g = (IEntityGroup) it.next(); Entity e = EntityFactory.createEntity( g, EntityEnum.getEntityEnum(g.getLeafType(), true)); groups.add(e); } return groups; } } } } return groups; }
@Override public IAuthorizationPrincipal getPrincipalForEntity(JsonEntityBean entity) { if (entity == null) { throw new IllegalArgumentException("Parameter cannot be null."); } // attempt to determine the entity type class for this principal Class entityType; EntityEnum jsonType = entity.getEntityType(); if (jsonType == null) { throw new IllegalArgumentException("Parameter's entityType cannot be null."); } if (jsonType.isGroup()) { entityType = IEntityGroup.class; } else { entityType = jsonType.getClazz(); } // construct an authorization principal for this JsonEntityBean AuthorizationServiceFacade authService = AuthorizationServiceFacade.instance(); IAuthorizationPrincipal p = authService.newPrincipal(entity.getId(), entityType); return p; }
public String lookupEntityName(EntityEnum entityType, String entityId) { if (entityType == null && (StringUtils.isBlank(entityId))) { return null; } IEntityNameFinder finder; if (entityType.isGroup()) { finder = EntityNameFinderService.instance().getNameFinder(IEntityGroup.class); } else { finder = EntityNameFinderService.instance().getNameFinder(entityType.getClazz()); } try { return finder.getName(entityId); } catch (Exception e) { /* An exception here isn't the end of the world. Just log it and return null. */ log.warn("Couldn't find name for entity " + entityId, e); return null; } }
public IAuthorizationPrincipal getPrincipalForEntity(Entity entity) { // attempt to determine the entity type class for this principal if (entity == null) { return null; } Class entityType; if (entity.getEntityType().equals(EntityEnum.GROUP.toString())) { entityType = IEntityGroup.class; } else { entityType = EntityEnum.getEntityEnum(entity.getEntityType()).getClazz(); } // construct an authorization principal for this JsonEntityBean AuthorizationServiceFacade authService = AuthorizationServiceFacade.instance(); IAuthorizationPrincipal p = authService.newPrincipal(entity.getId(), entityType); return p; }
groupName, GroupService.SearchMethod.DISCRETE, EntityEnum.GROUP.getClazz()); for (EntityIdentifier entityIdentifier : identifiers) { if (entityIdentifier.getType().equals(IEntityGroup.class)) {
finder = EntityNameFinderService.instance().getNameFinder(IEntityGroup.class); } else { finder = EntityNameFinderService.instance().getNameFinder(entityEnum.getClazz());
person.getUserName(), EntityEnum.PERSON.getClazz());
httpServletRequest.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) { return null;
this.authorizationService.newPrincipal(username, EntityEnum.PERSON.getClazz());
entity.getId(), entity.getEntityType().getClazz());
member = GroupService.findGroup(a.getPrincipal().getId()); } else { member = GroupService.getGroupMember(a.getPrincipal().getId(), entityEnum.getClazz());
IGroupMember groupMember = GroupService.getGroupMember(entityId, entityEnum.getClazz()); if (groupMember == null || groupMember instanceof IEntityGroup) { return null;
group.addChild(member); } else { IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz()); group.addChild(member);
IGroupMember entity = GroupService.getGroupMember(entityId, entityEnum.getClazz()); if (entity == null || entity instanceof IEntityGroup) { return null;
&& authorizationService.canPrincipalBrowse( authorizationService.newPrincipal( request.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) { final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();