-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UP-4179: uPortal 5 project overhault with a Gradle-based build #715
Merged
Merged
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
7366a59
UP-4179: Update the version of the master branch to 5.0.0-SNAPSHOT in…
drewwills fa6de1d
UP-4179: Add a Gradle Wrapper based on the latest version of Gradle t…
drewwills 8e027b1
UP-4179: Update distributionUrl in gradle-wrapper.properties to use t…
drewwills bc4c0d3
UP-4179: Getting started with Gradle; adding...
drewwills 8e0b9a7
UP-4728: Add submodule uPortal-soffit ported from https://github.com/…
drewwills 9b33dc6
UP-4728: Undo IntelliJ's butchered import order; moce the CACHE_CONT…
drewwills 86ca33a
UP-4728: Add submodule uPortal-soffit-connector ported from https://g…
drewwills 9c56a44
UP-4728: Add submodule uPortal-soffit-renderer ported from https://gi…
drewwills 965625c
UP-4728: Add the connector-portlet.xmlfile to uPortal-soffit-connecto…
drewwills 03a9c77
UP-4728: Add support for Soffit to uPortal
drewwills 08a7215
UP-4179: Instruct Travis CI to use the Maven dependency step, instea…
drewwills 4ab5fc7
UP-4179: Instruct Travis CI to use the Maven dependency step, instea…
drewwills ae9c898
UP-4179: Add the following (3) Gradle-based submodules and move some…
drewwills c91a8f8
UP-4728: Use the 'compile project()' dependency style for cross-modu…
drewwills a87baae
UP-4179: (Interim step) move packages 'org.jasig.portal.aggr' and 'o…
drewwills e72c3e9
UP-4179: (Interim step) move the following packages out of 'org.jasi…
drewwills fc3f8d2
Remove channelRegistry.xml and channelRegistry.dtd; they are (unused…
drewwills 80bbf97
UP-4179: (Interim step) move the o.j.p.dao.usertype package out of '…
drewwills 6af06b6
UP-4179: (Interim step) move the o.j.p.events package -- and all subp…
drewwills 1a05df7
UP-4179: (Interim step) move the o.j.p.fragment and o.j.p.groups pack…
drewwills 6812068
UP-4179: (Interim step) move the o.j.p.hibernate and o.j.p.i18n packa…
drewwills cd93e25
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 8456060
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 0e65cca
UP-4179: (Interim step) move the remainer of the o.j.p.io package out…
drewwills dd4624c
UP-4179: (Interim step) move the o.j.p.jgroups -- and all subpackages…
drewwills e36dcc9
UP-4179: (Interim step) move the o.j.p.jmx and o.j.p.jpa packages -- …
drewwills 661efa5
UP-4179: (Interim step) move the o.j.p.json package -- and all subpac…
drewwills 723661f
UP-4179: (Interim step) move the o.j.p.layout.dao and the o.j.p.layou…
drewwills 75efa44
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills a0a29f5
UP-4179: (Interim step) move the o.j.p.ldap and the o.j.p.logging pac…
drewwills 2e3b7a8
UP-4179: (Interim step) move the o.j.p.permission and the o.j.p.perso…
drewwills bbd6f13
UP-4179: (Interim step) move the o.j.p.portlet.container package -- a…
drewwills edf11b9
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 283fd45
UP-4179: (Interim step) move the o.j.p.portlet.om package -- and all …
drewwills 1389b9b
UP-4179: Move several Import/Export files that don't need to be in '…
drewwills a127ec9
UP-4179: (Interim step) move the o.j.p.portlet.registry package -- an…
drewwills b1122cf
UP-4179: (Interim step) move the o.j.p.portlet.rendering package -- a…
drewwills 4bb7715
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 25a675e
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 0a62393
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills a6f1e9a
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills fbd2ffe
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 89019c2
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills c17a743
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 2da66ec
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 68e59dd
UP-4179: (Interim step) move the o.j.p.rendering package -- and all s…
drewwills 542a01f
UP-4179: (Interim step) move the o.j.p.rest package -- and all subpac…
drewwills b5e1947
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills ef24fca
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 4c1eb4c
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills e64b9c3
UP-4179: (Interim step) move the o.j.p.spring package -- and all subp…
drewwills c5365b6
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 20c20d0
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 01ebf39
UP-4179: (Interim step) move the following packages (and subpackages,…
drewwills 2c97deb
UP-4179: (Interim step) move the o.j.p.utils package -- and all subpa…
drewwills 63ab3d5
UP-4179: (Interim step) move the following packages out of 'org.jasig…
drewwills 76cf73b
UP-4179: (Interim step) move the 'export-*.crn' files from src/main/r…
drewwills 893d166
UP-4179: Delete folder uportal-war/src/main/resources/org/jasig/port…
drewwills 22cd947
UP-4179: Delete folder uportal-war/src/main/resources/org/jasig/port…
drewwills 67c8fba
UP-4179: (Interim step) move remaining items (portal/groups) out of u…
drewwills 85d4c86
UP-4179: (Interim step) move remaining items out of uportal-war/src/t…
drewwills 62085b9
UP-4179: Remove from 'uportal-war/src/test/resources/org/jasig/porta…
drewwills 9b23b26
UP-4179: Re-package sources within uportal-portlets-overlay/cas from…
drewwills be64fbe
UP-4179: Re-package sources within uportal-search-api/src/ from 'org…
drewwills d9ea1ec
UP-4179: grep for org.jasig.portal and verify that remaining occurre…
drewwills e945df5
UP-4179: Remove (accidentally added) files in .gradle/
drewwills 9be12f0
UP-4179: Rename a couple *.entity-type.xml files replacing 'jasig' w…
drewwills 006bc48
UP-4179: Revert any (IDE-generated) changes to tenant sampledata and…
drewwills 85de7eb
Fix some license headers
drewwills 75787b8
UP-4179: Revert unwanted changes to uportal-war/src/test/resources/o…
drewwills File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
uportal-war/src/main/java/org/jasig/portal/soffit/AuthorizationHeaderProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/** | ||
* Licensed to Apereo under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work | ||
* for additional information regarding copyright ownership. | ||
* Apereo licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a | ||
* copy of the License at the following location: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.jasig.portal.soffit; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.Map.Entry; | ||
|
||
import javax.portlet.PortletSession; | ||
import javax.portlet.RenderRequest; | ||
import javax.portlet.RenderResponse; | ||
|
||
import org.apache.http.Header; | ||
import org.apache.http.message.BasicHeader; | ||
import org.apereo.portal.soffit.Headers; | ||
import org.apereo.portal.soffit.connector.AbstractHeaderProvider; | ||
import org.apereo.portal.soffit.model.v1_0.Bearer; | ||
import org.apereo.portal.soffit.service.BearerService; | ||
import org.jasig.portal.groups.IEntityGroup; | ||
import org.jasig.portal.groups.IGroupMember; | ||
import org.jasig.portal.security.IPerson; | ||
import org.jasig.portal.services.GroupService; | ||
import org.jasig.services.persondir.IPersonAttributeDao; | ||
import org.jasig.services.persondir.IPersonAttributes; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
/** | ||
* Prepares the standard HTTP Authorization header. This component is defined | ||
* explicitly in the portlet context (not by annotation). | ||
* | ||
* @since 5.0 | ||
* @author drewwills | ||
*/ | ||
public class AuthorizationHeaderProvider extends AbstractHeaderProvider { | ||
|
||
@Autowired | ||
private IPersonAttributeDao personAttributeDao; | ||
|
||
@Autowired | ||
private BearerService bearerService; | ||
|
||
@Override | ||
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) { | ||
|
||
// Username | ||
final String username = getUsername(renderRequest); | ||
|
||
// Attributes | ||
final Map<String,List<String>> attributes = new HashMap<>(); | ||
final IPersonAttributes person = personAttributeDao.getPerson(username); | ||
if (person != null) { | ||
for (Entry<String, List<Object>> y : person.getAttributes().entrySet()) { | ||
final List<String> values = new ArrayList<>(); | ||
for (Object value : y.getValue()) { | ||
if (value instanceof String) { | ||
values.add((String) value); | ||
} | ||
} | ||
attributes.put(y.getKey(), values); | ||
} | ||
} | ||
logger.debug("Found the following user attributes for username='{}': {}", username, attributes); | ||
|
||
// Groups | ||
final List<String> groups = new ArrayList<>(); | ||
final IGroupMember groupMember = GroupService.getGroupMember(username, IPerson.class); | ||
if (groupMember != null) { | ||
Set<IEntityGroup> ancestors = groupMember.getAncestorGroups(); | ||
for (IEntityGroup g : ancestors) { | ||
groups.add(g.getName()); | ||
} | ||
} | ||
logger.debug("Found the following group affiliations for username='{}': {}", username, groups); | ||
|
||
// Expiration of the Bearer token | ||
final PortletSession portletSession = renderRequest.getPortletSession(); | ||
final Date expires = new Date( | ||
portletSession.getLastAccessedTime() + ((long) portletSession.getMaxInactiveInterval() * 1000L) | ||
); | ||
|
||
// Authorization header | ||
final Bearer bearer = bearerService.createBearer(username, attributes, groups, expires); | ||
final Header rslt = new BasicHeader( | ||
Headers.AUTHORIZATION.getName(), | ||
Headers.BEARER_TOKEN_PREFIX + bearer.getEncryptedToken()); | ||
logger.debug("Produced the following Authorization header for username='{}': {}", username, rslt); | ||
|
||
return rslt; | ||
|
||
} | ||
|
||
} |
140 changes: 140 additions & 0 deletions
140
uportal-war/src/main/java/org/jasig/portal/soffit/DefinitionHeaderProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/** | ||
* Licensed to Apereo under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work | ||
* for additional information regarding copyright ownership. | ||
* Apereo licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a | ||
* copy of the License at the following location: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.jasig.portal.soffit; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
import javax.portlet.RenderRequest; | ||
import javax.portlet.RenderResponse; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.apache.http.Header; | ||
import org.apache.http.message.BasicHeader; | ||
import org.apereo.portal.soffit.Headers; | ||
import org.apereo.portal.soffit.connector.AbstractHeaderProvider; | ||
import org.apereo.portal.soffit.model.v1_0.Definition; | ||
import org.apereo.portal.soffit.service.DefinitionService; | ||
import org.jasig.portal.i18n.ILocaleStore; | ||
import org.jasig.portal.i18n.LocaleManager; | ||
import org.jasig.portal.portlet.marketplace.IMarketplaceService; | ||
import org.jasig.portal.portlet.marketplace.MarketplacePortletDefinition; | ||
import org.jasig.portal.portlet.om.IPortletDefinition; | ||
import org.jasig.portal.portlet.om.IPortletDefinitionParameter; | ||
import org.jasig.portal.portlet.om.IPortletWindow; | ||
import org.jasig.portal.portlet.om.IPortletWindowId; | ||
import org.jasig.portal.portlet.om.PortletCategory; | ||
import org.jasig.portal.portlet.registry.IPortletWindowRegistry; | ||
import org.jasig.portal.security.IPerson; | ||
import org.jasig.portal.security.IPersonManager; | ||
import org.jasig.portal.url.IPortalRequestUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
/** | ||
* Prepares the custom HTTP X-Soffit-Definition header. This component is | ||
* defined explicitly in the portlet context (not by annotation). | ||
* | ||
* @since 5.0 | ||
* @author drewwills | ||
*/ | ||
public class DefinitionHeaderProvider extends AbstractHeaderProvider { | ||
|
||
@Autowired | ||
private IPortalRequestUtils portalRequestUtils; | ||
|
||
@Autowired | ||
private IPortletWindowRegistry portletWindowRegistry; | ||
|
||
@Autowired | ||
private IMarketplaceService marketplaceService; | ||
|
||
@Autowired | ||
private IPersonManager personManager; | ||
|
||
@Autowired | ||
private ILocaleStore localeStore; | ||
|
||
@Autowired | ||
private DefinitionService definitionService; | ||
|
||
@Override | ||
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) { | ||
|
||
// Username | ||
final String username = getUsername(renderRequest); | ||
|
||
// Obtain the MarketplacePortletDefinition for this soffit | ||
final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest(); | ||
final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID()); | ||
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId); | ||
final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition(); | ||
final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef); | ||
|
||
final IPerson user = personManager.getPerson(httpr); | ||
final Locale locale = getUserLocale(user); | ||
|
||
// Title | ||
final String title = mpdef.getTitle(locale.toString()); | ||
|
||
// FName | ||
final String fname = mpdef.getFName(); | ||
|
||
// Description | ||
final String description = mpdef.getDescription(locale.toString()); | ||
|
||
// Categories | ||
List<String> categories = new ArrayList<>(); | ||
for (PortletCategory pc : mpdef.getCategories()) { | ||
categories.add(pc.getName()); | ||
} | ||
|
||
// Parameters | ||
Map<String,List<String>> parameters = new HashMap<>(); | ||
for (IPortletDefinitionParameter param : mpdef.getParameters()) { | ||
parameters.put(param.getName(), Collections.singletonList(param.getValue())); | ||
} | ||
|
||
final Definition definition = definitionService.createDefinition(title, fname, | ||
description, categories, parameters, username, getExpiration(renderRequest)); | ||
final Header rslt = new BasicHeader( | ||
Headers.DEFINITION.getName(), | ||
definition.getEncryptedToken()); | ||
logger.debug("Produced the following {} header for username='{}': {}", Headers.DEFINITION.getName(), username, rslt); | ||
|
||
return rslt; | ||
} | ||
|
||
/* | ||
* Implementation | ||
*/ | ||
|
||
private Locale getUserLocale(IPerson user) { | ||
// get user locale | ||
Locale[] locales = localeStore.getUserLocales(user); | ||
LocaleManager localeManager = new LocaleManager(user, locales); | ||
Locale rslt = localeManager.getLocales()[0]; | ||
return rslt; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a temporary measure for before move to gradle, can this be removed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet. Probably we will need that target as long as we need the
build.xml
file. We'll be able to remove that file entirely after Phase II (though maybe not immediately).