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);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class GoogleAnalyticsController method renderAnalyticsHeader.
@RenderMapping
public String renderAnalyticsHeader(RenderRequest request, ModelMap model) throws IOException {
// For which user account are we logging portal activity?
final HttpServletRequest req = portalRequestUtils.getCurrentPortalRequest();
final IPerson person = personManager.getPerson(req);
final String username = person.getUserName();
final IGroupMember groupMember = GroupService.getGroupMember(username, IPerson.class);
final Map<String, Boolean> isMemberCache = new HashMap<>();
final PortletPreferences preferences = request.getPreferences();
final JsonNode config = this.portletPreferencesJsonDao.getJsonNode(preferences, GoogleAnalyticsConfigController.CONFIG_PREF_NAME);
final JsonNode propertyConfig = config.get("defaultConfig");
this.filterAnalyticsGroups(groupMember, propertyConfig, isMemberCache);
final JsonNode hosts = config.get("hosts");
if (hosts != null) {
for (final Iterator<JsonNode> hostsItr = hosts.elements(); hostsItr.hasNext(); ) {
final JsonNode institution = hostsItr.next();
this.filterAnalyticsGroups(groupMember, institution, isMemberCache);
}
}
model.put("data", config);
if (propertyConfig == null || propertyConfig.get("propertyId") == null) {
return "jsp/GoogleAnalytics/noop";
} else {
return "jsp/GoogleAnalytics/init";
}
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class SubscribableTabsRESTController method getSubscriptionList.
@RequestMapping(value = "/subscribableTabs.json", method = RequestMethod.GET)
public ModelAndView getSubscriptionList(HttpServletRequest request) {
Map<String, Object> model = new HashMap<String, Object>();
/** Retrieve the IPerson and IAuthorizationPrincipal for the currently authenticated user */
IUserInstance userInstance = userInstanceManager.getUserInstance(request);
IPerson person = userInstance.getPerson();
AuthorizationService authService = AuthorizationService.instance();
IAuthorizationPrincipal principal = authService.newPrincipal(person.getUserName(), IPerson.class);
/**
* Build a collection of owner IDs for the fragments to which the authenticated user is
* subscribed
*/
// get the list of current subscriptions for this user
List<IUserFragmentSubscription> subscriptions = userFragmentSubscriptionDao.getUserFragmentInfo(person);
// transform it into the set of owners
Set<String> subscribedOwners = new HashSet<String>();
for (IUserFragmentSubscription subscription : subscriptions) {
if (subscription.isActive()) {
subscribedOwners.add(subscription.getFragmentOwner());
}
}
/**
* Iterate through the list of all currently defined DLM fragments and determine if the
* current user has permissions to subscribe to each. Any subscribable fragments will be
* transformed into a JSON-friendly bean and added to the model.
*/
final List<SubscribableFragment> jsonFragments = new ArrayList<SubscribableFragment>();
// get the list of fragment definitions from DLM
final List<FragmentDefinition> fragmentDefinitions = configurationLoader.getFragments();
final Locale locale = RequestContextUtils.getLocale(request);
// iterate through the list
for (FragmentDefinition fragmentDefinition : fragmentDefinitions) {
if (isSubscribable(fragmentDefinition, principal)) {
String owner = fragmentDefinition.getOwnerId();
// this fragment
if (principal.hasPermission("UP_FRAGMENT", "FRAGMENT_SUBSCRIBE", owner)) {
// create a JSON fragment bean and add it to our list
boolean subscribed = subscribedOwners.contains(owner);
final String name = getMessage("fragment." + owner + ".name", fragmentDefinition.getName(), locale);
final String description = getMessage("fragment." + owner + ".description", fragmentDefinition.getDescription(), locale);
SubscribableFragment jsonFragment = new SubscribableFragment(name, description, owner, subscribed);
jsonFragments.add(jsonFragment);
}
}
}
model.put("fragments", jsonFragments);
return new ModelAndView("json", model);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class MarketplaceRESTController method marketplaceEntriesFeed.
@RequestMapping(value = "/marketplace/entries.json", method = RequestMethod.GET)
public ModelAndView marketplaceEntriesFeed(HttpServletRequest request) {
final IPerson user = personManager.getPerson(request);
final Set<PortletCategory> empty = // Produces an complete/unfiltered collection
Collections.emptySet();
final Set<MarketplaceEntry> marketplaceEntries = marketplaceService.browseableMarketplaceEntriesFor(user, empty);
return new ModelAndView("json", "portlets", marketplaceEntries);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PortalEventFactoryImpl method createPortalEventBuilder.
/*
* Implementation
*/
protected PortalEvent.PortalEventBuilder createPortalEventBuilder(Object source, HttpServletRequest request) {
request = getCurrentPortalRequest(request);
final IPerson person = this.getPerson(request);
return this.createPortalEventBuilder(source, person, request);
}
Aggregations