Search in sources :

Example 1 with PrincipalImpl

use of org.apereo.portal.api.PrincipalImpl in project uPortal by Jasig.

the class EntityImplTest method setup.

@Before
public void setup() {
    List<Entity> entities = new ArrayList<Entity>();
    entities.add(new EntityImpl());
    entity = new EntityImpl();
    entity.setCreatorId("creatorID");
    entity.setDescription("description");
    entity.setEntityType(Entity.ENTITY_PERSON);
    entity.setId("id");
    entity.setName("entity");
    entity.setPrincipal(new PrincipalImpl("john", "doe"));
    entity.setChildrenInitialized(true);
    entity.setChildren(entities);
}
Also used : ArrayList(java.util.ArrayList) PrincipalImpl(org.apereo.portal.api.PrincipalImpl) Before(org.junit.Before)

Example 2 with PrincipalImpl

use of org.apereo.portal.api.PrincipalImpl in project uPortal by Jasig.

the class ApiPermissionsService method createAssignment.

/*
     * Implementation
     */
private Assignment createAssignment(IPermission permission, IAuthorizationPrincipal authP, boolean inherited) {
    Assignment rslt = null;
    try {
        // Owner
        IPermissionOwner owner = permissionOwnerDao.getPermissionOwner(permission.getOwner());
        Owner ownerImpl = new OwnerImpl(permission.getOwner(), owner.getName());
        // Activity
        IPermissionActivity activity = permissionOwnerDao.getPermissionActivity(permission.getOwner(), permission.getActivity());
        Activity activityImpl = new ActivityImpl(permission.getActivity(), activity.getName());
        // Principal
        Principal principalImpl = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
        // Target
        // default
        Target targetImpl = null;
        IPermissionTargetProvider targetProvider = targetProviderRegistry.getTargetProvider(activity.getTargetProviderKey());
        IPermissionTarget target = targetProvider.getTarget(permission.getTarget());
        if (target != null) {
            targetImpl = new TargetImpl(permission.getTarget(), target.getName());
        }
        rslt = new AssignmentImpl(ownerImpl, activityImpl, principalImpl, targetImpl, inherited);
    } catch (Exception e) {
        log.warn("Exception while adding permission", e);
    }
    return rslt;
}
Also used : IPermissionActivity(org.apereo.portal.permission.IPermissionActivity) IPermissionOwner(org.apereo.portal.permission.IPermissionOwner) IPermissionActivity(org.apereo.portal.permission.IPermissionActivity) IPermissionTarget(org.apereo.portal.permission.target.IPermissionTarget) IPermissionTarget(org.apereo.portal.permission.target.IPermissionTarget) IPermissionTargetProvider(org.apereo.portal.permission.target.IPermissionTargetProvider) Principal(org.apereo.portal.api.Principal) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PrincipalImpl(org.apereo.portal.api.PrincipalImpl) IPermissionOwner(org.apereo.portal.permission.IPermissionOwner)

Example 3 with PrincipalImpl

use of org.apereo.portal.api.PrincipalImpl in project uPortal by Jasig.

the class EntityFactory method setPrincipal.

private static void setPrincipal(Entity entity) {
    IAuthorizationPrincipal authP = EntityService.instance().getPrincipalForEntity(entity);
    Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
    entity.setPrincipal(principal);
}
Also used : IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Principal(org.apereo.portal.api.Principal) PrincipalImpl(org.apereo.portal.api.PrincipalImpl)

Example 4 with PrincipalImpl

use of org.apereo.portal.api.PrincipalImpl in project uPortal by Jasig.

the class EntityService method getEntity.

public Entity getEntity(String entityType, String entityId, boolean populateChildren) {
    // get the EntityEnum for the specified entity type
    if (StringUtils.isBlank(entityType) && StringUtils.isBlank(entityId)) {
        return null;
    }
    EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
    // to locate it
    if (entityEnum.isGroup()) {
        // attempt to find the entity
        IEntityGroup entityGroup = GroupService.findGroup(entityId);
        if (entityGroup == null) {
            return null;
        } else {
            Entity entity = EntityFactory.createEntity(entityGroup, entityEnum);
            if (populateChildren) {
                Iterator<IGroupMember> members = entityGroup.getChildren().iterator();
                entity = populateChildren(entity, members);
            }
            IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
            Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
            entity.setPrincipal(principal);
            return entity;
        }
    } else // otherwise use the getGroupMember method
    {
        IGroupMember groupMember = GroupService.getGroupMember(entityId, entityEnum.getClazz());
        if (groupMember == null || groupMember instanceof IEntityGroup) {
            return null;
        }
        Entity entity = EntityFactory.createEntity(groupMember, entityEnum);
        // the group member interface doesn't include the entity name, so
        // we'll need to look that up manually
        entity.setName(lookupEntityName(entity));
        if (EntityEnum.GROUP.toString().equals(entity.getEntityType()) || EntityEnum.PERSON.toString().equals(entity.getEntityType())) {
            IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
            Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
            entity.setPrincipal(principal);
        }
        return entity;
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) EntityEnum(org.apereo.portal.portlets.groupselector.EntityEnum) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Principal(org.apereo.portal.api.Principal) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PrincipalImpl(org.apereo.portal.api.PrincipalImpl)

Example 5 with PrincipalImpl

use of org.apereo.portal.api.PrincipalImpl in project uPortal by Jasig.

the class EntityService method getEntity.

public Entity getEntity(IGroupMember member) {
    if (member == null) {
        return null;
    }
    // get the type of this member entity
    EntityEnum entityEnum = getEntityType(member);
    // construct a new entity bean for this entity
    Entity entity;
    if (entityEnum.isGroup()) {
        entity = EntityFactory.createEntity((IEntityGroup) member, entityEnum);
    } else {
        entity = EntityFactory.createEntity(member, entityEnum);
    }
    // if the name hasn't been set yet, look up the entity name
    if (entity.getName() == null) {
        entity.setName(lookupEntityName(entity));
    }
    if (EntityEnum.GROUP.toString().equals(entity.getEntityType()) || EntityEnum.PERSON.toString().equals(entity.getEntityType())) {
        IAuthorizationPrincipal authP = getPrincipalForEntity(entity);
        Principal principal = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());
        entity.setPrincipal(principal);
    }
    return entity;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) EntityEnum(org.apereo.portal.portlets.groupselector.EntityEnum) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Principal(org.apereo.portal.api.Principal) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PrincipalImpl(org.apereo.portal.api.PrincipalImpl)

Aggregations

PrincipalImpl (org.apereo.portal.api.PrincipalImpl)5 Principal (org.apereo.portal.api.Principal)4 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)4 IEntityGroup (org.apereo.portal.groups.IEntityGroup)2 EntityEnum (org.apereo.portal.portlets.groupselector.EntityEnum)2 ArrayList (java.util.ArrayList)1 IGroupMember (org.apereo.portal.groups.IGroupMember)1 IPermissionActivity (org.apereo.portal.permission.IPermissionActivity)1 IPermissionOwner (org.apereo.portal.permission.IPermissionOwner)1 IPermissionTarget (org.apereo.portal.permission.target.IPermissionTarget)1 IPermissionTargetProvider (org.apereo.portal.permission.target.IPermissionTargetProvider)1 Before (org.junit.Before)1