Skip to content

Commit

Permalink
Merge branch 'hotfix/2020.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
PenghaiZhang committed Apr 3, 2020
2 parents a4859ee + 47622eb commit 6caa6f4
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 70 deletions.
5 changes: 5 additions & 0 deletions Source/Plugins/Core/com.equella.core/plugin-jpf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4786,6 +4786,11 @@
<parameter id="url-pattern" value="/*" />
<parameter id="order" value="800" />
</extension>
<extension plugin-id="com.tle.web.core" point-id="webFilter" id="sameSiteFilter">
<parameter id="bean" value="bean:com.tle.web.core.filter.SameSiteFilter" />
<parameter id="url-pattern" value="/*" />
<parameter id="order" value="850" />
</extension>
<extension plugin-id="com.tle.web.core" point-id="webServlet" id="doNotServeServlet">
<parameter id="bean" value="bean:com.tle.web.core.servlet.DoNotServeServlet" />
<parameter id="url-pattern" value="/WEB-INF/*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ protected void configure() {
bindInt("http.port", -1);
bindInt("https.port", -1);
bindInt("ajp.port", -1);
bindProp("ajp.address", "127.0.0.1");
// Makes sense for this to be in mandatory-config, but we have to provide a default, non-null
// value
bindProp("ajp.secret", "ignore");
bindBoolean("ajp.secret.required", true);
bindInt("tomcat.max.threads", -2);
install(new TomcatOptionalModule());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ public class TomcatServiceImpl implements TomcatService, StartupBean, TomcatRest
@Named("ajp.port")
private int ajpPort;

@Inject
@Named("ajp.address")
private String ajpAddress;

@Inject
@Named("ajp.secret")
private String ajpSecret;

@Inject
@Named("ajp.secret.required")
private boolean ajpSecretRequired;

