use of org.apereo.portal.url.IPortalRequestUtils in project uPortal by Jasig.
the class ProfileEvaluator method isApplicable.
@Override
public boolean isApplicable(IPerson person) {
final ApplicationContext applicationContext = ApplicationContextLocator.getApplicationContext();
final IPortalRequestUtils portalRequestUtils = applicationContext.getBean(IPortalRequestUtils.class);
final IProfileMapper profileMapper = applicationContext.getBean("profileMapper", IProfileMapper.class);
final HttpServletRequest request = portalRequestUtils.getCurrentPortalRequest();
final String currentFname = profileMapper.getProfileFname(person, request);
return profileFname.equals(currentFname);
}
use of org.apereo.portal.url.IPortalRequestUtils in project uPortal by Jasig.
the class HttpRequestPropertiesManagerTest method testGetRequestProperties.
public void testGetRequestProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("1.2.3.4");
request.setMethod("POST");
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
final IPortalRequestUtils portalRequestUtils = EasyMock.createMock(IPortalRequestUtils.class);
EasyMock.expect(portalRequestUtils.getOriginalPortalRequest(request)).andReturn(request);
EasyMock.replay(portletWindow, portalRequestUtils);
this.httpRequestPropertiesManager.setPortalRequestUtils(portalRequestUtils);
final MultivaluedMapPopulator<String, String> populator = new MultivaluedMapPopulator<String, String>();
this.httpRequestPropertiesManager.populateRequestProperties(request, portletWindow, populator);
final Map<String, List<String>> properties = populator.getMap();
assertNotNull("properties Map should not be null", properties);
final Map<String, List<String>> expected = ImmutableMap.of("REMOTE_ADDR", Collections.singletonList("1.2.3.4"), "REQUEST_METHOD", Collections.singletonList("POST"), "REMOTE_HOST", Collections.singletonList("localhost"));
assertEquals(expected, properties);
EasyMock.verify(portletWindow, portalRequestUtils);
}
Aggregations