Search in sources :

Example 61 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PortletDefinitionImpl method updateLifecycleState.

/**
 * In {@link PortletDefinitionImpl}, this overload does all the work. (The other overload
 * forwards.) Adding <code>synchronized</code> in case two threads try to modify the collection
 * at the same time.
 */
@Override
public synchronized void updateLifecycleState(PortletLifecycleState lifecycleState, IPerson user, Date timestamp) {
    /*
         * Lifecycle entries that are scheduled for an instant
         * on or after the new entry must be cleared.
         */
    final Set<IPortletLifecycleEntry> canceledStateChanges = lifecycleEntries.stream().filter(entry -> entry.getDate().compareTo(timestamp) >= 0).collect(Collectors.toSet());
    lifecycleEntries.removeAll(canceledStateChanges);
    final IPortletLifecycleEntry newEntry = new PortletLifecycleEntryImpl(user.getID(), lifecycleState, timestamp);
    lifecycleEntries.add(newEntry);
}
Also used : IPortletDescriptorKey(org.apereo.portal.portlet.om.IPortletDescriptorKey) Date(java.util.Date) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) MapKey(javax.persistence.MapKey) MapKeyColumn(javax.persistence.MapKeyColumn) SequenceGenerator(javax.persistence.SequenceGenerator) FetchMode(org.hibernate.annotations.FetchMode) Map(java.util.Map) PortletLifecycleState(org.apereo.portal.portlet.om.PortletLifecycleState) IPortletLifecycleEntry(org.apereo.portal.portlet.om.IPortletLifecycleEntry) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) Version(javax.persistence.Version) IMarketplaceRating(org.apereo.portal.portlet.marketplace.IMarketplaceRating) Entity(javax.persistence.Entity) ManyToOne(javax.persistence.ManyToOne) CascadeType(javax.persistence.CascadeType) IPortletType(org.apereo.portal.portlet.om.IPortletType) Set(java.util.Set) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) Collectors(java.util.stream.Collectors) Type(org.hibernate.annotations.Type) Column(javax.persistence.Column) List(java.util.List) GeneratedValue(javax.persistence.GeneratedValue) Index(org.hibernate.annotations.Index) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Validate(org.apache.commons.lang.Validate) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Table(javax.persistence.Table) TableGenerator(javax.persistence.TableGenerator) NaturalIdCache(org.hibernate.annotations.NaturalIdCache) PostLoad(javax.persistence.PostLoad) OrderBy(javax.persistence.OrderBy) IPerson(org.apereo.portal.security.IPerson) CollectionTable(javax.persistence.CollectionTable) LinkedHashSet(java.util.LinkedHashSet) Id(javax.persistence.Id) Fetch(org.hibernate.annotations.Fetch) PostPersist(javax.persistence.PostPersist) Embedded(javax.persistence.Embedded) JoinColumn(javax.persistence.JoinColumn) Cacheable(javax.persistence.Cacheable) OneToMany(javax.persistence.OneToMany) CacheConcurrencyStrategy(org.hibernate.annotations.CacheConcurrencyStrategy) Cache(org.hibernate.annotations.Cache) OneToOne(javax.persistence.OneToOne) NaturalId(org.hibernate.annotations.NaturalId) Transient(javax.persistence.Transient) EntityIdentifier(org.apereo.portal.EntityIdentifier) FetchType(javax.persistence.FetchType) ElementCollection(javax.persistence.ElementCollection) PostUpdate(javax.persistence.PostUpdate) Collections(java.util.Collections) PostRemove(javax.persistence.PostRemove) StringUtils(org.springframework.util.StringUtils) IPortletLifecycleEntry(org.apereo.portal.portlet.om.IPortletLifecycleEntry)

Example 62 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class UpdatePreferencesServletTest method testRemoveFavorite.

@Test(expected = NullPointerException.class)
public void testRemoveFavorite() throws IOException {
    req.setLocalName("en-US");
    IPerson person = new PersonImpl();
    person.setUserName("jdoe");
    person.setFullName("john doe");
    IUserInstance userInstance = new UserInstance(person, null, null);
    Mockito.when(userInstanceManager.getUserInstance(req)).thenReturn(userInstance);
    ModelAndView modelAndView = updatePreferencesServlet.removeFavorite("channelId", req, res);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) UserInstance(org.apereo.portal.UserInstance) IUserInstance(org.apereo.portal.user.IUserInstance) Test(org.junit.Test)

Example 63 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PermissionAssignmentMapControllerTest method testDeletePermission.

@Test
public void testDeletePermission() throws Exception {
    String[] str = new String[] { "principal1", "principal2" };
    IPerson person = new PersonImpl();
    person.setUserName("jdoe");
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(true);
    Mockito.when(permissionAdministrationHelper.canEditPermission(person, "target")).thenReturn(true);
    Mockito.when(groupListHelper.getEntityForPrincipal("principal")).thenReturn(null);
    permissionAssignmentMapController.deletePermission("principal", "owner", "activity1", "target", req, res);
    Assert.assertEquals(200L, res.getStatus());
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) Test(org.junit.Test)

Example 64 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PermissionAssignmentMapControllerTest method testUpdatePermissionCannotViewPermission.

@Test
public void testUpdatePermissionCannotViewPermission() throws Exception {
    String[] str = new String[] { "principal1", "principal2" };
    IPerson person = new PersonImpl();
    person.setUserName("jdoe");
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(false);
    ModelAndView modelAndView = permissionAssignmentMapController.updatePermission("principal", "assignment1", str, "owner", "activity1", "target", req, res);
    Assert.assertNull(modelAndView);
    Assert.assertEquals(401L, res.getStatus());
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 65 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PermissionAssignmentMapControllerTest method testUpdatePermissionNull.

@Test
public void testUpdatePermissionNull() throws Exception {
    String[] str = new String[] { "principal1", "principal2" };
    IPerson person = new PersonImpl();
    person.setUserName("jdoe");
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(true);
    Mockito.when(groupListHelper.getEntityForPrincipal("principal")).thenReturn(null);
    ModelAndView modelAndView = permissionAssignmentMapController.updatePermission("principal", "assignment1", str, "owner", "activity1", "target", req, res);
    Assert.assertNull(modelAndView);
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Aggregations

IPerson (org.apereo.portal.security.IPerson)198 Test (org.junit.Test)52 PersonImpl (org.apereo.portal.security.provider.PersonImpl)45 ModelAndView (org.springframework.web.servlet.ModelAndView)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)34 HttpServletRequest (javax.servlet.http.HttpServletRequest)32 IUserInstance (org.apereo.portal.user.IUserInstance)27 HashMap (java.util.HashMap)25 HttpSession (javax.servlet.http.HttpSession)22 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)22 ArrayList (java.util.ArrayList)20 EntityIdentifier (org.apereo.portal.EntityIdentifier)18 ISecurityContext (org.apereo.portal.security.ISecurityContext)17 IPersonAttributes (org.apereo.services.persondir.IPersonAttributes)17 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)15 List (java.util.List)14 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 Map (java.util.Map)11 Set (java.util.Set)11 IUserProfile (org.apereo.portal.IUserProfile)11