Skip to content
Snippets Groups Projects
Commit 67e13cbc authored by uhensler's avatar uhensler
Browse files

OO-3797: Basic implementation for edu-sharing TinyMCE plugin

- Select resources from edu-sharing
- Use edu-sharing rendering service to display the resources
- Synchronize usage between OpenOLAT and edu-sharing
- Exchange configuration (metadata) between OpenOLAt and edu-sharing
parent fc0870a9
No related branches found
No related tags found
No related merge requests found
Showing
with 1260 additions and 10 deletions
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
<name>OpenOLAT LMS</name> <name>OpenOLAT LMS</name>
<url>https://www.openolat.com</url> <url>https://www.openolat.com</url>
<description> <description>
Welcome to the OpenOLAT (Open Online Learning And Training) Developer Project Site. This site Welcome to the OpenOLAT (Open Online Learning And Training) Developer Project Site. This site
contains materials chiefly of concern to developers (e.g., unit testing and SCA output etc.) contains materials chiefly of concern to developers (e.g., unit testing and SCA output etc.)
and is rebuilt periodically on a regular basis. The site structure is divided between and is rebuilt periodically on a regular basis. The site structure is divided between
project information (e.g., infrastructure, mailing lists, repositories etc.) and reports project information (e.g., infrastructure, mailing lists, repositories etc.) and reports
(e.g., unit testing, SCAs etc.) (e.g., unit testing, SCAs etc.)
</description> </description>
...@@ -296,6 +296,13 @@ ...@@ -296,6 +296,13 @@
<include>${basedir}/target/jquery/tinymce4/tinymce/plugins/quotespliter/plugin.min.js</include> <include>${basedir}/target/jquery/tinymce4/tinymce/plugins/quotespliter/plugin.min.js</include>
</includes> </includes>
</aggregation> </aggregation>
<aggregation>
<output>${basedir}/src/main/webapp/static/js/tinymce4/tinymce/plugins/olatedusharing/plugin.min.js</output>
<removeIncluded>false</removeIncluded>
<includes>
<include>${basedir}/target/jquery/tinymce4/tinymce/plugins/olatedusharing/plugin.min.js</include>
</includes>
</aggregation>
<aggregation> <aggregation>
<output>${basedir}/src/main/webapp/static/js/jquery/openolat/jquery.statistics.chart.min.js</output> <output>${basedir}/src/main/webapp/static/js/jquery/openolat/jquery.statistics.chart.min.js</output>
<removeIncluded>false</removeIncluded> <removeIncluded>false</removeIncluded>
...@@ -1849,6 +1856,11 @@ ...@@ -1849,6 +1856,11 @@
<artifactId>viterows</artifactId> <artifactId>viterows</artifactId>
<version>9.0</version> <version>9.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.openolat</groupId>
<artifactId>edusharingws</artifactId>
<version>4.1.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
......
...@@ -58,6 +58,9 @@ ...@@ -58,6 +58,9 @@
<entry key="/survey/"> <entry key="/survey/">
<ref bean="evaluationformwebbean" /> <ref bean="evaluationformwebbean" />
</entry> </entry>
<entry key="/edusharing/">
<ref bean="edusharingwebbean" />
</entry>
<entry key="/podcast/"> <entry key="/podcast/">
<ref bean="podcastMediaBean" /> <ref bean="podcastMediaBean" />
</entry> </entry>
...@@ -253,6 +256,9 @@ ...@@ -253,6 +256,9 @@
<bean id="evaluationformwebbean" <bean id="evaluationformwebbean"
class="org.olat.modules.forms.EvaluationFormDispatcher" /> class="org.olat.modules.forms.EvaluationFormDispatcher" />
<bean id="edusharingwebbean"
class="org.olat.modules.edusharing.EdusharingDispatcher" />
<!-- podcast media dispatcher --> <!-- podcast media dispatcher -->
<bean id="podcastMediaBean" class="org.olat.modules.webFeed.dispatching.FeedMediaDispatcher"> <bean id="podcastMediaBean" class="org.olat.modules.webFeed.dispatching.FeedMediaDispatcher">
<property name="feedManager" ref="feedManager"/> <property name="feedManager" ref="feedManager"/>
......
...@@ -21,6 +21,7 @@ package org.olat.core.gui.components.form.flexible.impl.elements.richText; ...@@ -21,6 +21,7 @@ package org.olat.core.gui.components.form.flexible.impl.elements.richText;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -41,6 +42,7 @@ import org.olat.core.gui.render.StringOutput; ...@@ -41,6 +42,7 @@ import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.themes.Theme; import org.olat.core.gui.themes.Theme;
import org.olat.core.gui.translator.Translator; import org.olat.core.gui.translator.Translator;
import org.olat.core.helpers.Settings; import org.olat.core.helpers.Settings;
import org.olat.core.id.Identity;
import org.olat.core.logging.OLog; import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.util.CodeHelper; import org.olat.core.util.CodeHelper;
...@@ -48,11 +50,15 @@ import org.olat.core.util.Formatter; ...@@ -48,11 +50,15 @@ import org.olat.core.util.Formatter;
import org.olat.core.util.UserSession; import org.olat.core.util.UserSession;
import org.olat.core.util.Util; import org.olat.core.util.Util;
import org.olat.core.util.WebappHelper; import org.olat.core.util.WebappHelper;
import org.olat.core.util.filter.Filter;
import org.olat.core.util.i18n.I18nManager; import org.olat.core.util.i18n.I18nManager;
import org.olat.core.util.vfs.LocalFolderImpl; import org.olat.core.util.vfs.LocalFolderImpl;
import org.olat.core.util.vfs.VFSContainer; import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSContainerMapper; import org.olat.core.util.vfs.VFSContainerMapper;
import org.olat.core.util.vfs.VFSManager; import org.olat.core.util.vfs.VFSManager;
import org.olat.modules.edusharing.EdusharingFilter;
import org.olat.modules.edusharing.EdusharingModule;
import org.olat.modules.edusharing.EdusharingProvider;
/** /**
* Description:<br> * Description:<br>
...@@ -169,6 +175,8 @@ public class RichTextConfiguration implements Disposable { ...@@ -169,6 +175,8 @@ public class RichTextConfiguration implements Disposable {
private List<TextMode> textModes = Collections.singletonList(TextMode.formatted); private List<TextMode> textModes = Collections.singletonList(TextMode.formatted);
private RichTextConfigurationDelegate additionalConfiguration; private RichTextConfigurationDelegate additionalConfiguration;
private Collection<Filter> valueFilters = new ArrayList<>(1);
public RichTextConfiguration(Locale locale) { public RichTextConfiguration(Locale locale) {
this.locale = locale; this.locale = locale;
tinyConfig = TinyConfig.minimalisticConfig; tinyConfig = TinyConfig.minimalisticConfig;
...@@ -882,6 +890,23 @@ public class RichTextConfiguration implements Disposable { ...@@ -882,6 +890,23 @@ public class RichTextConfiguration implements Disposable {
setQuotedConfigValue("custom_elements", "~textentryinteraction,~hottext"); setQuotedConfigValue("custom_elements", "~textentryinteraction,~hottext");
setQuotedConfigValue(EXTENDED_VALID_ELEMENTS, "script[src|type|defer],textentryinteraction[*],hottext[*]"); setQuotedConfigValue(EXTENDED_VALID_ELEMENTS, "script[src|type|defer],textentryinteraction[*],hottext[*]");
} }
public void enableEdusharing(Identity identity, EdusharingProvider provider) {
EdusharingModule edusharingModule = CoreSpringFactory.getImpl(EdusharingModule.class);
if (edusharingModule.isEnabled()) {
tinyConfig = tinyConfig.enableEdusharing();
EdusharingFilter filter = new EdusharingFilter(identity, provider);
addValueFilter(filter);
}
}
public void addValueFilter(Filter filter) {
valueFilters.add(filter);
}
Collection<Filter> getValueFilters() {
return valueFilters;
}
/** /**
* Set a tiny configuration value that must not be quoted with quotes, e.g. * Set a tiny configuration value that must not be quoted with quotes, e.g.
......
...@@ -105,16 +105,19 @@ public class RichTextElementImpl extends AbstractTextElement implements ...@@ -105,16 +105,19 @@ public class RichTextElementImpl extends AbstractTextElement implements
} }
/** /**
* @see org.olat.core.gui.components.form.flexible.impl.elements.AbstractTextElement#getValue() * The returned value is XSS save and does not contain executable JavaScript
* The returned value is XSS save and * code. Further all value filter of the configuration are applied. If you want
* does not contain executable JavaScript code. If you want to get the raw * to get the raw user data, use the getRawValue() method.
* user data use the getRawValue() method.
*/ */
@Override @Override
public String getValue() { public String getValue() {
String val = getRawValue(); String val = getRawValue();
Filter xssFilter = FilterFactory.getXSSFilter(val.length() + 1); Filter xssFilter = FilterFactory.getXSSFilter(val.length() + 1);
return xssFilter.filter(val); val = xssFilter.filter(val);
for (Filter filter : configuration.getValueFilters()) {
val = filter.filter(val);
}
return val;
} }
@Override @Override
......
...@@ -202,6 +202,27 @@ public class TinyConfig { ...@@ -202,6 +202,27 @@ public class TinyConfig {
return disableFeature("olatmatheditor"); return disableFeature("olatmatheditor");
} }
public TinyConfig enableEdusharing() {
return enableFeature("olatedusharing")
.endableButton("olatedusharing");
}
public TinyConfig disableEdusharing() {
return disableFeature("olatedusharing")
.disableButtons("olatedusharing");
}
public TinyConfig endableButton(String button) {
TinyConfig config = this;
if (!tool1.contains(button)) {
String clonedTools = tool1 + " " + button;
config = new TinyConfig(plugins, menu, clonedTools);
}
return config;
}
public TinyConfig disableButtons(String button) { public TinyConfig disableButtons(String button) {
TinyConfig config = this; TinyConfig config = this;
if(tool1.contains(button)) { if(tool1.contains(button)) {
......
...@@ -24,11 +24,11 @@ import org.olat.core.util.filter.impl.AddBaseURLToMediaRelativeURLFilter; ...@@ -24,11 +24,11 @@ import org.olat.core.util.filter.impl.AddBaseURLToMediaRelativeURLFilter;
import org.olat.core.util.filter.impl.ConditionalHTMLCommentsFilter; import org.olat.core.util.filter.impl.ConditionalHTMLCommentsFilter;
import org.olat.core.util.filter.impl.NekoHTMLFilter; import org.olat.core.util.filter.impl.NekoHTMLFilter;
import org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter; import org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter;
import org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter.Variant;
import org.olat.core.util.filter.impl.SimpleHTMLTagsFilter; import org.olat.core.util.filter.impl.SimpleHTMLTagsFilter;
import org.olat.core.util.filter.impl.SmileysCssToDataUriFilter; import org.olat.core.util.filter.impl.SmileysCssToDataUriFilter;
import org.olat.core.util.filter.impl.XMLValidCharacterFilter; import org.olat.core.util.filter.impl.XMLValidCharacterFilter;
import org.olat.core.util.filter.impl.XMLValidEntityFilter; import org.olat.core.util.filter.impl.XMLValidEntityFilter;
import org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter.Variant;
/** /**
* Description:<br> * Description:<br>
......
...@@ -81,7 +81,8 @@ ...@@ -81,7 +81,8 @@
<regexp name="olatInternalURL" <regexp name="olatInternalURL"
value="javascript:parent\.gotonode\(\d+\)" /> value="javascript:parent\.gotonode\(\d+\)" />
<regexp name="onsiteURL" <regexp name="onsiteURL"
value="([\p{L}\p{N}\p{Zs}/\.\?=&amp;\-~_])+" /> value="([\p{L}\p{N}\p{Zs}/\.\?=&amp;\-~_]|ccrep:)+" />
<!-- value="([\p{L}\p{N}\p{Zs}/\.\?=&amp;\-~_])+" /> -->
<regexp name="offsiteURL" <regexp name="offsiteURL"
value="(\s)*(http(s?)://|mailto:)[A-Za-z0-9]+[~a-zA-Z0-9-_\.@#$%&amp;;&Agrave;;&Aacute;&Acirc;&Atilde;&Auml;&Egrave;&Eacute;&Ecirc;&Euml;&Igrave;&Iacute;&Icirc;&Iuml;&Ograve;&Oacute;&Ocirc;&Otilde;&Ouml;&Ugrave;&Uacute;&Ucirc;&Uuml;&agrave;&aacute;&acirc;&atilde;&auml;&egrave;&eacute;&ecirc;&euml;&igrave;&iacute;&icirc;&iuml;&ograve;&oacute;&ocirc;&ouml;&ugrave;&uacute;&ucirc;&uuml;;:,\?=/\+!]*(\s)*" /> value="(\s)*(http(s?)://|mailto:)[A-Za-z0-9]+[~a-zA-Z0-9-_\.@#$%&amp;;&Agrave;;&Aacute;&Acirc;&Atilde;&Auml;&Egrave;&Eacute;&Ecirc;&Euml;&Igrave;&Iacute;&Icirc;&Iuml;&Ograve;&Oacute;&Ocirc;&Otilde;&Ouml;&Ugrave;&Uacute;&Ucirc;&Uuml;&agrave;&aacute;&acirc;&atilde;&auml;&egrave;&eacute;&ecirc;&euml;&igrave;&iacute;&icirc;&iuml;&ograve;&oacute;&ocirc;&ouml;&ugrave;&uacute;&ucirc;&uuml;;:,\?=/\+!]*(\s)*" />
...@@ -354,6 +355,53 @@ ...@@ -354,6 +355,53 @@
<literal value="colgroup" /> <literal value="colgroup" />
</literal-list> </literal-list>
</attribute> </attribute>
<!-- edu-sharing data attributes -->
<attribute name="data-es_identifier">
<regexp-list>
<regexp value="[a-zA-Z0-9_\-\:]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_objecturl">
<regexp-list>
<regexp value="[a-zA-Z0-9_\-\:\/]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_version">
<regexp-list>
<regexp value="[a-zA-Z0-9_\-\:\.]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_version_current">
<regexp-list>
<regexp value="[a-zA-Z0-9_\-\:\.]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_mimetype">
<regexp-list>
<regexp value="[a-zA-Z0-9_\-\:\/]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_mediatype">
<regexp-list>
<regexp value="[a-zA-Z0-9_\-\:]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_width">
<regexp-list>
<regexp value="[0-9]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_height">
<regexp-list>
<regexp value="[0-9]+"/>
</regexp-list>
</attribute>
<attribute name="data-es_first_edit">
<regexp-list>
<regexp value="true|false"/>
</regexp-list>
</attribute>
</common-attributes> </common-attributes>
...@@ -475,6 +523,17 @@ ...@@ -475,6 +523,17 @@
<literal value="nofollow" /> <literal value="nofollow" />
</literal-list> </literal-list>
</attribute> </attribute>
<!-- edu-sharing data attributes -->
<attribute name="data-es_identifier" />
<attribute name="data-es_objecturl" />
<attribute name="data-es_version" />
<attribute name="data-es_version_current" />
<attribute name="data-es_mimetype" />
<attribute name="data-es_mediatype" />
<attribute name="data-es_width" />
<attribute name="data-es_height" />
<attribute name="data-es_first_edit" />
</tag> </tag>
<!-- List tags <!-- List tags
...@@ -523,6 +582,17 @@ ...@@ -523,6 +582,17 @@
<regexp name="number" /> <regexp name="number" />
</regexp-list> </regexp-list>
</attribute> </attribute>
<!-- edu-sharing data attributes -->
<attribute name="data-es_identifier" />
<attribute name="data-es_objecturl" />
<attribute name="data-es_version" />
<attribute name="data-es_version_current" />
<attribute name="data-es_mimetype" />
<attribute name="data-es_mediatype" />
<attribute name="data-es_width" />
<attribute name="data-es_height" />
<attribute name="data-es_first_edit" />
</tag> </tag>
......
...@@ -81,6 +81,26 @@ ...@@ -81,6 +81,26 @@
</property> </property>
</bean> </bean>
<!-- edu-sharing admin. panel -->
<bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints">
<property name="order" value="8253" />
<property name="actionController">
<bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype">
<property name="className" value="org.olat.modules.edusharing.ui.EdusharingAdminController"/>
</bean>
</property>
<property name="navigationKey" value="edusharing" />
<property name="i18nActionKey" value="admin.menu.title"/>
<property name="i18nDescriptionKey" value="admin.menu.title.alt"/>
<property name="translationPackage" value="org.olat.modules.edusharing.ui"/>
<property name="parentTreeNodeIdentifier" value="externalToolsParent" />
<property name="extensionPoints">
<list>
<value>org.olat.admin.SystemAdminMainController</value>
</list>
</property>
</bean>
<!-- Goto admin. panel --> <!-- Goto admin. panel -->
<bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints">
<property name="order" value="8218" /> <property name="order" value="8218" />
......
#Wed Apr 19 14:49:09 CEST 2017 #Wed Apr 19 14:49:09 CEST 2017
admin.baseUrl=URL LTI resource admin.baseUrl=URL LTI resource
admin.baseUrlHelpText=Use '%s' as a placeholder for the alias of the flashcards. admin.baseUrlHelpText=Use '%s' as a placeholder for the alias of the flashcards.
admin.description=card2brain is the multi-channel application for methodical learning in all fields of study. On card2brain, you can create flashcards and study them according to Sebastian Leitner's well-known system of five compartments. Further information is available on the <a href\="http\://card2brain.ch" target\=_blank>website</a> of card2brain. admin.description=card2brain is the multi-channel application for methodical learning in all fields of study. On card2brain, you can create flashcards and study them according to Sebastian Leitner's well-known system of five compartments. Further information is available on the <a href\="https\://edu-sharing.com/" target\=_blank>website</a> of card2brain.
admin.enabled=Module "card2brain" admin.enabled=Module "card2brain"
admin.enterpriseKey=API Key admin.enterpriseKey=API Key
admin.enterpriseLoginEnabled=Enterprise Login admin.enterpriseLoginEnabled=Enterprise Login
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* Initial date: 9 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*/
public class CreateUsageParameter {
private final String resourceId;
private final String eduRef;
private final String user;
private final String courseId;
private String userMail;
private XMLGregorianCalendar fromUsed;
private XMLGregorianCalendar toUsed;
private int distinctPersons;
private String version;
private String xmlParams;
public CreateUsageParameter(String resourceId, String eduRef, String user, String courseId) {
this.resourceId = resourceId;
this.eduRef = eduRef;
this.user = user;
this.courseId = courseId;
}
public String getResourceId() {
return resourceId;
}
public String getEduRef() {
return eduRef;
}
public String getUser() {
return user;
}
public String getCourseId() {
return courseId;
}
public String getUserMail() {
return userMail;
}
public void setUserMail(String userMail) {
this.userMail = userMail;
}
public XMLGregorianCalendar getFromUsed() {
return fromUsed;
}
public void setFromUsed(XMLGregorianCalendar fromUsed) {
this.fromUsed = fromUsed;
}
public XMLGregorianCalendar getToUsed() {
return toUsed;
}
public void setToUsed(XMLGregorianCalendar toUsed) {
this.toUsed = toUsed;
}
public int getDistinctPersons() {
return distinctPersons;
}
public void setDistinctPersons(int distinctPersons) {
this.distinctPersons = distinctPersons;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getXmlParams() {
return xmlParams;
}
public void setXmlParams(String xmlParams) {
this.xmlParams = xmlParams;
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
/**
* Initial date: 9 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*/
public class DeleteUsageParameter {
private final String resourceId;
private final String eduRef;
private final String user;
private final String courseId;
public DeleteUsageParameter(String resourceId, String eduRef, String user, String courseId) {
this.eduRef = eduRef;
this.user = user;
this.courseId = courseId;
this.resourceId = resourceId;
}
public String getResourceId() {
return resourceId;
}
public String getEduRef() {
return eduRef;
}
public String getUser() {
return user;
}
public String getCourseId() {
return courseId;
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import org.olat.core.id.Identity;
/**
*
* Initial date: 28 Nov 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public interface EdusharingClient {
void test(Identity identity);
public EdusharingProperties getRepoConfig();
public String createTicket(Identity identity) throws EdusharingException;
public boolean validateTicket(String ticket) throws EdusharingException;
public EdusharingResponse getPreview(GetPreviewParameter parameter) throws EdusharingException;
public EdusharingResponse getRendered(GetRenderedParameter parameter) throws EdusharingException;
public String getRenderUrl(GetRenderedParameter parameter);
public void createUsage(CreateUsageParameter parameter) throws EdusharingException;
public void deleteUsage(DeleteUsageParameter parameter) throws EdusharingException;
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import org.olat.core.gui.UserRequest;
import org.olat.core.id.OLATResourceable;
import org.olat.modules.edusharing.model.SearchResult;
/**
*
* Initial date: 12 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public interface EdusharingConversionService {
public String toEdusharingCourseId(OLATResourceable ores);
public SearchResult toSearchResult(UserRequest ureq);
public String toJson(SearchResult searchResult) throws EdusharingException;
public NodeIdentifier toNodeIdentifier(String objectUrl);
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.time.LocalDateTime;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.edu_sharing.webservices.authbyapp.AuthenticationException;
import org.olat.core.dispatcher.Dispatcher;
import org.olat.core.dispatcher.DispatcherModule;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.UserRequestImpl;
import org.olat.core.helpers.Settings;
import org.olat.core.id.Identity;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
import org.olat.core.util.UserSession;
import org.olat.dispatcher.LocaleNegotiator;
import org.olat.modules.edusharing.model.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
* Initial date: 30 Nov 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
@Service
public class EdusharingDispatcher implements Dispatcher {
private static final OLog log = Tracing.createLoggerFor(EdusharingDispatcher.class);
private static final String EDUSHARING_PATH = "edusharing";
private static final String METADATA_PATH = "metadata";
private static final String SEARCH_CALLBACK_PATH = "searchcallback";
@Autowired
private EdusharingModule edusharingModule;
@Autowired
private EdusharingService edusharingService;
@Autowired
private EdusharingConversionService conversionService;
public static final String getMetadataUrl() {
return getBaseUrl().append(METADATA_PATH).toString();
}
public static final String getSearchCallbackUrl() {
return getBaseUrl().append(SEARCH_CALLBACK_PATH).toString();
}
private static StringBuilder getBaseUrl() {
return new StringBuilder()
.append(Settings.getServerContextPathURI())
.append("/")
.append(EDUSHARING_PATH)
.append("/");
}
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!edusharingModule.isEnabled()) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.setContentType("text/plain");
return;
}
UserRequest ureq = null;
try{
//upon creation URL is checked for
ureq = new UserRequestImpl("edusharing", request, response);
} catch(NumberFormatException nfe) {
DispatcherModule.sendBadRequest(request.getPathInfo(), response);
return;
}
try {
String command = getCommand(request);
if ("enabled".equals(command)) {
// If module is not enabled, an error is triggered above
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("text/plain");
} else if (METADATA_PATH.equals(command)) {
buildMetadata(ureq, response);
} else if (ureq.getUserSession().isAuthenticated()) {
switch (command) {
case "search":
redirectToSearch(ureq, response);
break;
case SEARCH_CALLBACK_PATH:
buildSearchCallback(ureq, response);
break;
case "preview":
buildPreview(ureq, response);
break;
case "render":
buildRender(ureq, response);
break;
case "goto":
buildGoTo(ureq, response);
break;
default:
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
} else {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
} catch (Exception e) {
log.error("", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
private String getCommand(HttpServletRequest request) {
String uriPrefix = DispatcherModule.getLegacyUriPrefix(request);
final String origUri = request.getRequestURI();
String encodedRestPart = origUri.substring(uriPrefix.length());
String restPart = encodedRestPart;
try {
restPart = URLDecoder.decode(encodedRestPart, "UTF8");
} catch (UnsupportedEncodingException e) {
log.error("Unsupported encoding", e);
}
String[] split = restPart.split("/");
if (split.length >= 1) {
return split[0];
}
return null;
}
/**
* Metadata to register OpenOLAT as application in edu-sharing.
*
* @param ureq
* @param response
* @throws IOException
*/
private void buildMetadata(UserRequest ureq, HttpServletResponse response) throws Exception {
Properties properties = edusharingService.getConfigForRegistration();
properties.storeToXML(
response.getOutputStream(),
"Generated by OpenOLAT on " + LocalDateTime.now(),
"UTF-8");
}
private void redirectToSearch(UserRequest ureq, HttpServletResponse response) throws AuthenticationException {
String language = LocaleNegotiator.getPreferedLocale(ureq).getLanguage();
Ticket ticket = getTicket(ureq.getUserSession());
String url = new StringBuilder()
.append(edusharingModule.getBaseUrl())
.append("components/search")
.append("?locale=").append(language)
.append("&ticket=").append(ticket.getTooken())
.append("&reurl=").append(getSearchCallbackUrl())
.toString();
log.debug("edu-sharing start search " + url);
DispatcherModule.redirectTo(response, url);
}
private void buildSearchCallback(UserRequest ureq, HttpServletResponse response) throws IOException {
log.debug("edu-sharing search callback url: " + ureq.getHttpReq().getRequestURL() + "?" + ureq.getHttpReq().getQueryString());
SearchResult result = conversionService.toSearchResult(ureq);
String json = conversionService.toJson(result);
log.debug("edu-sharing search callback: " + json);
StringBuilder sb = new StringBuilder();
sb.append("<!DOCTYPE html>");
sb.append("<html>");
sb.append("<head>");
sb.append("<meta charset=\"UTF-8\">");
sb.append("<script>");
sb.append(" (function() {");
sb.append(" \"use strict\";");
sb.append(" parent.tinymce.activeEditor.windowManager.setParams(");
sb.append(json);
sb.append(" );");
sb.append(" parent.tinymce.activeEditor.windowManager.close();");
sb.append("}());");
sb.append("</script>");
sb.append("<body />");
sb.append("</html>");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().write(sb.toString());
response.getWriter().flush();
response.getWriter().close();
}
private void buildPreview(UserRequest ureq, HttpServletResponse response) throws Exception {
log.debug("edu-sharing preview url: " + ureq.getHttpReq().getRequestURL() + "?" + ureq.getHttpReq().getQueryString());
String objectUrl = ureq.getParameter("objectUrl");
Ticket ticket = getTicket(ureq.getUserSession());
try (EdusharingResponse edusharingResponse = edusharingService.getPreview(ticket, objectUrl)) {
response.setStatus(edusharingResponse.getStatus());
if (edusharingResponse.hasContent()) {
response.setContentType(edusharingResponse.getMimeType());
response.setContentLengthLong(edusharingResponse.getContentLength());
stream(edusharingResponse.getContent(), response.getOutputStream());
}
}
}
private void buildRender(UserRequest ureq, HttpServletResponse response) throws Exception {
log.debug("edu-sharing render url: " + ureq.getHttpReq().getRequestURL() + "?" + ureq.getHttpReq().getQueryString());
String identifier = ureq.getParameter("identifier");
String width = ureq.getParameter("width");
String height = ureq.getParameter("height");
Identity viewer = ureq.getUserSession().getIdentity();
String language = LocaleNegotiator.getPreferedLocale(ureq).getLanguage();
try (EdusharingResponse edusharingResponse = edusharingService.getRendered(viewer, identifier, width, height, language)) {
response.setStatus(edusharingResponse.getStatus());
if (edusharingResponse.hasContent()) {
response.setContentType(edusharingResponse.getMimeType());
response.setContentLengthLong(edusharingResponse.getContentLength());
stream(edusharingResponse.getContent(), response.getOutputStream());
}
}
}
private void buildGoTo(UserRequest ureq, HttpServletResponse response) throws Exception {
log.debug("edu-sharing go to url: " + ureq.getHttpReq().getRequestURL() + "?" + ureq.getHttpReq().getQueryString());
String identifier = ureq.getParameter("identifier");
Ticket ticket = getTicket(ureq.getUserSession());
Identity viewer = ureq.getUserSession().getIdentity();
String language = LocaleNegotiator.getPreferedLocale(ureq).getLanguage();
String url = edusharingService.getRenderAsWindowUrl(ticket, viewer, identifier, language);
if (!StringHelper.containsNonWhitespace(url)) {
url = edusharingModule.getBaseUrl();
}
log.debug("edu-sharing go to " + url);
DispatcherModule.redirectTo(response, url);
}
private Ticket getTicket(UserSession usess) throws AuthenticationException {
Ticket ticket = null;
Object ticketObject = usess.getEntry("edusharing-ticket");
if (ticketObject instanceof Ticket) {
ticket = (Ticket) ticketObject;
ticket = edusharingService.validateTicket(ticket)
.orElse(edusharingService.createTicket(usess.getIdentity()));
} else {
ticket = edusharingService.createTicket(usess.getIdentity());
}
usess.putEntry("edusharing-ticket", ticket);
return ticket;
}
private static long stream(InputStream input, OutputStream output) throws IOException {
try (
ReadableByteChannel inputChannel = Channels.newChannel(input);
WritableByteChannel outputChannel = Channels.newChannel(output);
) {
ByteBuffer buffer = ByteBuffer.allocateDirect(10240);
long size = 0;
while (inputChannel.read(buffer) != -1) {
buffer.flip();
size += outputChannel.write(buffer);
buffer.clear();
}
return size;
}
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
/**
*
* Initial date: 9 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class EdusharingException extends RuntimeException {
private static final long serialVersionUID = 5989604853713786054L;
public EdusharingException() {
super();
}
public EdusharingException(Throwable e) {
super(e);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.olat.core.CoreSpringFactory;
import org.olat.core.id.Identity;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.filter.Filter;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* Initial date: 9 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class EdusharingFilter implements Filter {
private static final OLog log = Tracing.createLoggerFor(EdusharingFilter.class);
private final Identity identity;
private final EdusharingProvider provider;
@Autowired
private EdusharingModule edusharingModule;
@Autowired
private EdusharingService edusharingService;
@Autowired
private EdusharingHtmlService htmlService;
public EdusharingFilter(Identity identity, EdusharingProvider provider) {
this.identity = identity;
this.provider = provider;
CoreSpringFactory.autowireObject(this);
}
@Override
public String filter(String original) {
if (edusharingModule.isEnabled()) {
// Get all edu-sharing elements from html
List<EdusharingHtmlElement> htmlElements = htmlService.parse(original);
Map<String, EdusharingHtmlElement> htmlIdentifierToElement = htmlElements.stream().collect(Collectors.toMap(u -> u.getIdentifier(), u -> u));
Set<String> htmlIdentifiers = htmlIdentifierToElement.keySet();
log.debug("edu-sharing filter identifiers in html: " + htmlIdentifiers.toString());
// Get all usages from database
List<EdusharingUsage> usages = edusharingService.loadUsages(provider.getOlatResourceable());
Map<String, EdusharingUsage> usageIdentifierToUsage = usages.stream().collect(Collectors.toMap(u -> u.getIdentifier(), u -> u));
Set<String> usageIdentifiers = usageIdentifierToUsage.keySet();
log.debug("edu-sharing filter identifiers in database: " + usageIdentifiers.toString());
// create
Collection<String> createIdentifiers = new HashSet<>(htmlIdentifiers);
createIdentifiers.removeAll(usageIdentifiers);
for (String identifier: createIdentifiers) {
try {
EdusharingHtmlElement element = htmlIdentifierToElement.get(identifier);
edusharingService.createUsage(identity, element, provider);
} catch (Exception e) {
original = htmlService.deleteNode(original, identifier);
log.warn("edu-sharing usage creation failed. identifier=" + identifier + ", resType="
+ provider.getOlatResourceable().getResourceableTypeName() + ", resId="
+ provider.getOlatResourceable().getResourceableId(), e);
}
}
// delete
Collection<String> deleteIdentifiers = new HashSet<>(usageIdentifiers);
deleteIdentifiers.removeAll(htmlIdentifiers);
for (String identifier: deleteIdentifiers) {
try {
edusharingService.deleteUsage(identity, identifier);
} catch (EdusharingException e) {
log.warn("edu-sharing usage deletion failed. identifier=" + identifier + ", resType="
+ provider.getOlatResourceable().getResourceableTypeName() + ", resId="
+ provider.getOlatResourceable().getResourceableId(), e);
}
}
}
return original;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
/**
*
* Initial date: 9 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class EdusharingHtmlElement {
private final String identifier;
private final String objectUrl;
private String version;
private String mimeType;
private String mediaType;
private String width;
private String hight;
public EdusharingHtmlElement(String identifier, String objectUrl) {
this.identifier = identifier;
this.objectUrl = objectUrl;
}
public String getIdentifier() {
return identifier;
}
public String getObjectUrl() {
return objectUrl;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public String getMediaType() {
return mediaType;
}
public void setMediaType(String mediaType) {
this.mediaType = mediaType;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getHight() {
return hight;
}
public void setHight(String hight) {
this.hight = hight;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import java.util.List;
/**
*
* Initial date: 9 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public interface EdusharingHtmlService {
public List<EdusharingHtmlElement> parse(String html);
public String deleteNode(String html, String identifier2);
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import org.olat.core.configuration.AbstractSpringModule;
import org.olat.core.configuration.ConfigOnOff;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
import org.olat.core.util.coordinate.CoordinatorManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
*
* Initial date: 20 Nov 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
@Service
public class EdusharingModule extends AbstractSpringModule implements ConfigOnOff {
private static final OLog log = Tracing.createLoggerFor(EdusharingModule.class);
private static final String EDUSHARING_ENABLED = "edusharing.enabled";
private static final String EDUSHARING_BASE_URL = "edusharing.url";
private static final String EDUSHARING_APP_ID = "edusharing.app.id";
private static final String EDUSHARING_HOST = "edusharing.host";
private static final String EDUSHARING_TICKET_VALID_SECONDS = "edusharing.ticket.valid.seconds";
private static final String EDUSHARING_SOAP_PUBLIC_KEY = "edusharing.soap.public.key";
private static final String EDUSHARING_SOAP_PRIVATE_KEY = "edusharing.soap.private.key";
private static final String EDUSHARING_REPO_PUBLIC_KEY = "edusharing.repo.public.key";
@Value("${edusharing.enabled:false}")
private boolean enabled;
@Value("${edusharing.url}")
private String baseUrl;
@Value("${edusharing.app.id}")
private String appId;
@Value("${edusharing.host}")
private String host;
@Value("${edusharing.ticket.valid.seconds:10}")
private int ticketValidSeconds;
private KeyPair soapKeys;
private String soapPublicKey;
private String soapPrivateKey;
// public key of the edu-sharing (home) repository.
private PublicKey repoPublicKey;
private String repoPublicKeyString;
@Autowired
private EdusharingSecurityService edusharingSignature;
@Autowired
private EdusharingModule(CoordinatorManager coordinateManager) {
super(coordinateManager);
}
@Override
public void init() {
updateProperties();
}
@Override
protected void initFromChangedProperties() {
updateProperties();
}
private void updateProperties() {
String enabledObj = getStringPropertyValue(EDUSHARING_ENABLED, true);
if(StringHelper.containsNonWhitespace(enabledObj)) {
enabled = "true".equals(enabledObj);
}
String baseUrlObj = getStringPropertyValue(EDUSHARING_BASE_URL, true);
if(StringHelper.containsNonWhitespace(baseUrlObj)) {
baseUrl = baseUrlObj;
}
String appIdObj = getStringPropertyValue(EDUSHARING_APP_ID, true);
if(StringHelper.containsNonWhitespace(appIdObj)) {
appId = appIdObj;
}
String hostObj = getStringPropertyValue(EDUSHARING_HOST, true);
if(StringHelper.containsNonWhitespace(hostObj)) {
host = hostObj;
}
ticketValidSeconds = getIntPropertyValue(EDUSHARING_TICKET_VALID_SECONDS);
String soapPublicKeyObj = getStringPropertyValue(EDUSHARING_SOAP_PUBLIC_KEY, true);
if(StringHelper.containsNonWhitespace(soapPublicKeyObj)) {
soapPublicKey = soapPublicKeyObj;
}
String soapPrivateKeyObj = getStringPropertyValue(EDUSHARING_SOAP_PRIVATE_KEY, true);
if(StringHelper.containsNonWhitespace(soapPrivateKeyObj)) {
soapPrivateKey = soapPrivateKeyObj;
}
String repoPublicKeyObj = getStringPropertyValue(EDUSHARING_REPO_PUBLIC_KEY, true);
if(StringHelper.containsNonWhitespace(repoPublicKeyObj)) {
repoPublicKeyString = repoPublicKeyObj;
}
}
@Override
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
setStringProperty(EDUSHARING_ENABLED, Boolean.toString(enabled), true);
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
setStringProperty(EDUSHARING_BASE_URL, baseUrl, true);
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
setStringProperty(EDUSHARING_APP_ID, appId, true);
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
setStringProperty(EDUSHARING_HOST, host, true);
}
public int getTicketValidSeconds() {
return ticketValidSeconds;
}
public void setTicketValidSeconds(int ticketValidSeconds) {
this.ticketValidSeconds = ticketValidSeconds;
setIntProperty(EDUSHARING_TICKET_VALID_SECONDS, ticketValidSeconds, true);
}
public KeyPair getSoapKeys() {
if (soapKeys == null && StringHelper.containsNonWhitespace(soapPublicKey) && StringHelper.containsNonWhitespace(soapPrivateKey)) {
try {
PublicKey publicKey = edusharingSignature.toPublicKey(soapPublicKey);
PrivateKey privateKey = edusharingSignature.toPrivateKey(soapPrivateKey);
soapKeys = new KeyPair(publicKey, privateKey);
} catch (Exception e) {
log.error("", e);
}
}
return soapKeys;
}
public void setSoapKeys(KeyPair soapKeys) {
this.soapKeys = soapKeys;
this.soapPublicKey = edusharingSignature.getPublicKey(soapKeys);
setStringProperty(EDUSHARING_SOAP_PUBLIC_KEY, soapPublicKey, true);
this.soapPrivateKey = edusharingSignature.getPrivateKey(soapKeys);
setStringProperty(EDUSHARING_SOAP_PRIVATE_KEY, soapPrivateKey, true);
}
public PublicKey getRepoPublicKey() {
if (repoPublicKey == null && StringHelper.containsNonWhitespace(repoPublicKeyString)) {
try {
repoPublicKey = edusharingSignature.toPublicKey(repoPublicKeyString);
} catch (Exception e) {
log.error("", e);
}
}
return repoPublicKey;
}
public String getRepoPublicKeyString() {
return repoPublicKeyString;
}
public void setRepoPublicKeyString(String repoPublicKeyString) {
this.repoPublicKey = null;
this.repoPublicKeyString = repoPublicKeyString;
setStringProperty(EDUSHARING_REPO_PUBLIC_KEY, repoPublicKeyString, true);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.edusharing;
/**
*
* Initial date: 14 Dec 2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public interface EdusharingProperties {
public String getPublicKey();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment