Search in sources :

Example 76 with IPerson

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

the class UserLayoutHelperImpl method resetUserLayout.

/**
 * @param personAttributes
 * @see
 *     org.apereo.portal.layout.IUserLayoutHelper#resetUserLayout(org.apereo.services.persondir.IPersonAttributes)
 */
@BasePortalJpaDao.PortalTransactional
@Override
public void resetUserLayout(final IPersonAttributes personAttributes) {
    // Create an empty RestrictedPerson object
    final IPerson person = PersonFactory.createRestrictedPerson();
    // populate the person with the supplied attributes
    person.setAttributes(personAttributes.getAttributes());
    // get the integer uid into the person object without creating any new person data
    final int uid = userIdentityStore.getPortalUID(person, false);
    person.setID(uid);
    final IUserProfile profile = userLayoutStore.getUserProfileByFname(person, DEFAULT_LAYOUT_FNAME);
    resetUserLayoutForProfileByName(person, profile);
    resetStylesheetUserPreferencesForProfile(person, profile);
}
Also used : IPerson(org.apereo.portal.security.IPerson) IUserProfile(org.apereo.portal.IUserProfile)

Example 77 with IPerson

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

the class UserLayoutHelperImpl method resetUserLayoutAllProfiles.

/**
 * Resets a users layout for all the users profiles
 *
 * @param personAttributes
 */
@BasePortalJpaDao.PortalTransactional
public void resetUserLayoutAllProfiles(final IPersonAttributes personAttributes) {
    final IPerson person = PersonFactory.createRestrictedPerson();
    person.setAttributes(personAttributes.getAttributes());
    // get the integer uid into the person object without creating any new person data
    int uid = userIdentityStore.getPortalUID(person, false);
    person.setID(uid);
    final Hashtable<Integer, UserProfile> map = userLayoutStore.getUserProfileList(person);
    for (UserProfile profile : map.values()) {
        resetUserLayoutForProfileByName(person, profile);
        resetStylesheetUserPreferencesForProfile(person, profile);
    }
}
Also used : IPerson(org.apereo.portal.security.IPerson) IUserProfile(org.apereo.portal.IUserProfile) UserProfile(org.apereo.portal.UserProfile)

Example 78 with IPerson

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

the class ServerNameGuestChainingProfileMapperTest method testGuestNonAuthorizedDomainWithSubMapperMatching.

@Test
public void testGuestNonAuthorizedDomainWithSubMapperMatching() throws Exception {
    ServerNameGuestChainingProfileMapper profileMapper = new ServerNameGuestChainingProfileMapper();
    profileMapper.setAuthorizedServerNames(configMap);
    List<IProfileMapper> subMappers = new ArrayList<>();
    SessionAttributeProfileMapperImpl subMapper = new SessionAttributeProfileMapperImpl();
    subMappers.add(subMapper);
    subMapper.setDefaultProfileName("submapper_default");
    subMapper.setAttributeName("session_attr");
    Map<String, String> mapping = new HashMap<>();
    mapping.put("session_attr", "sub_fname");
    subMapper.setMappings(mapping);
    profileMapper.setSubMappers(subMappers);
    profileMapper.afterPropertiesSet();
    final IPerson person = createGuestPerson();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setServerName("domain.test");
    request.getSession().setAttribute("session_attr", "session_attr");
    final String fname = profileMapper.getProfileFname(person, request);
    Assert.assertEquals("guest-sub_fname", fname);
}
Also used : IPerson(org.apereo.portal.security.IPerson) HashMap(java.util.HashMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 79 with IPerson

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

the class ServerNameGuestChainingProfileMapperTest method testGuestAuthorizedDomain.

@Test
public void testGuestAuthorizedDomain() throws Exception {
    ServerNameGuestChainingProfileMapper profileMapper = new ServerNameGuestChainingProfileMapper();
    profileMapper.setAuthorizedServerNames(configMap);
    profileMapper.afterPropertiesSet();
    final IPerson person = createGuestPerson();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setServerName("test-cfa.portail.ent");
    final String fname = profileMapper.getProfileFname(person, request);
    Assert.assertEquals("guest-cfa-default", fname);
}
Also used : IPerson(org.apereo.portal.security.IPerson) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 80 with IPerson

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

the class ServerNameGuestChainingProfileMapperTest method testNonGuestNonAuthorizedDomain.

@Test
public void testNonGuestNonAuthorizedDomain() throws Exception {
    ServerNameGuestChainingProfileMapper profileMapper = new ServerNameGuestChainingProfileMapper();
    profileMapper.setAuthorizedServerNames(configMap);
    profileMapper.afterPropertiesSet();
    final IPerson person = createPerson();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setServerName("domain.test");
    final String fname = profileMapper.getProfileFname(person, request);
    Assert.assertEquals("default", fname);
}
Also used : IPerson(org.apereo.portal.security.IPerson) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) 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