Search in sources :

Example 71 with IPerson

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

the class PersonalizationFilterTest method setup.

@Before
public void setup() {
    res = new MockHttpServletResponse();
    req = new MockHttpServletRequest();
    personalizationFilter = new PersonalizationFilter();
    IPerson person = mockPerson("user1");
    IPersonManager pMgr = mockPersonManager(req, person);
    personalizationFilter.setPersonManager(pMgr);
}
Also used : IPerson(org.apereo.portal.security.IPerson) IPersonManager(org.apereo.portal.security.IPersonManager) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Example 72 with IPerson

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

the class PagsRESTControllerTest method testFindPagsGroup.

@Test
public void testFindPagsGroup() throws JsonProcessingException {
    String groupName = "groupname";
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    person.setFullName("john doe");
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    IPersonAttributesGroupDefinition pagsGroup = new PersonAttributesGroupDefinitionImpl(groupName, "this is awesome");
    Mockito.when(pagsService.getPagsDefinitionByName(person, groupName)).thenReturn(pagsGroup);
    pagsRESTController.findPagsGroup(req, res, "groupname");
    Mockito.verify(mapper).writeValueAsString(pagsGroup);
}
Also used : IPerson(org.apereo.portal.security.IPerson) IPersonAttributesGroupDefinition(org.apereo.portal.groups.pags.dao.IPersonAttributesGroupDefinition) PersonImpl(org.apereo.portal.security.provider.PersonImpl) PersonAttributesGroupDefinitionImpl(org.apereo.portal.groups.pags.dao.jpa.PersonAttributesGroupDefinitionImpl) Test(org.junit.Test)

Example 73 with IPerson

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

the class PeopleRESTControllerV50Test method testGetPerson.

@Test
public void testGetPerson() {
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(lookupHelper.findPerson(person, USER_NAME)).thenReturn(getNamedPerson());
    ModelAndView modelAndView = peopleRESTControllerV50.getPerson(USER_NAME, req, res);
    Assert.assertEquals("json", modelAndView.getViewName());
    Assert.assertNotNull(modelAndView.getModel());
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) NamedPersonImpl(org.apereo.services.persondir.support.NamedPersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 74 with IPerson

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

the class PeopleRESTControllerV50Test method testMe.

@Test
public void testMe() {
    IPerson person = new PersonImpl();
    person.setUserName(USER_NAME);
    Mockito.when(personManager.getPerson(req)).thenReturn(person);
    Mockito.when(lookupHelper.findPerson(person, USER_NAME)).thenReturn(getNamedPerson());
    ModelAndView modelAndView = peopleRESTControllerV50.getMe(req, res);
    Assert.assertEquals("json", modelAndView.getViewName());
    Assert.assertNotNull(modelAndView.getModel());
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) NamedPersonImpl(org.apereo.services.persondir.support.NamedPersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 75 with IPerson

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

the class UserFilteringPortalEventHandler method supports.

@Override
public boolean supports(E event) {
    if (!(event instanceof PortalEvent)) {
        return false;
    }
    // Guest support check
    final IPerson person = event.getPerson();
    if (person != null && !this.supportGuest && person.isGuest()) {
        return false;
    }
    // userName check
    final String userName = event.getUserName();
    if (this.supportedUserNames != null && this.supportedUserNames.contains(userName)) {
        return true;
    }
    // ignored userName check
    if (this.ignoredUserNames != null && this.ignoredUserNames.contains(userName)) {
        return false;
    }
    // ignored userName pattern check
    if (this.ignoredUserNamePatterns != null) {
        for (final Pattern ignoredUserNamePattern : this.ignoredUserNamePatterns) {
            if (ignoredUserNamePattern.matcher(userName).matches()) {
                return false;
            }
        }
    }
    return this.supportedUserNames == null || this.supportedUserNames.isEmpty();
}
Also used : IPerson(org.apereo.portal.security.IPerson) Pattern(java.util.regex.Pattern) PortalEvent(org.apereo.portal.events.PortalEvent)

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