@Inject
@Named("tomcat.max.threads")
private int maxThreads;
Expand Down Expand Up @@ -182,9 +194,13 @@ public void startup() {
if (ajpPort != -1) {
Connector connector = new Connector(useBio ? BIO_AJP : "AJP/1.3");
connector.setPort(ajpPort);
connector.setAttribute("requiredSecret", false);
if (!ajpSecret.equals("ignore")) {
connector.setAttribute("secret", ajpSecret);
}
connector.setAttribute("secretRequired", ajpSecretRequired);
connector.setAttribute("tomcatAuthentication", false);
connector.setAttribute("packetSize", "65536");
connector.setAttribute("address", ajpAddress);
setConnector(connector);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* The Apereo Foundation 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:
*
* 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 com.tle.web.core.filter;

import com.tle.core.guice.Bind;
import com.tle.web.dispatcher.AbstractWebFilter;
import com.tle.web.dispatcher.FilterResult;
import java.io.IOException;
import java.util.Collection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.HttpHeaders;

@Bind
public class SameSiteFilter extends AbstractWebFilter {

@Override
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (request.isSecure()) {
Collection<String> headers = response.getHeaders(HttpHeaders.SET_COOKIE);
boolean firstHeader = true;
for (String header : headers) {
if (firstHeader) {
response.setHeader(
HttpHeaders.SET_COOKIE, String.format("%s; %s", header, "SameSite=None"));
firstHeader = false;
continue;
}
response.addHeader(
HttpHeaders.SET_COOKIE, String.format("%s; %s", header, "SameSite=None"));
}
}
return FilterResult.FILTER_CONTINUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
import com.tle.webtests.pageobject.wizard.ContributePage;
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.pageobject.wizard.controls.UniversalControl;
import com.tle.webtests.pageobject.wizard.controls.universal.YouTubeUniversalControlType;
import com.tle.webtests.pageobject.wizard.controls.universal.UrlUniversalControlType;
import com.tle.webtests.test.AbstractCleanupTest;
import org.testng.annotations.Test;

@TestInstitution("fiveo")
public class ItemUnlock extends AbstractCleanupTest {
private static final String RENAMED_NAME = "A Video";
private static final String ORIGINAL_NAME =
"What is a function? | Functions and their graphs | Algebra II | Khan Academy";
private static final String DISPLAY_NAME = "Original Displayname";
private static final String RENAMED_NAME = "Google Renamed";
private static final String DISPLAY_NAME = "Google";
private final String LINK_ATTACHMENT_URL = "https://www.google.com";

@Test
public void unlockAndResumeItem() {
Expand All @@ -30,10 +29,10 @@ public void unlockAndResumeItem() {
new ContributePage(context).load().openWizard("Youtube Channel Testing Collection");
wizard.editbox(1, itemName);
UniversalControl control = wizard.universalControl(2);
YouTubeUniversalControlType youtube =
control.addDefaultResource(new YouTubeUniversalControlType(control));
youtube.search("Functions and their graphs", "The Khan Academy").selectVideo(1, ORIGINAL_NAME);
control.editResource(youtube.editPage(), ORIGINAL_NAME).setDisplayName(DISPLAY_NAME).save();

UrlUniversalControlType urlControl =
control.addDefaultResource(new UrlUniversalControlType(control));
urlControl.addUrl(LINK_ATTACHMENT_URL, DISPLAY_NAME);
SummaryPage item = wizard.save().publish();
assertTrue(item.attachments().attachmentExists(DISPLAY_NAME));

Expand All @@ -49,7 +48,7 @@ public void unlockAndResumeItem() {

control = wizard.universalControl(2);
control
.editResource(new YouTubeUniversalControlType(control), DISPLAY_NAME)
.editResource(new UrlUniversalControlType(control), DISPLAY_NAME)
.setDisplayName(RENAMED_NAME)
.save();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.tle.webtests.pageobject.wizard.ContributePage;
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.pageobject.wizard.controls.UniversalControl;
import com.tle.webtests.pageobject.wizard.controls.universal.YouTubeUniversalControlType;
import com.tle.webtests.pageobject.wizard.controls.universal.UrlUniversalControlType;
import com.tle.webtests.test.AbstractCleanupAutoTest;
import com.tle.webtests.test.files.Attachments;
import java.net.URL;
Expand All @@ -15,8 +15,8 @@
public class MaxAttachmentsTest extends AbstractCleanupAutoTest {
private static final String COLLECTION = "Max attachments restriction";
private final URL[] ATTACHMENTS = {Attachments.get("page.html"), Attachments.get("pageB.html")};
private final String ORIGINAL_TITLE = "Peter Andre - Mysterious Girl (Official Music Video)";
private final String YOUTUBE_TITLE = "good song";
private final String LINK_ATTACHMENT_URL = "https://www.google.com";
private final String LINK_ATTACHMENT_NAME = "Google";

@Test
public void maxFiles() {
Expand All @@ -25,19 +25,15 @@ public void maxFiles() {
wizard.editbox(1, fullName);
UniversalControl control = wizard.universalControl(2);

YouTubeUniversalControlType youTubeControl =
control.addResource(new YouTubeUniversalControlType(control));
youTubeControl.search("mysterious girl peter andre", null).selectVideo(1, ORIGINAL_TITLE);
control
.editResource(youTubeControl.editPage(), ORIGINAL_TITLE)
.setDisplayName(YOUTUBE_TITLE)
.save();
UrlUniversalControlType urlControl = control.addResource(new UrlUniversalControlType(control));
urlControl.addUrl(LINK_ATTACHMENT_URL, LINK_ATTACHMENT_NAME);

wizard.addFiles(2, false, ATTACHMENTS);
wizard.save().finishInvalid(wizard);
Assert.assertEquals(
wizard.getErrorMessage(2),
"This control is restricted to a maximum of 2 attachments. Please remove 1 attachment(s).");
control.deleteResource(YOUTUBE_TITLE);
control.deleteResource(LINK_ATTACHMENT_NAME);
wizard.save().publish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void testHtml5Player() {
public void testLTIViewer() {
SummaryPage summary = SearchPage.searchAndView(context, "lti viewer item");
LTIViewerPage lti =
summary.attachments().viewAttachment("youtube tool", new LTIViewerPage(context));
summary.attachments().viewAttachment("Vimeo tool", new LTIViewerPage(context));
lti.searchYoutube("ghosts");
lti.embedYTResult(4);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<status>0</status>
<time class="sql-timestamp">2009-04-16 15:49:15.643</time>
<from class="sql-timestamp">2009-04-16 15:49:02.687</from>
<until class="sql-timestamp">2020-04-01 11:00:00.0</until>
<until class="sql-timestamp">2100-12-31 11:00:00.0</until>
<course entityclass="com.tle.beans.item.cal.request.CourseInfo" uuid="313213e6-049a-8834-46d1-230be99f4490"/>
<citation>Harvard</citation>
<description>, &apos;Part Two&apos; in</description>
</com.tle.beans.activation.ActivateRequest>
</list>
</list>
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
<com.tle.beans.item.Item>
<id>217346</id>
<id>682604</id>
<uuid>2c5be16d-90ec-46ba-b137-724d595f838b</uuid>
<version>1</version>
<owner>adfcaf58-241b-4eca-9740-6a26d1c3dd58</owner>
<dateModified class="sql-timestamp">2015-05-18 10:49:14.041</dateModified>
<dateModified class="sql-timestamp">2020-03-17 16:13:10.392</dateModified>
<dateCreated class="sql-timestamp">2013-12-17 13:59:20.29</dateCreated>
<dateForIndex class="sql-timestamp">2015-05-18 10:49:14.041</dateForIndex>
<dateForIndex class="sql-timestamp">2020-03-17 16:13:10.392</dateForIndex>
<rating>-1.0</rating>
<moderating>false</moderating>
<status>LIVE</status>
<metadataSecurityTargets/>
<attachments>
<com.tle.beans.item.attachments.CustomAttachment>
<id>217365</id>
<id>682610</id>
<uuid>9b246ac5-1916-4ec7-8209-04e7e252479b</uuid>
<url></url>
<description>youtube tool</description>
<description>Vimeo tool</description>
<value1>lti</value1>
<thumbnail>https://www.edu-apps.org/tools/youtube/icon.png</thumbnail>
<thumbnail>https://www.edu-apps.org/assets/lti_public_resources/vimeo_icon.png</thumbnail>
<data>
<entry>
<string>SHARED_SECRET</string>
<string>secret</string>
</entry>
<entry>
<string>ICON_URL</string>
<string>https://www.edu-apps.org/assets/lti_public_resources/youtube_icon.png</string>
</entry>
<entry>
<string>SHARE_EMAIL</string>
<boolean>true</boolean>
Expand All @@ -35,17 +31,13 @@
<string>CONSUMER_KEY</string>
<string>key</string>
</entry>
<entry>
<string>CUSTOM_PARAMS</string>
<list/>
</entry>
<entry>
<string>SHARE_NAME</string>
<boolean>true</boolean>
</entry>
<entry>
<string>LAUNCH_URL</string>
<string>https://www.edu-apps.org/lti_public_resources/?tool_id=youtube</string>
<string>https://www.edu-apps.org/lti_public_resources/?tool_id=vimeo</string>
</entry>
<entry>
<string>EXTERNAL_TOOL_PROVIDER_UUID</string>
Expand All @@ -60,7 +52,7 @@
<collaborators/>
<referencedUrls/>
<moderation>
<id>217353</id>
<id>682607</id>
<liveApprovalDate class="sql-timestamp">2013-12-17 13:59:20.28</liveApprovalDate>
<start class="sql-timestamp">2013-12-17 14:44:26.98</start>
<lastAction class="sql-timestamp">2013-12-17 13:59:20.28</lastAction>
Expand All @@ -72,75 +64,79 @@
</moderation>
<history>
<com.tle.beans.item.HistoryEvent>
<id>217369</id>
<id>682611</id>
<user>adfcaf58-241b-4eca-9740-6a26d1c3dd58</user>
<date class="sql-timestamp">2013-12-17 13:59:20.28</date>
<applies>false</applies>
<type>contributed</type>
<state>DRAFT</state>
</com.tle.beans.item.HistoryEvent>
<com.tle.beans.item.HistoryEvent>
<id>217371</id>
<id>682612</id>
<user>adfcaf58-241b-4eca-9740-6a26d1c3dd58</user>
<date class="sql-timestamp">2013-12-17 13:59:20.28</date>
<applies>false</applies>
<type>edit</type>
<state>DRAFT</state>
</com.tle.beans.item.HistoryEvent>
<com.tle.beans.item.HistoryEvent>
<id>217373</id>
<id>682613</id>
<user>adfcaf58-241b-4eca-9740-6a26d1c3dd58</user>
<date class="sql-timestamp">2013-12-17 13:59:20.28</date>
<applies>false</applies>
<type>statechange</type>
<state>LIVE</state>
</com.tle.beans.item.HistoryEvent>
<com.tle.beans.item.HistoryEvent>
<id>217374</id>
<id>682614</id>
<user>adfcaf58-241b-4eca-9740-6a26d1c3dd58</user>
<date class="sql-timestamp">2014-01-08 11:15:19.267</date>
<applies>false</applies>
<type>edit</type>
<state>LIVE</state>
</com.tle.beans.item.HistoryEvent>
<com.tle.beans.item.HistoryEvent>
<id>217494</id>
<id>682615</id>
<user>adfcaf58-241b-4eca-9740-6a26d1c3dd58</user>
<date class="sql-timestamp">2015-05-18 10:49:14.041</date>
<applies>false</applies>
<type>edit</type>
<state>LIVE</state>
</com.tle.beans.item.HistoryEvent>
<com.tle.beans.item.HistoryEvent>
<id>682721</id>
<user>TLE_ADMINISTRATOR</user>
<date class="sql-timestamp">2020-03-17 16:13:10.392</date>
<applies>false</applies>
<type>edit</type>
<state>LIVE</state>
</com.tle.beans.item.HistoryEvent>
</history>
<comments/>
<sharePasses/>
<acceptances/>
<treeNodes/>
<notifications/>
<name>
<id>217355</id>
<id>682608</id>
<strings>
<entry>
<string>en_US</string>
<string>en_GB</string>
<com.tle.beans.entity.LanguageString>
<id>217496</id>
<locale>en_US</locale>
<id>682722</id>
<locale>en_GB</locale>
<priority>2</priority>
<text>lti viewer item</text>
<bundle reference="../../../.."/>
</com.tle.beans.entity.LanguageString>
</entry>
</strings>
</name>
<description>
<id>217495</id>
<strings/>
</description>
<totalFileSize>0</totalFileSize>
<navigationSettings>
<showNextPrev>false</showNextPrev>
<showSplitOption>false</showSplitOption>
<manualNavigation>false</manualNavigation>
</navigationSettings>
<thumb>default</thumb>
</com.tle.beans.item.Item>
</com.tle.beans.item.Item>
Loading

0 comments on commit 6caa6f4

Please sign in to comment.