├── .gitignore ├── DEV_ENVIRONMENT.md ├── Jenkinsfile ├── README.md ├── activitypub-commons ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── xwiki │ │ │ └── contrib │ │ │ └── activitypub │ │ │ └── internal │ │ │ ├── DateProvider.java │ │ │ ├── DefaultURLHandler.java │ │ │ └── XWikiUserBridge.java │ └── resources │ │ └── META-INF │ │ └── components.txt │ └── test │ └── java │ └── org │ └── xwiki │ └── contrib │ └── activitypub │ └── internal │ ├── DateProviderTest.java │ ├── DefaultURLHandlerTest.java │ └── XWikiUserBridgeTest.java ├── activitypub-core ├── pom.xml └── src │ ├── checkstyle │ └── checkstyle-suppressions.xml │ ├── main │ ├── java │ │ └── org │ │ │ └── xwiki │ │ │ └── contrib │ │ │ └── activitypub │ │ │ ├── ActivityPubClient.java │ │ │ ├── ActivityPubConfiguration.java │ │ │ ├── ActivityPubException.java │ │ │ ├── ActivityPubIdentifierService.java │ │ │ ├── ActivityPubJsonParser.java │ │ │ ├── ActivityPubJsonSerializer.java │ │ │ ├── ActivityPubObjectReferenceResolver.java │ │ │ ├── ActivityPubResourceReference.java │ │ │ ├── ActivityPubStorage.java │ │ │ ├── ActorHandler.java │ │ │ ├── entities │ │ │ ├── AbstractActivity.java │ │ │ ├── AbstractActor.java │ │ │ ├── AbstractBox.java │ │ │ ├── AbstractCollection.java │ │ │ ├── Accept.java │ │ │ ├── ActivityPubObject.java │ │ │ ├── ActivityPubObjectReference.java │ │ │ ├── Announce.java │ │ │ ├── Collection.java │ │ │ ├── Create.java │ │ │ ├── Document.java │ │ │ ├── Follow.java │ │ │ ├── Inbox.java │ │ │ ├── JSONLDContext.java │ │ │ ├── JSONLDObjects.java │ │ │ ├── Like.java │ │ │ ├── Link.java │ │ │ ├── Mention.java │ │ │ ├── Note.java │ │ │ ├── OrderedCollection.java │ │ │ ├── Outbox.java │ │ │ ├── Page.java │ │ │ ├── Person.java │ │ │ ├── ProxyActor.java │ │ │ ├── PublicKey.java │ │ │ ├── Reject.java │ │ │ ├── Service.java │ │ │ ├── UnknownTypeObject.java │ │ │ └── Update.java │ │ │ └── internal │ │ │ ├── DefaultActivityPubIdentifierService.java │ │ │ ├── DefaultActivityPubObjectReferenceResolver.java │ │ │ ├── InternalURINormalizer.java │ │ │ ├── json │ │ │ ├── AbstractActivityPubJsonParser.java │ │ │ ├── AbstractActivityPubJsonSerializer.java │ │ │ ├── AbstractActivityPubObjectReferenceDeserializer.java │ │ │ ├── AbstractActivityPubObjectReferenceSerializer.java │ │ │ ├── AbstractObjectMapperConfiguration.java │ │ │ ├── ActivityPubObjectDeserializer.java │ │ │ ├── JSONLDContextDeserializer.java │ │ │ ├── ObjectMapperConfiguration.java │ │ │ ├── absolute │ │ │ │ ├── DefaultActivityPubJsonParser.java │ │ │ │ ├── DefaultActivityPubJsonSerializer.java │ │ │ │ ├── DefaultActivityPubObjectReferenceDeserializer.java │ │ │ │ ├── DefaultActivityPubObjectReferenceSerializer.java │ │ │ │ └── DefaultObjectMapperConfiguration.java │ │ │ └── relative │ │ │ │ ├── RelativeActivityPubJsonParser.java │ │ │ │ ├── RelativeActivityPubJsonSerializer.java │ │ │ │ ├── RelativeActivityPubObjectReferenceDeserializer.java │ │ │ │ ├── RelativeActivityPubObjectReferenceSerializer.java │ │ │ │ └── RelativeObjectMapperConfiguration.java │ │ │ └── stream │ │ │ ├── StreamActivityPubObjectReferenceResolver.java │ │ │ └── StreamActivityPubObjectReferenceSerializer.java │ └── resources │ │ └── META-INF │ │ └── components.txt │ └── test │ ├── java │ └── org │ │ └── xwiki │ │ └── contrib │ │ └── activitypub │ │ ├── entities │ │ ├── AbstractEntityTest.java │ │ ├── AcceptTest.java │ │ ├── ActivityPubObjectReferenceTest.java │ │ ├── ActivityPubObjectTest.java │ │ ├── AnnounceTest.java │ │ ├── CollectionTest.java │ │ ├── CreateTest.java │ │ ├── FollowTest.java │ │ ├── InboxTest.java │ │ ├── LinkTest.java │ │ ├── MentionTest.java │ │ ├── NoteTest.java │ │ ├── OutboxTest.java │ │ ├── PersonTest.java │ │ ├── ProxyActorTest.java │ │ └── RejectTest.java │ │ └── internal │ │ ├── DefaultActivityPubIdentifierServiceTest.java │ │ ├── DefaultActivityPubObjectReferenceResolverTest.java │ │ ├── InternalURINormalizerTest.java │ │ ├── json │ │ ├── absolute │ │ │ ├── DefaultActivityPubObjectReferenceDeserializerTest.java │ │ │ └── DefaultActivityPubObjectReferenceSerializerTest.java │ │ └── relative │ │ │ ├── RelativeActivityPubObjectReferenceDeserializerTest.java │ │ │ └── RelativeActivityPubObjectReferenceSerializerTest.java │ │ └── stream │ │ ├── StreamActivityPubObjectReferenceResolverTest.java │ │ └── StreamActivityPubObjectReferenceSerializerTest.java │ └── resources │ └── entities │ ├── accept │ └── accept1.json │ ├── announce │ └── announce1.json │ ├── collection │ └── collection1.json │ ├── create │ └── create1.json │ ├── follow │ ├── follow1.json │ └── nextcloud.json │ ├── inbox │ └── inbox1.json │ ├── link │ └── link1.json │ ├── mention │ └── mention1.json │ ├── note │ ├── note1.json │ ├── note2.json │ ├── note3.json │ └── note4.json │ ├── outbox │ └── outbox1.json │ ├── person │ ├── mastodon.json │ ├── person1.json │ └── person2.json │ ├── reject │ └── reject1.json │ └── wrongtype.json ├── activitypub-notifications ├── pom.xml └── src │ ├── checkstyle │ └── checkstyle-suppressions.xml │ ├── main │ ├── java │ │ └── org │ │ │ └── xwiki │ │ │ └── contrib │ │ │ └── activitypub │ │ │ ├── ActivityPubNotifier.java │ │ │ ├── events │ │ │ ├── AbstractActivityPubEvent.java │ │ │ ├── AnnounceEvent.java │ │ │ ├── CreateEvent.java │ │ │ ├── FollowEvent.java │ │ │ ├── LikeEvent.java │ │ │ ├── MentionEvent.java │ │ │ ├── MessageEvent.java │ │ │ └── UpdateEvent.java │ │ │ └── internal │ │ │ ├── ActivityPubLegacyEventConverter.java │ │ │ ├── ActivityPubNotificationDisplayer.java │ │ │ ├── ActivityPubRecordableEventConverter.java │ │ │ ├── DefaultActivityPubNotifier.java │ │ │ └── descriptors │ │ │ ├── AbstractActivityPubEventDescriptor.java │ │ │ ├── AnnounceEventDescriptor.java │ │ │ ├── CreateEventDescriptor.java │ │ │ ├── FollowEventDescriptor.java │ │ │ ├── LikeEventDescriptor.java │ │ │ ├── MentionEventDescriptor.java │ │ │ ├── MessageEventDescriptor.java │ │ │ └── UpdateEventDescriptor.java │ └── resources │ │ ├── ApplicationResources.properties │ │ ├── ApplicationResources_de.properties │ │ ├── ApplicationResources_es.properties │ │ ├── ApplicationResources_fr.properties │ │ ├── ApplicationResources_ja.properties │ │ ├── ApplicationResources_ko.properties │ │ ├── ApplicationResources_pt.properties │ │ ├── ApplicationResources_pt_BR.properties │ │ ├── ApplicationResources_ru.properties │ │ ├── ApplicationResources_tr.properties │ │ ├── META-INF │ │ └── components.txt │ │ └── templates │ │ └── activitypub │ │ ├── activity.vm │ │ ├── announce.vm │ │ ├── create.vm │ │ ├── follow.vm │ │ ├── like.vm │ │ ├── likeAction.vm │ │ ├── macros.vm │ │ ├── mention.vm │ │ ├── message.vm │ │ └── update.vm │ └── test │ └── java │ └── org │ └── xwiki │ └── contrib │ └── activitypub │ ├── events │ ├── AnnounceEventTest.java │ ├── CreateEventTest.java │ ├── FollowEventTest.java │ └── UpdateEventTest.java │ └── internal │ ├── ActivityPubLegacyEventConverterTest.java │ ├── ActivityPubNotificationDisplayerTest.java │ ├── ActivityPubRecordableEventConverterTest.java │ └── DefaultActivityPubNotifierTest.java ├── activitypub-server ├── pom.xml └── src │ ├── checkstyle │ └── checkstyle-suppressions.xml │ ├── main │ ├── java │ │ └── org │ │ │ └── xwiki │ │ │ └── contrib │ │ │ └── activitypub │ │ │ ├── ActivityHandler.java │ │ │ ├── ActivityRequest.java │ │ │ ├── CryptoService.java │ │ │ ├── HTMLRenderer.java │ │ │ ├── SignatureService.java │ │ │ ├── internal │ │ │ ├── ActivityPubConfigurationSource.java │ │ │ ├── ActivityPubDiscussionsActorService.java │ │ │ ├── ActivityPubDiscussionsService.java │ │ │ ├── ActivityPubMentionsFormatter.java │ │ │ ├── ActivityPubMentionsSender.java │ │ │ ├── ActivityPubXDOMService.java │ │ │ ├── DefaultActivityPubClient.java │ │ │ ├── DefaultActivityPubConfiguration.java │ │ │ ├── DefaultActorHandler.java │ │ │ ├── DefaultHTMLRenderer.java │ │ │ ├── activities │ │ │ │ ├── AbstractActivityHandler.java │ │ │ │ ├── AcceptActivityHandler.java │ │ │ │ ├── AnnounceActivityHandler.java │ │ │ │ ├── CreateActivityHandler.java │ │ │ │ ├── FollowActivityHandler.java │ │ │ │ ├── LikeActivityHandler.java │ │ │ │ ├── RejectActivityHandler.java │ │ │ │ └── UpdateActivityHandler.java │ │ │ ├── async │ │ │ │ ├── PageChangedRequest.java │ │ │ │ ├── PageChangedStatus.java │ │ │ │ └── jobs │ │ │ │ │ ├── AbstractPageNotificationJob.java │ │ │ │ │ ├── PageCreatedNotificationJob.java │ │ │ │ │ └── PageUpdatedNotificationJob.java │ │ │ ├── filters │ │ │ │ ├── CollectionFilter.java │ │ │ │ ├── PublicActivityCollectionFilter.java │ │ │ │ └── PublicActivityFilter.java │ │ │ ├── listeners │ │ │ │ ├── AbstractActivityPubMentionEventListener.java │ │ │ │ ├── ActivityPubDiscussionsMessagesEventListener.java │ │ │ │ ├── ActivityPubMentionDiscussionEventListener.java │ │ │ │ ├── ActivityPubMentionEventListener.java │ │ │ │ ├── ActivityPubNewMessagesListener.java │ │ │ │ ├── DocumentCreatedEventListener.java │ │ │ │ └── DocumentUpdatedEventListener.java │ │ │ ├── resource │ │ │ │ ├── ActivityPubResourceReferenceHandler.java │ │ │ │ ├── ActivityPubResourceReferenceResolver.java │ │ │ │ └── ActivityPubResourceReferenceSerializer.java │ │ │ ├── script │ │ │ │ └── ActivityPubScriptServiceActor.java │ │ │ ├── signature │ │ │ │ ├── DefaultCryptoService.java │ │ │ │ └── DefaultSignatureService.java │ │ │ └── storage │ │ │ │ ├── ActivityPubSolrInitializer.java │ │ │ │ └── DefaultActivityPubStorage.java │ │ │ └── script │ │ │ ├── ActivityPubDiscussionsScriptService.java │ │ │ ├── ActivityPubScriptService.java │ │ │ ├── FollowResult.java │ │ │ └── PublishNoteScriptService.java │ └── resources │ │ └── META-INF │ │ └── components.txt │ └── test │ └── java │ └── org │ └── xwiki │ └── contrib │ └── activitypub │ ├── internal │ ├── ActivityPubDiscussionsActorServiceTest.java │ ├── ActivityPubDiscussionsServiceTest.java │ ├── ActivityPubMentionsFormatterTest.java │ ├── ActivityPubMentionsSenderTest.java │ ├── ActivityPubXDOMServiceTest.java │ ├── DefaultActivityPubClientTest.java │ ├── DefaultActivityPubConfigurationTest.java │ ├── DefaultActorHandlerTest.java │ ├── activities │ │ ├── AbstractHandlerTest.java │ │ ├── AcceptActivityHandlerTest.java │ │ ├── AnnounceActivityHandlerTest.java │ │ ├── CreateActivityHandlerTest.java │ │ ├── FollowActivityHandlerTest.java │ │ ├── LikeActivityHandlerTest.java │ │ ├── RejectActivityHandlerTest.java │ │ └── UpdateActivityHandlerTest.java │ ├── async │ │ └── jobs │ │ │ ├── PageCreatedNotificationJobTest.java │ │ │ └── PageUpdatedNotificationJobTest.java │ ├── filters │ │ ├── PublicActivityCollectionFilterTest.java │ │ └── PublicActivityFilterTest.java │ ├── listeners │ │ ├── ActivityPubDiscussionsMessagesEventListenerTest.java │ │ ├── ActivityPubMentionDiscussionEventListenerTest.java │ │ ├── ActivityPubMentionEventListenerTest.java │ │ ├── DocumentCreatedEventListenerTest.java │ │ └── DocumentUpdatedEventListenerTest.java │ ├── resource │ │ ├── ActivityPubResourceReferenceHandlerTest.java │ │ ├── ActivityPubResourceReferenceResolverTest.java │ │ └── ActivityPubResourceReferenceSerializerTest.java │ ├── script │ │ └── ActivityPubScriptServiceActorTest.java │ ├── signature │ │ ├── DefaultCryptoServiceTest.java │ │ └── DefaultSignatureServiceTest.java │ └── storage │ │ └── DefaultActivityPubStorageTest.java │ └── script │ ├── ActivityPubDiscussionsScriptServiceTest.java │ ├── ActivityPubScriptServiceTest.java │ └── PublishNoteScriptServiceTest.java ├── activitypub-ui ├── pom.xml └── src │ └── main │ └── resources │ └── ActivityPub │ ├── ActivityPubConfigurationClass.xml │ ├── ActivityPubTranslations.de.xml │ ├── ActivityPubTranslations.es.xml │ ├── ActivityPubTranslations.fr.xml │ ├── ActivityPubTranslations.ja.xml │ ├── ActivityPubTranslations.ko.xml │ ├── ActivityPubTranslations.pt.xml │ ├── ActivityPubTranslations.pt_BR.xml │ ├── ActivityPubTranslations.ru.xml │ ├── ActivityPubTranslations.xml │ ├── ActivityPubUserPicker.xml │ ├── Configuration.xml │ ├── Discussion.xml │ ├── Discussions.xml │ ├── FollowUser.xml │ ├── LikersView.xml │ ├── ListFollowing.xml │ ├── ListMessages.xml │ ├── MessageUser.xml │ ├── NotificationReply.xml │ ├── ShareDocument.xml │ ├── UserDashboard.xml │ ├── UserLikes.xml │ └── WebHome.xml ├── pom.xml └── webfinger-parent ├── README.md ├── pom.xml ├── webfinger-core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── xwiki │ │ │ └── contrib │ │ │ └── activitypub │ │ │ └── webfinger │ │ │ ├── WebfingerException.java │ │ │ ├── WebfingerJsonParser.java │ │ │ ├── WebfingerJsonSerializer.java │ │ │ ├── WebfingerResourceReference.java │ │ │ ├── entities │ │ │ ├── JSONResourceDescriptor.java │ │ │ └── Link.java │ │ │ └── internal │ │ │ └── json │ │ │ ├── DefaultWebfingerJsonParser.java │ │ │ ├── DefaultWebfingerJsonSerializer.java │ │ │ └── ObjectMapperConfiguration.java │ └── resources │ │ └── META-INF │ │ └── components.txt │ └── test │ ├── java │ └── org │ │ └── xwiki │ │ └── contrib │ │ └── activitypub │ │ └── webfinger │ │ └── entities │ │ └── JSONResourceDescriptorTest.java │ └── resources │ ├── webfinger.json │ └── webfinger_unknown_field.json └── webfinger-server ├── pom.xml └── src ├── checkstyle └── checkstyle-suppressions.xml ├── main ├── java │ └── org │ │ └── xwiki │ │ └── contrib │ │ └── activitypub │ │ └── webfinger │ │ ├── WebfingerClient.java │ │ ├── WebfingerService.java │ │ ├── internal │ │ ├── DefaultWebfingerClient.java │ │ ├── DefaultWebfingerService.java │ │ ├── WebfingerResourceReferenceHandler.java │ │ └── WebfingerResourceReferenceResolver.java │ │ └── script │ │ └── WebfingerScriptService.java └── resources │ └── META-INF │ └── components.txt └── test └── java └── org └── xwiki └── contrib └── activitypub └── webfinger ├── internal ├── DefaultWebfingerClientTest.java ├── DefaultWebfingerServiceTest.java ├── WebfingerResourceReferenceHandlerTest.java └── WebfingerResourceReferenceResolverTest.java └── script └── WebfingerScriptServiceTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | target/ 4 | .project 5 | .settings/ 6 | .classpath 7 | target-eclipse/ -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | 21 | // It's assumed that Jenkins has been configured to implicitly load the vars/xwikiModule.groovy library which exposes 22 | // the "xwikiModule" global function/DSL. 23 | // Note that the version used is the one defined in Jenkins but it can be overridden as follows: 24 | // @Library("XWiki@") _ 25 | // See https://github.com/jenkinsci/workflow-cps-global-lib-plugin for details. 26 | 27 | xwikiModule { 28 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Application ActivityPub 2 | 3 | This application is an implementation of the [ActivityPub protocol](https://www.w3.org/TR/activitypub/) for XWiki. 4 | 5 | * Project Lead: [Simon Urli](https://www.xwiki.org/xwiki/bin/view/XWiki/surli) 6 | * [Documentation & Download](https://extensions.xwiki.org/xwiki/bin/view/Extension/ActivityPub%20Application/) 7 | * [Issue Tracker](https://jira.xwiki.org/projects/XAP) 8 | * Communication: [Forum](https://forum.xwiki.org/), [Chat](https://dev.xwiki.org/xwiki/bin/view/Community/Chat) 9 | * [Development Practices](https://dev.xwiki.org/) 10 | * Minimal XWiki version supported: XWiki 12.2 11 | * License: LGPL 2.1 12 | * Translations: 13 | * [ActivityPub UI](https://l10n.xwiki.org/projects/xwiki-contrib/activitypub-ui/) 14 | * [ActivityPub Notifications](https://l10n.xwiki.org/projects/xwiki-contrib/activitypub-notifications/) 15 | * Sonar Dashboard: N/A 16 | * Continuous Integration Status: [![Build Status](https://ci.xwiki.org/job/XWiki%20Contrib/job/application-activitypub/job/master/badge/icon)](https://ci.xwiki.org/job/XWiki%20Contrib/job/application-activitypub/job/master/) 17 | 18 | # Acknowledgement 19 | 20 | This project has been partly funded by [NLnet fundation](https://nlnet.nl) as part of the [NGI Search & Discovery call](https://nlnet.nl/project/WikiActivityPub/). -------------------------------------------------------------------------------- /activitypub-commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.xwiki.contrib 27 | application-activitypub 28 | 1.7.12-SNAPSHOT 29 | 30 | activitypub-commons 31 | 1.7.12-SNAPSHOT 32 | XWiki ActivityPub - Commons 33 | jar 34 | 35 | 0.93 36 | 37 | 38 | 39 | org.xwiki.platform 40 | xwiki-platform-oldcore 41 | ${platform.version} 42 | 43 | 44 | org.xwiki.platform 45 | xwiki-platform-user-api 46 | ${platform.version} 47 | 48 | 49 | org.xwiki.platform 50 | xwiki-platform-user-default 51 | ${platform.version} 52 | 53 | 54 | javax.servlet 55 | javax.servlet-api 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /activitypub-commons/src/main/resources/META-INF/components.txt: -------------------------------------------------------------------------------- 1 | org.xwiki.contrib.activitypub.internal.DateProvider 2 | org.xwiki.contrib.activitypub.internal.XWikiUserBridge 3 | org.xwiki.contrib.activitypub.internal.DefaultURLHandler -------------------------------------------------------------------------------- /activitypub-core/src/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/ActivityPubException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | /** 25 | * Default exception type for ActivityPub application. 26 | * 27 | * @since 1.0 28 | * @version $Id$ 29 | */ 30 | @Unstable 31 | public class ActivityPubException extends Exception 32 | { 33 | /** 34 | * Default constructor with message. 35 | * @param message the message to be displayed. 36 | */ 37 | public ActivityPubException(String message) 38 | { 39 | super(message); 40 | } 41 | 42 | /** 43 | * Default constructor with message and root cause. 44 | * @param message the message to be displayed. 45 | * @param origin the root cause. 46 | */ 47 | public ActivityPubException(String message, Throwable origin) 48 | { 49 | super(message, origin); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/ActivityPubIdentifierService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import org.xwiki.component.annotation.Role; 23 | import org.xwiki.contrib.activitypub.entities.AbstractActor; 24 | import org.xwiki.stability.Unstable; 25 | 26 | /** 27 | * Provides the logic to deal with the identification of user and other actors in activitypub. 28 | * 29 | * @version $Id$ 30 | * @since 1.2 31 | */ 32 | @Role 33 | @Unstable 34 | public interface ActivityPubIdentifierService 35 | { 36 | /** 37 | * 38 | * @return the wiki separator between a wiki name and the wiki identifier. 39 | */ 40 | default String getWikiSeparator() 41 | { 42 | return "."; 43 | } 44 | 45 | /** 46 | * 47 | * @return the wiki identifier. 48 | */ 49 | default String getWikiIdentifier() 50 | { 51 | return "xwiki"; 52 | } 53 | 54 | /** 55 | * Return the activitypub identifier of the actor. 56 | * @param actor The actor. 57 | * @param username 58 | * @param wikiName The name of the wiki. 59 | * @return the identifier. 60 | * @throws ActivityPubException In case of errror during the identifier resolution. 61 | */ 62 | String createIdentifier(AbstractActor actor, String username, String wikiName) throws ActivityPubException; 63 | } 64 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/ActivityPubJsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import java.io.OutputStream; 23 | 24 | import org.xwiki.component.annotation.Role; 25 | import org.xwiki.contrib.activitypub.entities.ActivityPubObject; 26 | import org.xwiki.stability.Unstable; 27 | 28 | /** 29 | * Define serializing operations for ActivityPub. 30 | * 31 | * @since 1.0 32 | * @version $Id$ 33 | */ 34 | @Unstable 35 | @Role 36 | public interface ActivityPubJsonSerializer 37 | { 38 | /** 39 | * Serialize the given {@link ActivityPubObject} (or any inherited type) to a {@link String}. 40 | * @param object the object to serialize. 41 | * @param the concrete type of the given object. 42 | * @return a string representing the serialization of the given object. 43 | * @throws ActivityPubException in case any issue occurred during the serialization. 44 | */ 45 | String serialize(T object) throws ActivityPubException; 46 | 47 | /** 48 | * Serialize the given {@link ActivityPubObject} (or any inherited type) to the output stream. 49 | * @param stream the stream where to output the serialized object. 50 | * @param object the object to serialize. 51 | * @param the concrete type of the given object. 52 | * @throws ActivityPubException in case any issue occurred during the serialization. 53 | */ 54 | void serialize(OutputStream stream, T object) throws ActivityPubException; 55 | } 56 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/AbstractBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | /** 25 | * A common class to represent an {@link Inbox} or an {@link Outbox}. 26 | * 27 | * @version $Id$ 28 | * @since 1.4 29 | */ 30 | @Unstable 31 | public abstract class AbstractBox extends OrderedCollection 32 | { 33 | @Override 34 | public > O addItem(AbstractActivity item) 35 | { 36 | if (!this.contains(item.getReference())) { 37 | return super.addItem(item); 38 | } else { 39 | return (O) this; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Accept.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents the Accept activity as defined by ActivityStream. 28 | * 29 | * @see ActivityStream Accept definition 30 | * @version $Id$ 31 | * @since 1.0 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = Accept.class) 35 | public class Accept extends AbstractActivity 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Announce.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents an Announce activity as defined by ActivityStream. 28 | * @see ActivityStream Announce definition 29 | * @version $Id$ 30 | * @since 1.2 31 | */ 32 | @Unstable 33 | @JsonDeserialize(as = Announce.class) 34 | public class Announce extends AbstractActivity 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Create.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Create activity as defined by ActivityStream. 28 | * @see ActivityStream Create definition 29 | * @version $Id$ 30 | * @since 1.0 31 | */ 32 | @Unstable 33 | @JsonDeserialize(as = Create.class) 34 | public class Create extends AbstractActivity 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Document.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Document as defined by ActivityStream. 28 | * @see ActivityStream Document definition 29 | * @version $Id$ 30 | * @since 1.0 31 | */ 32 | @Unstable 33 | @JsonDeserialize(as = Document.class) 34 | public class Document extends ActivityPubObject 35 | { 36 | @Override 37 | public boolean isDocument() 38 | { 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Follow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Follow activity as defined by ActivityStream. 28 | * @see ActivityStream Follow definition 29 | * @version $Id$ 30 | * @since 1.0 31 | */ 32 | @Unstable 33 | @JsonDeserialize(as = Follow.class) 34 | public class Follow extends AbstractActivity 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/JSONLDContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import java.net.URI; 23 | import java.util.ArrayList; 24 | import java.util.Arrays; 25 | 26 | /** 27 | * @since 1.1 28 | * @version $Id$ 29 | */ 30 | public class JSONLDContext extends ArrayList 31 | { 32 | /** 33 | * Initialize a new {@link JSONLDContext}. 34 | * @param uris a list of URIs of the context. 35 | */ 36 | public JSONLDContext(URI... uris) 37 | { 38 | this.addAll(Arrays.asList(uris)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Like.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Like activity as defined by ActivityStream. 28 | * 29 | * @see ActivityStream Like definition 30 | * @version $Id$ 31 | * @since 1.4 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = Like.class) 35 | public class Like extends AbstractActivity 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Mention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * @version $Id$ 28 | * @see Activity Streams Vocabulary mention 29 | * specification 30 | * @since 1.4 31 | */ 32 | @Unstable 33 | @JsonDeserialize(as = Mention.class) 34 | public class Mention extends Link 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Note.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Note as defined by ActivityStream. 28 | * 29 | * @see ActivityStream Note definition 30 | * @version $Id$ 31 | * @since 1.0 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = Note.class) 35 | public class Note extends ActivityPubObject 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Outbox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 24 | 25 | /** 26 | * Represents an Outbox as defined by ActivityPub. 27 | * 28 | * @see ActivityPub Outbox definition 29 | * @version $Id$ 30 | * @since 1.0 31 | */ 32 | @Unstable 33 | @JsonDeserialize(as = Outbox.class) 34 | public class Outbox extends AbstractBox 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Page.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Page as defined by ActivityStream. 28 | * A Page is a specific type of Document representing a webpage. 29 | * 30 | * @see ActivityStream Page definition 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | @Unstable 35 | @JsonDeserialize(as = Page.class) 36 | public class Page extends Document 37 | { 38 | } 39 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Person as defined by ActivityStream. 28 | * 29 | * @see ActivityStream Person definition 30 | * @version $Id$ 31 | * @since 1.0 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = Person.class) 35 | public class Person extends AbstractActor 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Reject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents the Reject activity as defined by ActivityStream. 28 | * 29 | * @see ActivityStream Accept definition 30 | * @version $Id$ 31 | * @since 1.0 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = Reject.class) 35 | public class Reject extends AbstractActivity 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents a Service actor as defined by ActivityStream vocabulary. 28 | * This is used in particular in XWiki to represent an entire wiki. 29 | * 30 | * @see ActivityStream Definition 31 | * @since 1.2 32 | * @version $Id$ 33 | */ 34 | @Unstable 35 | @JsonDeserialize(as = Service.class) 36 | public class Service extends AbstractActor 37 | { 38 | } 39 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/UnknownTypeObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents an ActivityPub object with an unknown type. It has the same field as an ActivityPub object but its type is 28 | * set as Unknown. 29 | * 30 | * @version $Id$ 31 | * @since 1.7.1 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = UnknownTypeObject.class) 35 | public class UnknownTypeObject extends ActivityPubObject 36 | { 37 | private String unknownType; 38 | 39 | @Override 40 | public T setType(String type) 41 | { 42 | this.unknownType = type; 43 | return (T) this; 44 | } 45 | 46 | @Override 47 | public String getType() 48 | { 49 | return "Unknown"; 50 | } 51 | 52 | /** 53 | * The declared type of the object. This value can be used to know what is the actual type of an 54 | * deserialized activitypub object even if its type have not been found. 55 | * 56 | * @return the actual type of the object 57 | */ 58 | public String getActualType() 59 | { 60 | return this.unknownType; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/entities/Update.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import org.xwiki.stability.Unstable; 23 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | 26 | /** 27 | * Represents an Update activity as defined by ActivityStream. 28 | * 29 | * @version $Id$ 30 | * @see ActivityStream Updated definition 31 | * @since 1.2 32 | */ 33 | @Unstable 34 | @JsonDeserialize(as = Update.class) 35 | public class Update extends AbstractActivity 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/ObjectMapperConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json; 21 | 22 | import org.xwiki.component.annotation.Role; 23 | 24 | import com.fasterxml.jackson.databind.ObjectMapper; 25 | 26 | /** 27 | * A generic component to return an {@link ObjectMapper} to be used in the 28 | * {@link org.xwiki.contrib.activitypub.ActivityPubJsonParser} and 29 | * {@link org.xwiki.contrib.activitypub.ActivityPubJsonSerializer}. 30 | * 31 | * @since 1.2 32 | * @version $Id$ 33 | */ 34 | @Role 35 | public interface ObjectMapperConfiguration 36 | { 37 | /** 38 | * @return the actual object mapper to be used in a Jackson parser/serializer. 39 | */ 40 | ObjectMapper getObjectMapper(); 41 | } 42 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/absolute/DefaultActivityPubJsonParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.absolute; 21 | 22 | import javax.inject.Inject; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.ActivityPubJsonParser; 27 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubJsonParser; 28 | import org.xwiki.contrib.activitypub.internal.json.ObjectMapperConfiguration; 29 | 30 | import com.fasterxml.jackson.databind.ObjectMapper; 31 | 32 | /** 33 | * Default implementation of {@link ActivityPubJsonParser}. 34 | * This implementation will keep all URI absolute when parsing the information. 35 | * 36 | * @version $Id$ 37 | * @since 1.2 38 | */ 39 | @Component 40 | @Singleton 41 | public class DefaultActivityPubJsonParser extends AbstractActivityPubJsonParser 42 | { 43 | @Inject 44 | private ObjectMapperConfiguration objectMapperConfiguration; 45 | 46 | @Override 47 | public ObjectMapper getObjectMapper() 48 | { 49 | return this.objectMapperConfiguration.getObjectMapper(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/absolute/DefaultActivityPubJsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.absolute; 21 | 22 | import javax.inject.Inject; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.ActivityPubJsonSerializer; 27 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubJsonSerializer; 28 | import org.xwiki.contrib.activitypub.internal.json.ObjectMapperConfiguration; 29 | 30 | import com.fasterxml.jackson.databind.ObjectMapper; 31 | 32 | /** 33 | * Default implementation of {@link ActivityPubJsonSerializer}. 34 | * This implementation will keep all URI absolute when serializing the information. 35 | * 36 | * @version $Id$ 37 | * @since 1.2 38 | */ 39 | @Component 40 | @Singleton 41 | public class DefaultActivityPubJsonSerializer extends AbstractActivityPubJsonSerializer 42 | { 43 | @Inject 44 | private ObjectMapperConfiguration objectMapperConfiguration; 45 | 46 | @Override 47 | public ObjectMapper getObjectMapper() 48 | { 49 | return this.objectMapperConfiguration.getObjectMapper(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/absolute/DefaultActivityPubObjectReferenceDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.absolute; 21 | 22 | import java.net.URI; 23 | 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubObjectReferenceDeserializer; 28 | 29 | /** 30 | * Default implementation of the JsonDeserializer for ActivityPubObjectReference. 31 | * This implementation doesn't transform the URI and keep them absolute. 32 | * 33 | * @since 1.2 34 | * @version $Id$ 35 | */ 36 | @Component(roles = DefaultActivityPubObjectReferenceDeserializer.class) 37 | @Singleton 38 | public class DefaultActivityPubObjectReferenceDeserializer extends AbstractActivityPubObjectReferenceDeserializer 39 | { 40 | @Override 41 | public URI transformURI(URI uri) 42 | { 43 | return uri; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/absolute/DefaultActivityPubObjectReferenceSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.absolute; 21 | 22 | import java.net.URI; 23 | 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubObjectReferenceSerializer; 28 | 29 | /** 30 | * Default implementation of the JsonSerializer for ActivityPubObjectReference. 31 | * This implementation doesn't transform the URI and keep them absolute. 32 | * 33 | * @since 1.2 34 | * @version $Id$ 35 | */ 36 | @Component(roles = DefaultActivityPubObjectReferenceSerializer.class) 37 | @Singleton 38 | public class DefaultActivityPubObjectReferenceSerializer extends AbstractActivityPubObjectReferenceSerializer 39 | { 40 | @Override 41 | public URI transformURI(URI inputURI) 42 | { 43 | return inputURI; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/absolute/DefaultObjectMapperConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.absolute; 21 | 22 | import javax.inject.Inject; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.entities.ActivityPubObjectReference; 27 | import org.xwiki.contrib.activitypub.internal.json.AbstractObjectMapperConfiguration; 28 | 29 | import com.fasterxml.jackson.databind.JsonDeserializer; 30 | import com.fasterxml.jackson.databind.JsonSerializer; 31 | import com.fasterxml.jackson.databind.ObjectMapper; 32 | 33 | /** 34 | * Default implementation of the {@link org.xwiki.contrib.activitypub.internal.json.ObjectMapperConfiguration}. 35 | * This implementation defines an {@link ObjectMapper} using default implementations of JsonSerializer and Deserializer 36 | * for {@link ActivityPubObjectReference} which keep absolute URI. 37 | * 38 | * @since 1.2 39 | * @version $Id$ 40 | */ 41 | @Component 42 | @Singleton 43 | public class DefaultObjectMapperConfiguration extends AbstractObjectMapperConfiguration 44 | { 45 | @Inject 46 | private DefaultActivityPubObjectReferenceSerializer objectReferenceSerializer; 47 | 48 | @Inject 49 | private DefaultActivityPubObjectReferenceDeserializer objectReferenceDeserializer; 50 | 51 | @Override 52 | public JsonSerializer getObjectReferenceSerializer() 53 | { 54 | return this.objectReferenceSerializer; 55 | } 56 | 57 | @Override 58 | public JsonDeserializer getObjectReferenceDeserializer() 59 | { 60 | return this.objectReferenceDeserializer; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/relative/RelativeActivityPubJsonParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.relative; 21 | 22 | import javax.inject.Inject; 23 | import javax.inject.Named; 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.ActivityPubJsonParser; 28 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubJsonParser; 29 | import org.xwiki.contrib.activitypub.internal.json.ObjectMapperConfiguration; 30 | 31 | import com.fasterxml.jackson.databind.ObjectMapper; 32 | 33 | /** 34 | * An implementation of {@link ActivityPubJsonParser} that relies on the {@link RelativeObjectMapperConfiguration}. 35 | * 36 | * @version $Id$ 37 | * @since 1.2 38 | */ 39 | @Component 40 | @Named("relative") 41 | @Singleton 42 | public class RelativeActivityPubJsonParser extends AbstractActivityPubJsonParser 43 | { 44 | @Inject 45 | @Named("relative") 46 | private ObjectMapperConfiguration objectMapperConfiguration; 47 | 48 | @Override 49 | public ObjectMapper getObjectMapper() 50 | { 51 | return this.objectMapperConfiguration.getObjectMapper(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/relative/RelativeActivityPubJsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.relative; 21 | 22 | import javax.inject.Inject; 23 | import javax.inject.Named; 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.ActivityPubJsonSerializer; 28 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubJsonSerializer; 29 | import org.xwiki.contrib.activitypub.internal.json.ObjectMapperConfiguration; 30 | 31 | import com.fasterxml.jackson.databind.ObjectMapper; 32 | 33 | /** 34 | * An implementation of {@link ActivityPubJsonSerializer} that relies on the {@link RelativeObjectMapperConfiguration}. 35 | * 36 | * @since 1.2 37 | * @version $Id$ 38 | */ 39 | @Component 40 | @Named("relative") 41 | @Singleton 42 | public class RelativeActivityPubJsonSerializer extends AbstractActivityPubJsonSerializer 43 | { 44 | @Inject 45 | @Named("relative") 46 | private ObjectMapperConfiguration objectMapperConfiguration; 47 | 48 | @Override 49 | public ObjectMapper getObjectMapper() 50 | { 51 | return this.objectMapperConfiguration.getObjectMapper(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/relative/RelativeActivityPubObjectReferenceDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.relative; 21 | 22 | import java.net.URI; 23 | 24 | import javax.inject.Inject; 25 | import javax.inject.Singleton; 26 | 27 | import org.xwiki.component.annotation.Component; 28 | import org.xwiki.contrib.activitypub.ActivityPubException; 29 | import org.xwiki.contrib.activitypub.internal.InternalURINormalizer; 30 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubObjectReferenceDeserializer; 31 | 32 | /** 33 | * A custom version of {@link AbstractActivityPubObjectReferenceDeserializer} that transforms local relative URI to 34 | * obtain the absolute ones: this implementation is mainly used inside the storage to retrieve right information. 35 | * 36 | * @version $Id$ 37 | * @since 1.2 38 | */ 39 | @Component(roles = RelativeActivityPubObjectReferenceDeserializer.class) 40 | @Singleton 41 | public class RelativeActivityPubObjectReferenceDeserializer extends AbstractActivityPubObjectReferenceDeserializer 42 | { 43 | @Inject 44 | private InternalURINormalizer internalURINormalizer; 45 | 46 | @Override 47 | public URI transformURI(URI uri) throws ActivityPubException 48 | { 49 | return this.internalURINormalizer.retrieveAbsoluteURI(uri); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/relative/RelativeActivityPubObjectReferenceSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.relative; 21 | 22 | import java.net.URI; 23 | 24 | import javax.inject.Inject; 25 | import javax.inject.Singleton; 26 | 27 | import org.xwiki.component.annotation.Component; 28 | import org.xwiki.contrib.activitypub.ActivityPubException; 29 | import org.xwiki.contrib.activitypub.internal.InternalURINormalizer; 30 | import org.xwiki.contrib.activitypub.internal.json.AbstractActivityPubObjectReferenceSerializer; 31 | 32 | /** 33 | * A custom version of {@link AbstractActivityPubObjectReferenceSerializer} that transforms local absolute URI to 34 | * keep them relative: this implementation is mainly used inside the storage to keep right information. 35 | * 36 | * @version $Id$ 37 | * @since 1.2 38 | */ 39 | @Component(roles = RelativeActivityPubObjectReferenceSerializer.class) 40 | @Singleton 41 | public class RelativeActivityPubObjectReferenceSerializer extends AbstractActivityPubObjectReferenceSerializer 42 | { 43 | @Inject 44 | private InternalURINormalizer internalURINormalizer; 45 | 46 | @Override 47 | public URI transformURI(URI inputURI) throws ActivityPubException 48 | { 49 | return this.internalURINormalizer.relativizeURI(inputURI); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/json/relative/RelativeObjectMapperConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.json.relative; 21 | 22 | import javax.inject.Inject; 23 | import javax.inject.Named; 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.entities.ActivityPubObjectReference; 28 | import org.xwiki.contrib.activitypub.internal.json.AbstractObjectMapperConfiguration; 29 | 30 | import com.fasterxml.jackson.databind.JsonDeserializer; 31 | import com.fasterxml.jackson.databind.JsonSerializer; 32 | 33 | /** 34 | * Custom implementation of the {@link org.xwiki.contrib.activitypub.internal.json.ObjectMapperConfiguration} that 35 | * uses relative implementations of JsonSerializer and Deserializer for {@link ActivityPubObjectReference}. 36 | * This configuration has been created to be used in the storage. 37 | * 38 | * @since 1.2 39 | * @version $Id$ 40 | */ 41 | @Component 42 | @Named("relative") 43 | @Singleton 44 | public class RelativeObjectMapperConfiguration extends AbstractObjectMapperConfiguration 45 | { 46 | @Inject 47 | private RelativeActivityPubObjectReferenceSerializer objectReferenceSerializer; 48 | 49 | @Inject 50 | private RelativeActivityPubObjectReferenceDeserializer objectReferenceDeserializer; 51 | 52 | @Override 53 | public JsonSerializer getObjectReferenceSerializer() 54 | { 55 | return this.objectReferenceSerializer; 56 | } 57 | 58 | @Override 59 | public JsonDeserializer getObjectReferenceDeserializer() 60 | { 61 | return this.objectReferenceDeserializer; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/stream/StreamActivityPubObjectReferenceResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.stream; 21 | 22 | import java.util.function.Function; 23 | 24 | import javax.inject.Inject; 25 | import javax.inject.Singleton; 26 | 27 | import org.slf4j.Logger; 28 | import org.xwiki.component.annotation.Component; 29 | import org.xwiki.contrib.activitypub.ActivityPubException; 30 | import org.xwiki.contrib.activitypub.ActivityPubObjectReferenceResolver; 31 | import org.xwiki.contrib.activitypub.entities.ActivityPubObject; 32 | import org.xwiki.contrib.activitypub.entities.ActivityPubObjectReference; 33 | 34 | /** 35 | * A generic component that allows to resolve a {@link ActivityPubObjectReference} in a stream. 36 | * 37 | * @version $Id$ 38 | * @since 1.2 39 | */ 40 | @Component(roles = StreamActivityPubObjectReferenceResolver.class) 41 | @Singleton 42 | public class StreamActivityPubObjectReferenceResolver 43 | { 44 | @Inject 45 | private ActivityPubObjectReferenceResolver activityPubObjectReferenceResolver; 46 | 47 | @Inject 48 | private Logger logger; 49 | 50 | /** 51 | * The function to be used a in stream map to resolve an ActivityPubObjectReference from its reference. 52 | * 53 | * @param the actual true type of the ActivityPub object. 54 | * @return a function that perform the transformation with the right types. 55 | */ 56 | public Function, T> getFunction() 57 | { 58 | return objectReference -> { 59 | try { 60 | return activityPubObjectReferenceResolver.resolveReference(objectReference); 61 | } catch (ActivityPubException e) { 62 | logger.error("Error while resolving reference [{}]", objectReference, e); 63 | return null; 64 | } 65 | }; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /activitypub-core/src/main/java/org/xwiki/contrib/activitypub/internal/stream/StreamActivityPubObjectReferenceSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.stream; 21 | 22 | import java.util.function.Function; 23 | 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.entities.ActivityPubObject; 28 | import org.xwiki.contrib.activitypub.entities.ActivityPubObjectReference; 29 | 30 | /** 31 | * A generic component that allows to transform an {@link ActivityPubObject} to a reference in a stream while keeping 32 | * the right type. 33 | * 34 | * @version $Id$ 35 | * @since 1.2 36 | */ 37 | @Component(roles = StreamActivityPubObjectReferenceSerializer.class) 38 | @Singleton 39 | public class StreamActivityPubObjectReferenceSerializer 40 | { 41 | /** 42 | * The function to be used a in stream map to transform an ActivityPubObject into its reference. 43 | * 44 | * @param the actual true type of the ActivityPub object. 45 | * @return a function that perform the transformation with the right types. 46 | */ 47 | public Function> getFunction() 48 | { 49 | return ActivityPubObject::getReference; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-core/src/main/resources/META-INF/components.txt: -------------------------------------------------------------------------------- 1 | org.xwiki.contrib.activitypub.internal.json.JSONLDContextDeserializer 2 | org.xwiki.contrib.activitypub.internal.DefaultActivityPubIdentifierService 3 | org.xwiki.contrib.activitypub.internal.DefaultActivityPubObjectReferenceResolver 4 | org.xwiki.contrib.activitypub.internal.stream.StreamActivityPubObjectReferenceResolver 5 | org.xwiki.contrib.activitypub.internal.stream.StreamActivityPubObjectReferenceSerializer 6 | org.xwiki.contrib.activitypub.internal.json.absolute.DefaultActivityPubJsonParser 7 | org.xwiki.contrib.activitypub.internal.json.absolute.DefaultActivityPubJsonSerializer 8 | org.xwiki.contrib.activitypub.internal.json.absolute.DefaultActivityPubObjectReferenceDeserializer 9 | org.xwiki.contrib.activitypub.internal.json.absolute.DefaultActivityPubObjectReferenceSerializer 10 | org.xwiki.contrib.activitypub.internal.json.absolute.DefaultObjectMapperConfiguration 11 | org.xwiki.contrib.activitypub.internal.json.relative.RelativeActivityPubJsonParser 12 | org.xwiki.contrib.activitypub.internal.json.relative.RelativeActivityPubJsonSerializer 13 | org.xwiki.contrib.activitypub.internal.json.relative.RelativeActivityPubObjectReferenceDeserializer 14 | org.xwiki.contrib.activitypub.internal.json.relative.RelativeActivityPubObjectReferenceSerializer 15 | org.xwiki.contrib.activitypub.internal.json.relative.RelativeObjectMapperConfiguration 16 | org.xwiki.contrib.activitypub.internal.InternalURINormalizer 17 | -------------------------------------------------------------------------------- /activitypub-core/src/test/java/org/xwiki/contrib/activitypub/entities/LinkTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import java.net.URI; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | /** 29 | * Test of {@link Link}. 30 | * 31 | * @version $Id$ 32 | * @since 1.4 33 | */ 34 | class LinkTest extends AbstractEntityTest 35 | { 36 | private static final String LINK_ID = "http://localhost:8080/xwiki/activitypub/link/1"; 37 | 38 | @Test 39 | void serialization() throws Exception 40 | { 41 | Link inbox = new Link().setId(new URI(LINK_ID)); 42 | 43 | String expectedSerialization = this.readResource("link/link1.json"); 44 | assertEquals(expectedSerialization, this.serializer.serialize(inbox)); 45 | } 46 | 47 | @Test 48 | void parsing() throws Exception 49 | { 50 | Link expectedInbox = new Link().setId(new URI(LINK_ID)); 51 | 52 | String json = this.readResource("link/link1.json"); 53 | assertEquals(expectedInbox, this.parser.parse(json, Link.class)); 54 | assertEquals(expectedInbox, this.parser.parse(json)); 55 | } 56 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/java/org/xwiki/contrib/activitypub/entities/MentionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.entities; 21 | 22 | import java.net.URI; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | /** 29 | * Test of {@link Mention}. 30 | * 31 | * @version $Id$ 32 | * @since 1.4 33 | */ 34 | class MentionTest extends AbstractEntityTest 35 | { 36 | private static final String MENTION_ID = "http://localhost:8080/xwiki/activitypub/mention/1"; 37 | 38 | @Test 39 | void serialization() throws Exception 40 | { 41 | Mention inbox = new Mention().setId(new URI(MENTION_ID)); 42 | 43 | String expectedSerialization = this.readResource("mention/mention1.json"); 44 | assertEquals(expectedSerialization, this.serializer.serialize(inbox)); 45 | } 46 | 47 | @Test 48 | void parsing() throws Exception 49 | { 50 | Mention expectedInbox = new Mention().setId(new URI(MENTION_ID)); 51 | 52 | String json = this.readResource("mention/mention1.json"); 53 | assertEquals(expectedInbox, this.parser.parse(json, Mention.class)); 54 | assertEquals(expectedInbox, this.parser.parse(json)); 55 | } 56 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/java/org/xwiki/contrib/activitypub/internal/stream/StreamActivityPubObjectReferenceSerializerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.stream; 21 | 22 | import java.util.function.Function; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.xwiki.contrib.activitypub.entities.ActivityPubObject; 26 | import org.xwiki.contrib.activitypub.entities.ActivityPubObjectReference; 27 | import org.xwiki.contrib.activitypub.entities.Note; 28 | import org.xwiki.test.junit5.mockito.ComponentTest; 29 | import org.xwiki.test.junit5.mockito.InjectMockComponents; 30 | 31 | import static org.junit.jupiter.api.Assertions.assertSame; 32 | import static org.mockito.Mockito.mock; 33 | import static org.mockito.Mockito.when; 34 | 35 | /** 36 | * Tests for {@link StreamActivityPubObjectReferenceSerializer}. 37 | * 38 | * @version $Id$ 39 | * @since 1.2 40 | */ 41 | @ComponentTest 42 | public class StreamActivityPubObjectReferenceSerializerTest 43 | { 44 | @InjectMockComponents 45 | private StreamActivityPubObjectReferenceSerializer streamActivityPubObjectReferenceSerializer; 46 | 47 | @Test 48 | public void getFunction() 49 | { 50 | Function> function = 51 | this.streamActivityPubObjectReferenceSerializer.getFunction(); 52 | 53 | Note note = mock(Note.class); 54 | ActivityPubObjectReference noteReference = mock(ActivityPubObjectReference.class); 55 | when(note.getReference()).thenReturn(noteReference); 56 | assertSame(noteReference, function.apply(note)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/accept/accept1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "actor" : "https://social.example/alyssa/", 4 | "id" : "https://social.example/alyssa/posts/a29a6843-9feb-4c74-a7f7-081b9c9201d3", 5 | "object" : "https://social.example/alyssa/posts/49e2d03d-b53a-4c4c-a95c-94a6abf45a19", 6 | "to" : [ "https://chatty.example/ben/" ], 7 | "type" : "Accept" 8 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/announce/announce1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "actor" : "https://social.example/alyssa/", 4 | "id" : "https://social.example/alyssa/posts/a29a6843-9feb-4c74-a7f7-081b9c9201d3", 5 | "object" : "https://social.example/alyssa/posts/49e2d03d-b53a-4c4c-a95c-94a6abf45a19", 6 | "to" : [ "https://chatty.example/ben/" ], 7 | "type" : "Announce" 8 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/collection/collection1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "items" : [ "http://test/follow/1", "http://test/accept/2" ], 4 | "totalItems" : 2, 5 | "type" : "Collection" 6 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/create/create1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "actor" : "https://social.example/alyssa/", 4 | "id" : "https://social.example/alyssa/posts/a29a6843-9feb-4c74-a7f7-081b9c9201d3", 5 | "object" : "https://social.example/alyssa/posts/49e2d03d-b53a-4c4c-a95c-94a6abf45a19", 6 | "to" : [ "https://chatty.example/ben/" ], 7 | "type" : "Create" 8 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/follow/follow1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "actor" : "https://social.example/alyssa/", 4 | "attributedTo" : [ "http://test/person/1" ], 5 | "content" : "test content", 6 | "id" : "https://social.example/alyssa/posts/a29a6843-9feb-4c74-a7f7-081b9c9201d3", 7 | "object" : "https://social.example/alyssa/posts/49e2d03d-b53a-4c4c-a95c-94a6abf45a19", 8 | "published" : 951185225201, 9 | "to" : [ "https://chatty.example/ben/" ], 10 | "type" : "Follow", 11 | "url" : [ "http://myurl" ] 12 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/follow/nextcloud.json: -------------------------------------------------------------------------------- 1 | {"@context":["https:\/\/www.w3.org\/ns\/activitystreams"],"id":"http:\/\/nextcloud.home\/fe4c8b2e-415a-4e68-b769-718e01ba71f7","type":"Follow","actor":"http:\/\/nextcloud.home\/apps\/social\/@admin","object":"http:\/\/xwiki.home\/xwiki\/activitypub\/Person\/XWiki.Admin"} -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/inbox/inbox1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/Inbox/XWiki.Foo-inbox", 4 | "orderedItems" : [ "http://test/create/1", "http://test/follow/2" ], 5 | "totalItems" : 2, 6 | "type" : "Inbox" 7 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/link/link1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/link/1", 4 | "type" : "Link" 5 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/mention/mention1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/mention/1", 4 | "type" : "Mention" 5 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/note/note1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/Note/XWiki.Foo-note", 4 | "tag" : [ "https://localhost:8080/xwiki/activitypub/Mentions/mentionid" ], 5 | "type" : "Note" 6 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/note/note2.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "to" : [ "https://another.example/bob/followers", "https://www.w3.org/ns/activitystreams#Public", "https://social.example/alyssa/" ], 4 | "type" : "Note" 5 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/note/note3.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/Note/XWiki.Foo-note", 4 | "tag" : [{ 5 | "type": "Mention", 6 | "id": "https://localhost:8080/xwiki/activitypub/Mentions/mentionid" 7 | }], 8 | "type" : "Note" 9 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/note/note4.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/Note/XWiki.Foo-note", 4 | "tag" : [{ 5 | "type": "UnknownType", 6 | "id": "https://localhost:8080/xwiki/activitypub/UnknownType/id" 7 | }], 8 | "type" : "Note" 9 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/outbox/outbox1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://localhost:8080/xwiki/activitypub/Outbox/XWiki.Foo-outbox", 4 | "orderedItems" : [ "http://test/create/1", "http://test/follow/2" ], 5 | "totalItems" : 2, 6 | "type" : "Outbox" 7 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/person/mastodon.json: -------------------------------------------------------------------------------- 1 | {"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","toot":"http://joinmastodon.org/ns#","featured":{"@id":"toot:featured","@type":"@id"},"alsoKnownAs":{"@id":"as:alsoKnownAs","@type":"@id"},"movedTo":{"@id":"as:movedTo","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value","IdentityProof":"toot:IdentityProof","discoverable":"toot:discoverable"}],"id":"http://mastodon.local/users/mleduc","type":"Person","following":"http://mastodon.local/users/mleduc/following","followers":"http://mastodon.local/users/mleduc/followers","inbox":"http://mastodon.local/users/mleduc/inbox","outbox":"http://mastodon.local/users/mleduc/outbox","featured":"http://mastodon.local/users/mleduc/collections/featured","preferredUsername":"mleduc","name":"","summary":"\u003cp\u003e\u003c/p\u003e","url":"http://mastodon.local/@mleduc","manuallyApprovesFollowers":false,"discoverable":null,"publicKey":{"id":"http://mastodon.local/users/mleduc#main-key","owner":"http://mastodon.local/users/mleduc","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuRdEQZm4c8HYG/+Q41/p\nWljrOcFIu0+9Cs5J+PXpFwI9gUQln/Hf5jHAaVEzGEWIuhiYzW6xAy9nGe4ikfjy\n7Y0pvQrK0AQh/nXi5FWIuI1tDsAPoUtBQAcs4Bc5p13xOtaaQ18Iuvo5LowHgklG\nbLmDWTQ9d6FgWvgFcGfvyFcsl1x3H0CKfts2UoB63XpkHgJOYaMk2u/EBxnddOQ3\nCmP+r3D31Eqp++/nOMWkb6zK1iYqOV/u/OOZXIeWXuqLHJnqHesrWNyVCSAjyPu+\nJQgYfHbPH1dS7ZjjWk0wEQnQAZQgB/VaNMWrdS5UQ+z4O0ykdQUd/AmQHAWLwoGu\nLQIDAQAB\n-----END PUBLIC KEY-----\n"},"tag":[],"attachment":[],"endpoints":{"sharedInbox":"http://mastodon.local/inbox"}} -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/person/person1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "id" : "http://www.xwiki.org/wiki/activitypub/Foo", 4 | "name" : "XWiki.Foo", 5 | "preferredUsername" : "Foo bar", 6 | "publicKey" : { 7 | "id" : "pkid", 8 | "owner" : "pkowner", 9 | "publicKeyPem" : "pkpem" 10 | }, 11 | "type" : "Person" 12 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/person/person2.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://www.w3.org/ns/activitystreams", 3 | "type": "Person", 4 | "id": "https://social.example/alyssa/", 5 | "name": "Alyssa P. Hacker", 6 | "preferredUsername": "alyssa", 7 | "summary": "Lisp enthusiast hailing from MIT", 8 | "inbox": "https://social.example/alyssa/inbox/", 9 | "outbox": "https://social.example/alyssa/outbox/", 10 | "followers": "https://social.example/alyssa/followers/", 11 | "following": "https://social.example/alyssa/following/", 12 | "liked": "https://social.example/alyssa/liked/" 13 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/reject/reject1.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : [ "https://www.w3.org/ns/activitystreams" ], 3 | "actor" : "https://social.example/alyssa/", 4 | "id" : "https://social.example/alyssa/posts/a29a6843-9feb-4c74-a7f7-081b9c9201d3", 5 | "object" : "https://social.example/alyssa/posts/49e2d03d-b53a-4c4c-a95c-94a6abf45a19", 6 | "to" : [ "https://chatty.example/ben/" ], 7 | "type" : "Reject" 8 | } -------------------------------------------------------------------------------- /activitypub-core/src/test/resources/entities/wrongtype.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context" : "https://www.w3.org/ns/activitystreams", 3 | "id" : "http://localhost:8080/xwiki/activitypub/Note/XWiki.Foo-note", 4 | "type" : "Wrong" 5 | } -------------------------------------------------------------------------------- /activitypub-notifications/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.xwiki.contrib 27 | application-activitypub 28 | 1.7.12-SNAPSHOT 29 | 30 | activitypub-notifications 31 | 1.7.12-SNAPSHOT 32 | XWiki ActivityPub - Notifications 33 | jar 34 | 35 | 0.82 36 | ${basedir}/src/checkstyle/checkstyle-suppressions.xml 37 | 38 | 39 | 40 | org.xwiki.platform 41 | xwiki-platform-notifications-api 42 | ${platform.version} 43 | 44 | 45 | 46 | org.xwiki.platform 47 | xwiki-platform-eventstream-store-hibernate 48 | ${platform.version} 49 | 50 | 51 | org.xwiki.platform 52 | xwiki-platform-notifications-notifiers-api 53 | ${platform.version} 54 | 55 | 56 | org.xwiki.contrib 57 | activitypub-core 58 | ${project.version} 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /activitypub-notifications/src/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/ActivityPubNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.component.annotation.Role; 25 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 26 | import org.xwiki.contrib.activitypub.entities.AbstractActor; 27 | import org.xwiki.stability.Unstable; 28 | 29 | /** 30 | * External API to send an ActivityPub notification. 31 | * 32 | * @version $Id$ 33 | * @since 1.0 34 | */ 35 | @Unstable 36 | @Role 37 | public interface ActivityPubNotifier 38 | { 39 | /** 40 | * Send a notification related to the given activity to the given targets. 41 | * 42 | * @param activity the activity source of the notification. 43 | * @param targetedActors the target actors of the notification. 44 | * @param the real type of the activity 45 | * @throws ActivityPubException if the activity is not supported by any event. 46 | */ 47 | void notify(T activity, Set targetedActors) throws ActivityPubException; 48 | } 49 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/AbstractActivityPubEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 25 | import org.xwiki.eventstream.RecordableEvent; 26 | import org.xwiki.eventstream.TargetableEvent; 27 | import org.xwiki.stability.Unstable; 28 | 29 | /** 30 | * Defines the generic ActivityPub event to be displayed as Notifications. 31 | * @param the type of the activity 32 | * @version $Id$ 33 | * @since 1.0 34 | */ 35 | @Unstable 36 | public abstract class AbstractActivityPubEvent implements RecordableEvent, TargetableEvent 37 | { 38 | private final Set target; 39 | private final T activity; 40 | 41 | /** 42 | * Default constructor. 43 | * @param activity the activity to notify about 44 | * @param target the serialized references of users to notify to 45 | */ 46 | public AbstractActivityPubEvent(T activity, Set target) 47 | { 48 | this.activity = activity; 49 | this.target = target; 50 | } 51 | 52 | @Override 53 | public Set getTarget() 54 | { 55 | return this.target; 56 | } 57 | 58 | /** 59 | * @return the activity this event is about. 60 | */ 61 | public T getActivity() 62 | { 63 | return this.activity; 64 | } 65 | 66 | /** 67 | * @return the type of the event that will be used in notifications. 68 | */ 69 | public abstract String getType(); 70 | } 71 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/AnnounceEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.Announce; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific event type of {@link Announce} activities. 29 | * 30 | * @version $Id$ 31 | * @since 1.2 32 | */ 33 | @Unstable 34 | public class AnnounceEvent extends AbstractActivityPubEvent 35 | { 36 | /** 37 | * Default name for those events. 38 | */ 39 | public static final String EVENT_TYPE = "activitypub.announce"; 40 | 41 | /** 42 | * Default constructor. 43 | * 44 | * @param activity An announce activity. 45 | * @param targets the serialized references of users to notify to. 46 | */ 47 | public AnnounceEvent(Announce activity, Set targets) 48 | { 49 | super(activity, targets); 50 | } 51 | 52 | @Override 53 | public String getType() 54 | { 55 | return EVENT_TYPE; 56 | } 57 | 58 | @Override 59 | public boolean matches(Object otherEvent) 60 | { 61 | return otherEvent instanceof AnnounceEvent; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/CreateEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.Create; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific event type for Create activities that concerns every other type than Notes. 29 | * Create activities about Notes are handled by a {@link MessageEvent}. 30 | * 31 | * @since 1.1 32 | * @version $Id$ 33 | */ 34 | @Unstable 35 | public class CreateEvent extends AbstractActivityPubEvent 36 | { 37 | /** 38 | * Default name for those events. 39 | */ 40 | public static final String EVENT_TYPE = "activitypub.create"; 41 | 42 | /** 43 | * Default constructor. 44 | * 45 | * @param activity the activity to notify about 46 | * @param target the serialized references of users to notify to 47 | */ 48 | public CreateEvent(Create activity, Set target) 49 | { 50 | super(activity, target); 51 | } 52 | 53 | @Override 54 | public String getType() 55 | { 56 | return EVENT_TYPE; 57 | } 58 | 59 | @Override 60 | public boolean matches(Object otherEvent) 61 | { 62 | return otherEvent instanceof CreateEvent; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/FollowEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific events when it concerns the follow activities. 29 | * This event is voluntarily not bounded to {@link org.xwiki.contrib.activitypub.entities.Follow} type, so we can 30 | * also handle {@link org.xwiki.contrib.activitypub.entities.Accept} or 31 | * {@link org.xwiki.contrib.activitypub.entities.Reject} activities with it, since they are related to the follow 32 | * activities. 33 | * 34 | * @param the actual type of the activity. 35 | * @version $Id$ 36 | * @since 1.1 37 | */ 38 | @Unstable 39 | public class FollowEvent extends AbstractActivityPubEvent 40 | { 41 | /** 42 | * Default name for those events. 43 | */ 44 | public static final String EVENT_TYPE = "activitypub.follow"; 45 | 46 | /** 47 | * Default constructor. 48 | * 49 | * @param activity the activity to notify about 50 | * @param target the serialized references of users to notify to 51 | */ 52 | public FollowEvent(T activity, Set target) 53 | { 54 | super(activity, target); 55 | } 56 | 57 | @Override 58 | public String getType() 59 | { 60 | return EVENT_TYPE; 61 | } 62 | 63 | @Override 64 | public boolean matches(Object otherEvent) 65 | { 66 | return otherEvent instanceof FollowEvent; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/LikeEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.Like; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific event type for Like activities. 29 | * 30 | * @version $Id$ 31 | * @since 1.5 32 | */ 33 | @Unstable 34 | public class LikeEvent extends AbstractActivityPubEvent 35 | { 36 | /** 37 | * Default name for those events. 38 | */ 39 | public static final String EVENT_TYPE = "activitypub.like"; 40 | 41 | /** 42 | * Default constructor. 43 | * 44 | * @param activity the activity to notify about 45 | * @param target the serialized references of users to notify to 46 | */ 47 | public LikeEvent(Like activity, Set target) 48 | { 49 | super(activity, target); 50 | } 51 | 52 | @Override 53 | public String getType() 54 | { 55 | return EVENT_TYPE; 56 | } 57 | 58 | @Override 59 | public boolean matches(Object otherEvent) 60 | { 61 | return otherEvent instanceof LikeEvent; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/MentionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific event type for actor mentions from the fediverse. 29 | * 30 | * @since 1.4 31 | * @version $Id$ 32 | */ 33 | @Unstable 34 | public class MentionEvent extends AbstractActivityPubEvent 35 | { 36 | /** 37 | * Default name for those events. 38 | */ 39 | public static final String EVENT_TYPE = "activitypub.mention"; 40 | 41 | /** 42 | * Default constructor. 43 | * 44 | * @param activity the activity to notify about 45 | * @param target the serialized references of users to notify to 46 | */ 47 | public MentionEvent(AbstractActivity activity, Set target) 48 | { 49 | super(activity, target); 50 | } 51 | 52 | @Override 53 | public String getType() 54 | { 55 | return EVENT_TYPE; 56 | } 57 | 58 | @Override 59 | public boolean matches(Object otherEvent) 60 | { 61 | return otherEvent instanceof MentionEvent; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/MessageEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.Create; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific event type for Create activities of Note only. 29 | * All other Create events are handled by {@link CreateEvent}. 30 | * 31 | * @since 1.2 32 | * @version $Id$ 33 | */ 34 | @Unstable 35 | public class MessageEvent extends AbstractActivityPubEvent 36 | { 37 | /** 38 | * Default name for those events. 39 | */ 40 | public static final String EVENT_TYPE = "activitypub.message"; 41 | 42 | /** 43 | * Default constructor. 44 | * 45 | * @param activity the activity to notify about 46 | * @param target the serialized references of users to notify to 47 | */ 48 | public MessageEvent(Create activity, Set target) 49 | { 50 | super(activity, target); 51 | } 52 | 53 | @Override 54 | public String getType() 55 | { 56 | return EVENT_TYPE; 57 | } 58 | 59 | @Override 60 | public boolean matches(Object otherEvent) 61 | { 62 | return otherEvent instanceof MessageEvent; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/events/UpdateEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import java.util.Set; 23 | 24 | import org.xwiki.contrib.activitypub.entities.Update; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * A specific event type for Update activities. 29 | * 30 | * @version $Id$ 31 | * @since 1.2 32 | */ 33 | @Unstable 34 | public class UpdateEvent extends AbstractActivityPubEvent 35 | { 36 | /** 37 | * Default name for those events. 38 | */ 39 | public static final String EVENT_TYPE = "activitypub.update"; 40 | 41 | /** 42 | * Default constructor. 43 | * 44 | * @param activity the activity to notify about 45 | * @param target the serialized references of users to notify to 46 | */ 47 | public UpdateEvent(Update activity, Set target) 48 | { 49 | super(activity, target); 50 | } 51 | 52 | @Override 53 | public String getType() 54 | { 55 | return EVENT_TYPE; 56 | } 57 | 58 | @Override 59 | public boolean matches(Object otherEvent) 60 | { 61 | return otherEvent instanceof UpdateEvent; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/AbstractActivityPubEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import org.xwiki.eventstream.RecordableEventDescriptor; 23 | 24 | /** 25 | * An abstract event descriptor for ActivityPub to allows enabling/disabling the notifications. 26 | * 27 | * @version $Id$ 28 | * @since 1.0 29 | */ 30 | public abstract class AbstractActivityPubEventDescriptor implements RecordableEventDescriptor 31 | { 32 | @Override 33 | public String getApplicationName() 34 | { 35 | return "activitypub.application.name"; 36 | } 37 | 38 | @Override 39 | public String getApplicationIcon() 40 | { 41 | return "branch"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/AnnounceEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.AnnounceEvent; 27 | 28 | /** 29 | * Event descriptor for {@link AnnounceEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(AnnounceEvent.EVENT_TYPE) 37 | public class AnnounceEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return AnnounceEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.announce.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/CreateEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.CreateEvent; 27 | 28 | /** 29 | * Event descriptor for {@link CreateEvent}. 30 | * 31 | * @since 1.1 32 | * @version $Id$ 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(CreateEvent.EVENT_TYPE) 37 | public class CreateEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return CreateEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.create.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/FollowEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.FollowEvent; 27 | 28 | /** 29 | * Event descriptor for {@link FollowEvent}. 30 | * 31 | * @since 1.1 32 | * @version $Id$ 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(FollowEvent.EVENT_TYPE) 37 | public class FollowEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return FollowEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.follow.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/LikeEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.LikeEvent; 27 | 28 | /** 29 | * Event descriptor for {@link LikeEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.5 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(LikeEvent.EVENT_TYPE) 37 | public class LikeEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return LikeEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.like.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/MentionEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.MentionEvent; 27 | 28 | /** 29 | * Event descriptor for {@link MentionEvent}. 30 | * 31 | * @since 1.4 32 | * @version $Id$ 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(MentionEvent.EVENT_TYPE) 37 | public class MentionEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return MentionEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.mention.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/MessageEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.MessageEvent; 27 | 28 | /** 29 | * Event descriptor for {@link MessageEvent}. 30 | * 31 | * @since 1.2 32 | * @version $Id$ 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(MessageEvent.EVENT_TYPE) 37 | public class MessageEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return MessageEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.message.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/java/org/xwiki/contrib/activitypub/internal/descriptors/UpdateEventDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.descriptors; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.contrib.activitypub.events.UpdateEvent; 27 | 28 | /** 29 | * Event descriptor for {@link UpdateEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | @Component 35 | @Singleton 36 | @Named(UpdateEvent.EVENT_TYPE) 37 | public class UpdateEventDescriptor extends AbstractActivityPubEventDescriptor 38 | { 39 | @Override 40 | public String getEventType() 41 | { 42 | return UpdateEvent.EVENT_TYPE; 43 | } 44 | 45 | @Override 46 | public String getDescription() 47 | { 48 | return "activitypub.update.event.description"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /activitypub-notifications/src/main/resources/META-INF/components.txt: -------------------------------------------------------------------------------- 1 | org.xwiki.contrib.activitypub.internal.DefaultActivityPubNotifier 2 | org.xwiki.contrib.activitypub.internal.ActivityPubNotificationDisplayer 3 | org.xwiki.contrib.activitypub.internal.ActivityPubRecordableEventConverter 4 | org.xwiki.contrib.activitypub.internal.ActivityPubLegacyEventConverter 5 | org.xwiki.contrib.activitypub.internal.descriptors.AnnounceEventDescriptor 6 | org.xwiki.contrib.activitypub.internal.descriptors.CreateEventDescriptor 7 | org.xwiki.contrib.activitypub.internal.descriptors.FollowEventDescriptor 8 | org.xwiki.contrib.activitypub.internal.descriptors.MentionEventDescriptor 9 | org.xwiki.contrib.activitypub.internal.descriptors.MessageEventDescriptor 10 | org.xwiki.contrib.activitypub.internal.descriptors.UpdateEventDescriptor 11 | org.xwiki.contrib.activitypub.internal.descriptors.LikeEventDescriptor -------------------------------------------------------------------------------- /activitypub-notifications/src/main/resources/templates/activitypub/activity.vm: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## See the NOTICE file distributed with this work for additional 3 | ## information regarding copyright ownership. 4 | ## 5 | ## This is free software; you can redistribute it and/or modify it 6 | ## under the terms of the GNU Lesser General Public License as 7 | ## published by the Free Software Foundation; either version 2.1 of 8 | ## the License, or (at your option) any later version. 9 | ## 10 | ## This software is distributed in the hope that it will be useful, 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | ## Lesser General Public License for more details. 14 | ## 15 | ## You should have received a copy of the GNU Lesser General Public 16 | ## License along with this software; if not, write to the Free 17 | ## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | ## --------------------------------------------------------------------------- 20 | ## Default activity renderer for any kind of activity notification. 21 | #template('activitypub/macros.vm') 22 | 23 | #define ($content) 24 |
25 |
$services.localization.render('activitypub.event.activity.type')
26 |
#getAPEventSummary('activitypub.event.activity.summary')
27 |
$compositeEventDate
28 |
29 | #end 30 | 31 | #define ($details) 32 | #define($rows) 33 | #foreach($event in $compositeEvent.events) 34 | #set ($activity = $eventActivities.get($event)) 35 | #set ($actor = $services.activitypub.resolve($activity.actor)) 36 | #set ($object = $services.activitypub.resolve($activity.object)) 37 | 38 | #define($description) 39 | $services.localization.render('activitypub.event.activity.description') $activity.type. 40 | #end 41 | #displayAPEventDetail($event $actor $description) 42 | #end 43 | #end 44 | #displayNotificationEventDetailsSkeletons($events.size(), $rows) 45 | #end 46 | 47 | #displayNotificationEventSkeleton($mainIcon $smallIcon $content $details) -------------------------------------------------------------------------------- /activitypub-notifications/src/main/resources/templates/activitypub/likeAction.vm: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## See the NOTICE file distributed with this work for additional 3 | ## information regarding copyright ownership. 4 | ## 5 | ## This is free software; you can redistribute it and/or modify it 6 | ## under the terms of the GNU Lesser General Public License as 7 | ## published by the Free Software Foundation; either version 2.1 of 8 | ## the License, or (at your option) any later version. 9 | ## 10 | ## This software is distributed in the hope that it will be useful, 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | ## Lesser General Public License for more details. 14 | ## 15 | ## You should have received a copy of the GNU Lesser General Public 16 | ## License along with this software; if not, write to the Free 17 | ## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | ## --------------------------------------------------------------------------- 20 | 21 | #if ("$!request.activityId" != "" && $services.csrf.isTokenValid($request.form_token)) 22 | #set ($likeResult = $services.activitypub.likeActivity($request.activityId)) 23 | #jsonResponse({"success": $likeResult}) 24 | #else 25 | #jsonResponse({"success": false, "message": "Wrong parameters"}) 26 | #end -------------------------------------------------------------------------------- /activitypub-notifications/src/main/resources/templates/activitypub/message.vm: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## See the NOTICE file distributed with this work for additional 3 | ## information regarding copyright ownership. 4 | ## 5 | ## This is free software; you can redistribute it and/or modify it 6 | ## under the terms of the GNU Lesser General Public License as 7 | ## published by the Free Software Foundation; either version 2.1 of 8 | ## the License, or (at your option) any later version. 9 | ## 10 | ## This software is distributed in the hope that it will be useful, 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | ## Lesser General Public License for more details. 14 | ## 15 | ## You should have received a copy of the GNU Lesser General Public 16 | ## License along with this software; if not, write to the Free 17 | ## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | ## --------------------------------------------------------------------------- 20 | #template('activitypub/macros.vm') 21 | 22 | #set ($smallIcon = 'comment') 23 | #define ($content) 24 |
25 |
$services.localization.render('activitypub.event.message.type')
26 |
#getAPEventSummary('activitypub.event.message.summary')
27 |
$compositeEventDate
28 |
29 | #end 30 | 31 | #define ($details) 32 | #define($rows) 33 | #foreach($event in $compositeEvent.events) 34 | #set ($activity = $eventActivities.get($event)) 35 | #set ($actor = $services.activitypub.resolve($activity.actor)) 36 | #set ($object = $services.activitypub.resolve($activity.object)) 37 | #define($actorLink) 38 | #activityPubActorLink($actor) 39 | #end 40 | #set ($introduction = $services.localization.render('activitypub.event.message.description.withActor', [$actorLink])) 41 | #displayAPEventDetailLarge($event $actor $introduction $object.content 'blockquote') 42 | #end 43 | #end 44 | #displayNotificationEventDetailsSkeletons($events.size(), $rows) 45 | #end 46 | 47 | #displayNotificationEventSkeleton($mainIcon $smallIcon $content $details) -------------------------------------------------------------------------------- /activitypub-notifications/src/test/java/org/xwiki/contrib/activitypub/events/AnnounceEventTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | import static org.junit.jupiter.api.Assertions.assertFalse; 26 | import static org.junit.jupiter.api.Assertions.assertTrue; 27 | 28 | /** 29 | * Test of {@link AnnounceEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | class AnnounceEventTest 35 | { 36 | private final AnnounceEvent event = new AnnounceEvent(null, null); 37 | 38 | @Test 39 | void getType() 40 | { 41 | assertEquals("activitypub.announce", this.event.getType()); 42 | } 43 | 44 | @Test 45 | void matchesTrue() 46 | { 47 | assertTrue(this.event.matches(new AnnounceEvent(null, null))); 48 | } 49 | 50 | @Test 51 | void matchesFalse() 52 | { 53 | assertFalse(this.event.matches(new CreateEvent(null, null))); 54 | } 55 | } -------------------------------------------------------------------------------- /activitypub-notifications/src/test/java/org/xwiki/contrib/activitypub/events/CreateEventTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | import static org.junit.jupiter.api.Assertions.assertFalse; 26 | import static org.junit.jupiter.api.Assertions.assertTrue; 27 | 28 | /** 29 | * Test of {@link CreateEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | class CreateEventTest 35 | { 36 | private final CreateEvent event = new CreateEvent(null, null); 37 | 38 | @Test 39 | void getType() 40 | { 41 | assertEquals("activitypub.create", this.event.getType()); 42 | } 43 | 44 | @Test 45 | void matchesTrue() 46 | { 47 | assertTrue(this.event.matches(new CreateEvent(null, null))); 48 | } 49 | 50 | @Test 51 | void matchesFalse() 52 | { 53 | assertFalse(this.event.matches(new AnnounceEvent(null, null))); 54 | } 55 | } -------------------------------------------------------------------------------- /activitypub-notifications/src/test/java/org/xwiki/contrib/activitypub/events/FollowEventTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | import static org.junit.jupiter.api.Assertions.assertFalse; 26 | import static org.junit.jupiter.api.Assertions.assertTrue; 27 | 28 | /** 29 | * Test of {@link FollowEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | class FollowEventTest 35 | { 36 | private final FollowEvent event = new FollowEvent(null, null); 37 | 38 | @Test 39 | void getType() 40 | { 41 | assertEquals("activitypub.follow", this.event.getType()); 42 | } 43 | 44 | @Test 45 | void matchesTrue() 46 | { 47 | assertTrue(this.event.matches(new FollowEvent(null, null))); 48 | } 49 | 50 | @Test 51 | void matchesFalse() 52 | { 53 | assertFalse(this.event.matches(new CreateEvent(null, null))); 54 | } 55 | } -------------------------------------------------------------------------------- /activitypub-notifications/src/test/java/org/xwiki/contrib/activitypub/events/UpdateEventTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.events; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | import static org.junit.jupiter.api.Assertions.assertFalse; 26 | import static org.junit.jupiter.api.Assertions.assertTrue; 27 | 28 | /** 29 | * Test of {@link UpdateEvent}. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | class UpdateEventTest 35 | { 36 | private final UpdateEvent event = new UpdateEvent(null, null); 37 | 38 | @Test 39 | void getType() 40 | { 41 | assertEquals("activitypub.update", this.event.getType()); 42 | } 43 | 44 | @Test 45 | void matchesTrue() 46 | { 47 | assertTrue(this.event.matches(new UpdateEvent(null, null))); 48 | } 49 | 50 | @Test 51 | void matchesFalse() 52 | { 53 | assertFalse(this.event.matches(new CreateEvent(null, null))); 54 | } 55 | } -------------------------------------------------------------------------------- /activitypub-server/src/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/ActivityHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import java.io.IOException; 23 | 24 | import org.xwiki.component.annotation.Role; 25 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 26 | import org.xwiki.stability.Unstable; 27 | 28 | /** 29 | * Handle an activity posted in an inbox or in an outbox, wrapped in an {@link ActivityRequest}. 30 | * @param the type of the activity. 31 | * @version $Id$ 32 | * @since 1.0 33 | */ 34 | @Unstable 35 | @Role 36 | public interface ActivityHandler 37 | { 38 | /** 39 | * Handle a post of the activity in the inbox. 40 | * @param activityRequest the request to handle. 41 | * @throws IOException in case of problem when handling the HTTP answer. 42 | * @throws ActivityPubException in case of error when handling the request. 43 | */ 44 | void handleInboxRequest(ActivityRequest activityRequest) throws IOException, ActivityPubException; 45 | 46 | /** 47 | * Handle a post of the activity in the outbox. 48 | * @param activityRequest the request to handle. 49 | * @throws IOException in case of problem when handling the HTTP answer. 50 | * @throws ActivityPubException in case of error when handling the request. 51 | */ 52 | void handleOutboxRequest(ActivityRequest activityRequest) throws IOException, ActivityPubException; 53 | } 54 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/CryptoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import org.xwiki.component.annotation.Role; 23 | import org.xwiki.crypto.pkix.params.CertifiedKeyPair; 24 | import org.xwiki.stability.Unstable; 25 | 26 | /** 27 | * Provides the service specific to cryptography. 28 | * 29 | * @version $Id$ 30 | * @since 1.1 31 | */ 32 | @Unstable 33 | @Role 34 | public interface CryptoService 35 | { 36 | /** 37 | * Generates an {@link CertifiedKeyPair}. 38 | * @return The request key pair. 39 | * @throws ActivityPubException In case of error during the key pair generation. 40 | */ 41 | CertifiedKeyPair generateCertifiedKeyPair() throws ActivityPubException; 42 | } 43 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/HTMLRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import org.xwiki.component.annotation.Role; 23 | import org.xwiki.model.reference.DocumentReference; 24 | import org.xwiki.rendering.block.XDOM; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * Provides operations to render pages content in HTML. 29 | * 30 | * @version $Id$ 31 | * @since 1.2 32 | */ 33 | @Unstable 34 | @Role 35 | public interface HTMLRenderer 36 | { 37 | /** 38 | * @param content The content to be rendered in xhtml/1.0. 39 | * @param documentReference The document reference of the rendered page. 40 | * @return the content rendered in xhtml/1.0. 41 | * @throws ActivityPubException In case of error during the rendering. 42 | */ 43 | String render(XDOM content, DocumentReference documentReference) throws ActivityPubException; 44 | } 45 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/SignatureService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub; 21 | 22 | import org.apache.commons.httpclient.HttpMethod; 23 | import org.xwiki.component.annotation.Role; 24 | import org.xwiki.contrib.activitypub.entities.AbstractActor; 25 | import org.xwiki.stability.Unstable; 26 | 27 | /** 28 | * Deal with the concerns related to the management, storage and use of asymetric keys. 29 | * 30 | * @version $Id$ 31 | * @since 1.1 32 | */ 33 | @Unstable 34 | @Role 35 | public interface SignatureService 36 | { 37 | /** 38 | * Generate the signature of a message send to an external ActivityPub inbox. 39 | * 40 | * @param postMethod the post method to sign 41 | * @param actor the actor who posts the message 42 | * @param content the content of the body of the request 43 | * @throws ActivityPubException in case of error when signing the request 44 | */ 45 | void generateSignature(HttpMethod postMethod, AbstractActor actor, String content) 46 | throws ActivityPubException; 47 | 48 | /** 49 | * Retrieve the public key of an actor. 50 | * 51 | * @param actor the actor from which to retrieve the public key. 52 | * @return The public key of the actor. 53 | * @throws ActivityPubException in case of error during the key generation. 54 | */ 55 | String getPublicKeyPEM(AbstractActor actor) throws ActivityPubException; 56 | } 57 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/internal/ActivityPubConfigurationSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal; 21 | 22 | import java.util.List; 23 | 24 | import javax.inject.Named; 25 | import javax.inject.Singleton; 26 | 27 | import org.xwiki.component.annotation.Component; 28 | import org.xwiki.configuration.internal.AbstractDocumentConfigurationSource; 29 | import org.xwiki.model.reference.DocumentReference; 30 | import org.xwiki.model.reference.LocalDocumentReference; 31 | 32 | import static java.util.Arrays.asList; 33 | 34 | /** 35 | * {@link org.xwiki.configuration.ConfigurationSource} reading the values from the ActivityPub configuration page. 36 | * 37 | * @version $Id$ 38 | * @since 1.1 39 | */ 40 | @Component 41 | @Named("activitypub") 42 | @Singleton 43 | public class ActivityPubConfigurationSource extends AbstractDocumentConfigurationSource 44 | { 45 | private static final List SPACE_NAMES = asList("ActivityPub"); 46 | 47 | private static final LocalDocumentReference CLASS_REFERENCE = 48 | new LocalDocumentReference(SPACE_NAMES, "ActivityPubConfigurationClass"); 49 | 50 | private static final LocalDocumentReference DOC_REFERENCE = 51 | new LocalDocumentReference(SPACE_NAMES, "Configuration"); 52 | 53 | @Override 54 | protected DocumentReference getDocumentReference() 55 | { 56 | return new DocumentReference(DOC_REFERENCE, this.getCurrentWikiReference()); 57 | } 58 | 59 | @Override 60 | protected LocalDocumentReference getClassReference() 61 | { 62 | return CLASS_REFERENCE; 63 | } 64 | 65 | @Override 66 | protected String getCacheId() 67 | { 68 | return "configuration.document.activitypub"; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/internal/ActivityPubMentionsFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal; 21 | 22 | import javax.inject.Named; 23 | import javax.inject.Singleton; 24 | 25 | import org.xwiki.component.annotation.Component; 26 | import org.xwiki.mentions.DisplayStyle; 27 | import org.xwiki.mentions.MentionsFormatter; 28 | 29 | /** 30 | * ActivityPub mentions formatter. 31 | * 32 | * @since 1.4 33 | * @version $Id$ 34 | */ 35 | @Component 36 | @Singleton 37 | @Named("activitypub") 38 | public class ActivityPubMentionsFormatter implements MentionsFormatter 39 | { 40 | @Override 41 | public String formatMention(String actorReference, DisplayStyle style) 42 | { 43 | if (actorReference == null) { 44 | return actorReference; 45 | } 46 | if (actorReference.startsWith("xwiki:")) { 47 | return actorReference.substring(6); 48 | } 49 | return actorReference; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/internal/async/PageChangedStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.async; 21 | 22 | import org.xwiki.contrib.activitypub.internal.async.jobs.PageCreatedNotificationJob; 23 | import org.xwiki.job.AbstractJobStatus; 24 | import org.xwiki.job.event.status.JobStatus; 25 | import org.xwiki.logging.LoggerManager; 26 | import org.xwiki.observation.ObservationManager; 27 | 28 | /** 29 | * {@link JobStatus} for {@link PageCreatedNotificationJob} asynchrous tasks. 30 | * 31 | * @version $Id$ 32 | * @since 1.2 33 | */ 34 | public class PageChangedStatus extends AbstractJobStatus 35 | { 36 | /** 37 | * Default constructor. 38 | * 39 | * @param jobType the type of the job 40 | * @param request the request provided when started the job 41 | * @param parentJobStatus the status of the parent job (i.e. the status of the job that started this one); pass 42 | * {@code null} if this job hasn't been started by another job (i.e. if this is not a sub-job). 43 | * @param observationManager the observation manager component 44 | * @param loggerManager the logger manager component 45 | */ 46 | public PageChangedStatus(String jobType, PageChangedRequest request, JobStatus parentJobStatus, 47 | ObservationManager observationManager, LoggerManager loggerManager) 48 | { 49 | super(jobType, request, parentJobStatus, observationManager, loggerManager); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/internal/filters/CollectionFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.filters; 21 | 22 | import org.xwiki.component.annotation.Role; 23 | import org.xwiki.contrib.activitypub.entities.AbstractCollection; 24 | import org.xwiki.contrib.activitypub.entities.ActivityPubObject; 25 | 26 | /** 27 | * A generic interface to filter any activitypub collection. 28 | * 29 | * @param the type of collection to filter. 30 | * @since 1.2 31 | * @version $Id$ 32 | */ 33 | @Role 34 | public interface CollectionFilter> 35 | { 36 | /** 37 | * Filter the given collection according to some strategy. 38 | * The returned element can be a new collection or the same one as the argument but modified. 39 | * 40 | * @param collection the collection to filter. 41 | * @return a filtered collection. 42 | */ 43 | T filter(T collection); 44 | } 45 | -------------------------------------------------------------------------------- /activitypub-server/src/main/java/org/xwiki/contrib/activitypub/internal/filters/PublicActivityFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.filters; 21 | 22 | import java.util.function.Predicate; 23 | 24 | import javax.inject.Singleton; 25 | 26 | import org.xwiki.component.annotation.Component; 27 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 28 | import org.xwiki.contrib.activitypub.entities.ProxyActor; 29 | 30 | /** 31 | * A generic predicate that checks if an {@link AbstractActivity} is public. 32 | * 33 | * @version $Id$ 34 | * @since 1.2 35 | */ 36 | @Component(roles = PublicActivityFilter.class) 37 | @Singleton 38 | public class PublicActivityFilter implements Predicate 39 | { 40 | @Override 41 | public boolean test(AbstractActivity activity) 42 | { 43 | return activity.getTo() != null && activity.getTo().contains(ProxyActor.getPublicActor()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /activitypub-server/src/test/java/org/xwiki/contrib/activitypub/internal/ActivityPubMentionsFormatterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.xwiki.test.junit5.mockito.ComponentTest; 24 | import org.xwiki.test.junit5.mockito.InjectMockComponents; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | import static org.junit.jupiter.api.Assertions.assertNull; 28 | 29 | /** 30 | * Test of {@link ActivityPubMentionsFormatter}. 31 | * 32 | * @version $Id$ 33 | * @since 1.4 34 | */ 35 | @ComponentTest 36 | class ActivityPubMentionsFormatterTest 37 | { 38 | @InjectMockComponents 39 | private ActivityPubMentionsFormatter activityPubMentionsFormatter; 40 | 41 | @Test 42 | void formatMentionNull() 43 | { 44 | assertNull(this.activityPubMentionsFormatter.formatMention(null, null)); 45 | } 46 | 47 | @Test 48 | void formatMentionWithPrefix() 49 | { 50 | assertEquals("user@server", this.activityPubMentionsFormatter.formatMention("xwiki:user@server", null)); 51 | } 52 | 53 | @Test 54 | void formatMention() 55 | { 56 | assertEquals("user@server", this.activityPubMentionsFormatter.formatMention("user@server", null)); 57 | } 58 | } -------------------------------------------------------------------------------- /activitypub-server/src/test/java/org/xwiki/contrib/activitypub/internal/filters/PublicActivityFilterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.internal.filters; 21 | 22 | import java.util.List; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.xwiki.contrib.activitypub.entities.AbstractActivity; 26 | import org.xwiki.contrib.activitypub.entities.ProxyActor; 27 | import org.xwiki.test.junit5.mockito.ComponentTest; 28 | import org.xwiki.test.junit5.mockito.InjectMockComponents; 29 | 30 | import static org.junit.jupiter.api.Assertions.assertFalse; 31 | import static org.junit.jupiter.api.Assertions.assertTrue; 32 | import static org.mockito.Mockito.mock; 33 | import static org.mockito.Mockito.when; 34 | 35 | /** 36 | * Tests for {@link PublicActivityFilter}. 37 | * 38 | * @version $Id$ 39 | * @since 1.2 40 | */ 41 | @ComponentTest 42 | public class PublicActivityFilterTest 43 | { 44 | @InjectMockComponents 45 | private PublicActivityFilter publicActivityFilter; 46 | 47 | @Test 48 | public void test() 49 | { 50 | AbstractActivity activity = mock(AbstractActivity.class); 51 | assertFalse(this.publicActivityFilter.test(activity)); 52 | 53 | List proxyActorList = mock(List.class); 54 | when(activity.getTo()).thenReturn(proxyActorList); 55 | assertFalse(this.publicActivityFilter.test(activity)); 56 | 57 | when(proxyActorList.contains(ProxyActor.getPublicActor())).thenReturn(true); 58 | assertTrue(this.publicActivityFilter.test(activity)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /activitypub-ui/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.xwiki.contrib 27 | application-activitypub 28 | 1.7.12-SNAPSHOT 29 | 30 | activitypub-ui 31 | 1.7.12-SNAPSHOT 32 | XWiki ActivityPub - UI 33 | A social application to allow XWiki to be part of the fediverse 34 | xar 35 | 36 | 37 | ActivityPub Application 38 | 39 | application 40 | 41 | 42 | 43 | org.xwiki.contrib 44 | activitypub-server 45 | ${project.version} 46 | runtime 47 | 48 | 49 | org.xwiki.contrib 50 | webfinger-server 51 | ${project.version} 52 | runtime 53 | 54 | 55 | org.xwiki.contrib 56 | discussions-macro 57 | 1.1 58 | xar 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /activitypub-ui/src/main/resources/ActivityPub/Discussion.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | ActivityPub 25 | Discussion 26 | 27 | 28 | 0 29 | xwiki:XWiki.Admin 30 | WebHome 31 | xwiki:XWiki.Admin 32 | xwiki:XWiki.Admin 33 | 1.1 34 | 35 | <comment/> 36 | <minorEdit>false</minorEdit> 37 | <syntaxId>xwiki/2.1</syntaxId> 38 | <hidden>true</hidden> 39 | <content>{{velocity}} 40 | [[$services.localization.render('activitypub.discussions.discussion.back')>>ActivityPub.Discussions||class="btn btn-primary" queryString="actor=$escapetool.url($request.actor)"]] 41 | 42 | {{discussion reference="$request.reference" namespace='APDiscussion' type='activitypub'/}} 43 | 44 | {{/velocity}} 45 | </content> 46 | </xwikidoc> 47 | -------------------------------------------------------------------------------- /activitypub-ui/src/main/resources/ActivityPub/Discussions.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.1" encoding="UTF-8"?> 2 | 3 | <!-- 4 | * See the NOTICE file distributed with this work for additional 5 | * information regarding copyright ownership. 6 | * 7 | * This is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation; either version 2.1 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this software; if not, write to the Free 19 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 21 | --> 22 | 23 | <xwikidoc version="1.4" reference="ActivityPub.Discussions" locale=""> 24 | <web>ActivityPub</web> 25 | <name>Discussions</name> 26 | <language/> 27 | <defaultLanguage/> 28 | <translation>0</translation> 29 | <creator>xwiki:XWiki.Admin</creator> 30 | <parent>Main.WebHome</parent> 31 | <author>xwiki:XWiki.Admin</author> 32 | <contentAuthor>xwiki:XWiki.Admin</contentAuthor> 33 | <version>1.1</version> 34 | <title>Discussions 35 | 36 | false 37 | xwiki/2.1 38 | true 39 | {{velocity}} 40 | [[$services.localization.render('activitypub.discussions.discussions.back')>>ActivityPub.WebHome||class="btn btn-primary"]] 41 | 42 | #if ("$!request.actor" != "") 43 | #set($currentActor = $services.activitypub.getActor($request.actor)) 44 | #else 45 | #set ($currentActor = $services.activitypub.getActor("")) 46 | #end 47 | #set ($canSeeDashboard = ("$!currentActor" != "" && $services.activitypub.currentUserCanActFor($currentActor))) 48 | 49 | #if ($canSeeDashboard) 50 | #set ($discussionDoc = $xwiki.getDocument('ActivityPub.Discussion')) 51 | #set ($url = "$discussionDoc.getURL('view')?reference=__REFERENCE__&actor=$escapetool.url($request.actor)") 52 | 53 | {{listDiscussions listId="discussionsAPDashboard" type="activitypub-actor" 54 | reference="$currentActor.id" linkTemplate="$url"}} 55 | 56 | #end 57 | {{/velocity}} 58 | 59 | -------------------------------------------------------------------------------- /activitypub-ui/src/main/resources/ActivityPub/FollowUser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | ActivityPub 25 | FollowUser 26 | 27 | 28 | 0 29 | xwiki:XWiki.Admin 30 | ActivityPub.WebHome 31 | xwiki:XWiki.Admin 32 | xwiki:XWiki.Admin 33 | 1.1 34 | FollowUser 35 | 36 | false 37 | xwiki/2.1 38 | true 39 | {{velocity}} 40 | #if ("$!request.followInput" != "" && $services.csrf.isTokenValid($request.form_token) && $request.outputSyntax == "plain") 41 | #set ($sourceActor = $services.activitypub.getActor($request.actorId)) 42 | #set ($actor = $services.activitypub.getActor($request.followInput)) 43 | #if ("$!actor" != '') 44 | #set ($followRes = $services.activitypub.follow($actor, $sourceActor)) 45 | #set($followWorked = $followRes.success) 46 | #set($followMessage = $services.localization.render($followRes.message)) 47 | #else 48 | #set ($followWorked = false) 49 | #set ($followMessage = $services.localization.render('activitypub.follow.actornotfound')) 50 | #end 51 | #setVariable("$json" { "success": $followWorked, "message": "$followMessage" }) 52 | #jsonResponse($json) 53 | #end 54 | {{/velocity}} 55 | This page contains the velocity code to process Follow requests. 56 | 57 | -------------------------------------------------------------------------------- /activitypub-ui/src/main/resources/ActivityPub/LikersView.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | ActivityPub 25 | LikersView 26 | 27 | 28 | 0 29 | xwiki:XWiki.Admin 30 | ActivityPub.WebHome 31 | xwiki:XWiki.Admin 32 | xwiki:XWiki.Admin 33 | Main.WebHome 34 | 1.1 35 | $escapetool.xml($services.localization.render('activitypub.like.likers.title')) 36 | 37 | false 38 | xwiki/2.1 39 | true 40 | {{include reference='ActivityPub.ListMessages'/}} 41 | 42 | {{velocity}} 43 | {{html wiki="true"}} 44 | #set ($likedDoc = $xwiki.getDocument($request.get('reference'))) 45 | #set ($apPage = $services.activitypub.resolveDocument($request.get('reference'))) 46 | #set ($likesRef = $apPage.likes) 47 | 48 | #if ("$!likesRef" == "") 49 | $services.localization.render('activitypub.like.likers.nolikes', [$likedDoc.plainTitle]) 50 | #else 51 | #set ($likes = $services.activitypub.resolve($likesRef)) 52 | #if ($likes.totalItems == 0) 53 | $services.localization.render('activitypub.like.likers.nolikes', [$likedDoc.plainTitle]) 54 | #else 55 | <p>$escapetool.xml($services.localization.render('activitypub.like.likers.subtitle', [$likes.totalItems, $likedDoc.plainTitle])) 56 | <ul> 57 | #foreach ($likeRef in $likes) 58 | #set ($like = $services.activitypub.resolve($likeRef)) 59 | #set ($actor = $services.activitypub.resolve($like.actor)) 60 | <li>#displayActor($actor)</li> 61 | #end 62 | </ul> 63 | </p> 64 | #end 65 | #end 66 | {{/html}} 67 | {{/velocity}} 68 | 69 | -------------------------------------------------------------------------------- /activitypub-ui/src/main/resources/ActivityPub/ListFollowing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | ActivityPub 25 | ListFollowing 26 | 27 | 28 | 0 29 | xwiki:XWiki.Admin 30 | Main.WebHome 31 | xwiki:XWiki.Admin 32 | xwiki:XWiki.Admin 33 | 1.1 34 | ListFollowing 35 | 36 | false 37 | xwiki/2.1 38 | true 39 | {{include reference="ActivityPub.UserDashboard"/}} 40 | 41 | {{velocity}} 42 | {{html clean="false" wiki="true"}} 43 | #if (!$isGuest) 44 | #set($actor = $services.activitypub.getActor($request.actorId)) 45 | #listFollowing($actor) 46 | #end{{/html}} 47 | {{/velocity}} 48 | 49 | -------------------------------------------------------------------------------- /activitypub-ui/src/main/resources/ActivityPub/MessageUser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | ActivityPub 25 | MessageUser 26 | 27 | 28 | 0 29 | xwiki:XWiki.Admin 30 | WebHome 31 | xwiki:XWiki.Admin 32 | xwiki:XWiki.Admin 33 | 1.1 34 | MessageUser 35 | 36 | false 37 | xwiki/2.1 38 | true 39 | {{velocity}} 40 | #if ("$!request.content" != "" && $services.csrf.isTokenValid($request.form_token) && $request.outputSyntax == "plain") 41 | #set ($sourceActor = $services.activitypub.getActor($request.actorId)) 42 | #set ($messageSent = $services.activitypub.publishNote.publishNote($request.getParameterValues('messageTarget'), $request.content, $sourceActor, $request.syntax)) 43 | #if ($messageSent) 44 | #set ($messageSent = true) 45 | #set ($messageSentMessage = $services.localization.render('activitypub.message.messageSent')) 46 | #else 47 | #set ($messageSent = false) 48 | #set ($messageSentMessage = $services.localization.render('activitypub.message.messageError')) 49 | #end 50 | #setVariable("$json" { "success": $messageSent, "message": "$messageSentMessage" }) 51 | #jsonResponse($json) 52 | #else 53 | This page contains the velocity code to handle messaging. 54 | #end 55 | {{/velocity}} 56 | 57 | -------------------------------------------------------------------------------- /webfinger-parent/README.md: -------------------------------------------------------------------------------- 1 | # Webfinger 2 | 3 | ## Integration 4 | 5 | According to [webfinger's RFC](https://tools.ietf.org/html/rfc7033#section-4): 6 | 7 | > The path component of a WebFinger URI MUST be the well-known path "/.well-known/webfinger". 8 | > A WebFinger URI MUST contain a query component that encodes the query target and optional link relation types as 9 | > specified in [Section 4.1](https://tools.ietf.org/html/rfc7033#section-4.1). 10 | 11 | Internally, the URL provided by XWiki is in the form `/xwiki/webfinger`. 12 | Consequently, an http server is required to redirect queries from `/.well/know/webfinger` to `/xwiki/webfinger`. 13 | 14 | ### nginx 15 | 16 | The integration of XWiki behind an nginx http server is documented 17 | [here](https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/NginX/). 18 | 19 | In order to support webfinger, the following rule must be integrated in the configuration, before the `location /` 20 | block. 21 | 22 | Three specific parts needs to be adapted: 23 | - XWIKI_DOMAIN must be replaced with the domain name of ip address of the XWiki instance. 24 | - XWIKI_PORT must be replaced with the listening port of the XWiki instance (the default value is `8080`). 25 | - XWIKI_ROOT must be replaced with the root path to the xwiki instance (the default value is `xwiki`). 26 | See [this documentation](https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/ShortURLs/) to customize the root path to an XWiki instance. 27 | 28 | ```nginx 29 | location ~ ^/.well-known/webfinger { 30 | proxy_pass $scheme://{XWIKI_DOMAIN}:{XWIKI_PORT}/{XWIKI_ROOT}webfinger$is_args$args; 31 | proxy_set_header X-Real-IP $remote_addr; 32 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 33 | proxy_set_header Host $host; 34 | proxy_set_header X-Forwarded-Proto $scheme; 35 | 36 | expires 0m; 37 | } 38 | 39 | ``` -------------------------------------------------------------------------------- /webfinger-parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.xwiki.contrib 27 | application-activitypub 28 | 1.7.12-SNAPSHOT 29 | 30 | webfinger-parent 31 | 1.7.12-SNAPSHOT 32 | XWiki Webfinger - Parent 33 | pom 34 | 35 | webfinger-server 36 | webfinger-core 37 | 38 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 4.0.0 25 | 26 | org.xwiki.contrib 27 | webfinger-parent 28 | 1.7.12-SNAPSHOT 29 | 30 | webfinger-core 31 | 1.7.12-SNAPSHOT 32 | XWiki Webfinger - Core 33 | jar 34 | 35 | 0.68 36 | 37 | 38 | 39 | org.xwiki.platform 40 | xwiki-platform-resource-api 41 | ${platform.version} 42 | 43 | 44 | com.fasterxml.jackson.core 45 | jackson-annotations 46 | ${jackson.version} 47 | 48 | 49 | com.fasterxml.jackson.core 50 | jackson-databind 51 | ${jackson.version} 52 | 53 | 54 | commons-httpclient 55 | commons-httpclient 56 | 57 | 58 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/java/org/xwiki/contrib/activitypub/webfinger/WebfingerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger; 21 | 22 | /** 23 | * Default exception for webfinger. 24 | * 25 | * @since 1.1 26 | * @version $Id$ 27 | */ 28 | public class WebfingerException extends Exception 29 | { 30 | private final int errorCode; 31 | 32 | /** 33 | * Handling of a business error. 34 | * @param message the detailed message of the exception. 35 | * @param errorCode http error code to be returned to the client. 36 | */ 37 | public WebfingerException(String message, int errorCode) 38 | { 39 | super(message); 40 | this.errorCode = errorCode; 41 | } 42 | 43 | /** 44 | * Handling of a technical error. 45 | * @param message The detailed message of the exception. 46 | * @param cause The cause of the error 47 | */ 48 | public WebfingerException(String message, Throwable cause) 49 | { 50 | super(message, cause); 51 | this.errorCode = 500; 52 | } 53 | 54 | /** 55 | * Handling of a technical error. 56 | * @param cause The cause of the error 57 | */ 58 | public WebfingerException(Throwable cause) 59 | { 60 | super(cause); 61 | this.errorCode = 500; 62 | } 63 | 64 | /** 65 | * Handling of a technical error. 66 | * @param message The detailed message of the exception. 67 | */ 68 | public WebfingerException(String message) 69 | { 70 | super(message); 71 | this.errorCode = 500; 72 | } 73 | 74 | /** 75 | * 76 | * @return the error code. 77 | */ 78 | public int getErrorCode() 79 | { 80 | return this.errorCode; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/java/org/xwiki/contrib/activitypub/webfinger/WebfingerJsonParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger; 21 | 22 | import java.io.InputStream; 23 | import java.io.Reader; 24 | 25 | import org.xwiki.component.annotation.Role; 26 | import org.xwiki.contrib.activitypub.webfinger.entities.JSONResourceDescriptor; 27 | import org.xwiki.stability.Unstable; 28 | 29 | /** 30 | * Define parsing operations for Webfinger. 31 | * 32 | * @since 1.1 33 | * @version $Id$ 34 | */ 35 | @Unstable 36 | @Role 37 | public interface WebfingerJsonParser 38 | { 39 | /** 40 | * Parse the given string into a {@link JSONResourceDescriptor}. 41 | * @param json The json representation of a {@link JSONResourceDescriptor}. 42 | * @return The parsed {@link JSONResourceDescriptor}. 43 | * @throws WebfingerException in case of error during the parsing.w 44 | */ 45 | JSONResourceDescriptor parse(String json) throws WebfingerException; 46 | 47 | /** 48 | * Parse the given reader into a {@link JSONResourceDescriptor}. 49 | * @param reader The reader of the json representation of a {@link JSONResourceDescriptor}. 50 | * @return The parsed {@link JSONResourceDescriptor}. 51 | * @throws WebfingerException in case of error during the parsing.w 52 | */ 53 | JSONResourceDescriptor parse(Reader reader) throws WebfingerException; 54 | 55 | /** 56 | * Parse the given stream into a {@link JSONResourceDescriptor}. 57 | * @param stream The stream of a json representation of a {@link JSONResourceDescriptor}. 58 | * @return The parsed {@link JSONResourceDescriptor}. 59 | * @throws WebfingerException in case of error during the parsing. 60 | */ 61 | JSONResourceDescriptor parse(InputStream stream) throws WebfingerException; 62 | } 63 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/java/org/xwiki/contrib/activitypub/webfinger/WebfingerJsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger; 21 | 22 | import java.io.IOException; 23 | import java.io.OutputStream; 24 | 25 | import org.xwiki.component.annotation.Role; 26 | import org.xwiki.contrib.activitypub.webfinger.entities.JSONResourceDescriptor; 27 | import org.xwiki.stability.Unstable; 28 | 29 | /** 30 | * Define serializing operations for Webfinger. 31 | * 32 | * @since 1.1 33 | * @version $Id$ 34 | */ 35 | @Unstable 36 | @Role 37 | public interface WebfingerJsonSerializer 38 | { 39 | /** 40 | * Serialize a {@link JSONResourceDescriptor} to a {@link String}. 41 | * @param object the {@link JSONResourceDescriptor} to serialize. 42 | * @return a string representing the serialization of the object to json. 43 | * @throws IOException in case of issue occurring during the serialization. 44 | */ 45 | String serialize(JSONResourceDescriptor object) throws IOException; 46 | 47 | /** 48 | * Serialize a {@link JSONResourceDescriptor} to a {@link String}. 49 | * @param stream the stream where to output the serialized object. 50 | * @param object the {@link JSONResourceDescriptor} to serialize. 51 | * @throws IOException in case of issue occurring during the serialization. 52 | */ 53 | void serialize(OutputStream stream, JSONResourceDescriptor object) throws IOException; 54 | } 55 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/java/org/xwiki/contrib/activitypub/webfinger/WebfingerResourceReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger; 21 | 22 | import org.xwiki.resource.AbstractResourceReference; 23 | import org.xwiki.resource.ResourceType; 24 | import org.xwiki.stability.Unstable; 25 | 26 | /** 27 | * The resource handled for webfinger requests.. 28 | * 29 | * @since 1.1 30 | * @version $Id$ 31 | */ 32 | @Unstable 33 | public class WebfingerResourceReference extends AbstractResourceReference 34 | { 35 | /** 36 | * Represents a Webfinger Resource Type. 37 | */ 38 | public static final ResourceType TYPE = new ResourceType("webfinger"); 39 | 40 | /** 41 | * Default constructor. 42 | */ 43 | public WebfingerResourceReference() 44 | { 45 | this.setType(TYPE); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/java/org/xwiki/contrib/activitypub/webfinger/internal/json/DefaultWebfingerJsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger.internal.json; 21 | 22 | import java.io.ByteArrayOutputStream; 23 | import java.io.IOException; 24 | import java.io.OutputStream; 25 | import java.nio.charset.StandardCharsets; 26 | 27 | import javax.inject.Inject; 28 | import javax.inject.Singleton; 29 | 30 | import org.xwiki.component.annotation.Component; 31 | import org.xwiki.contrib.activitypub.webfinger.WebfingerJsonSerializer; 32 | import org.xwiki.contrib.activitypub.webfinger.entities.JSONResourceDescriptor; 33 | 34 | /** 35 | * Defines the default serialization of {@link JSONResourceDescriptor} to json. 36 | * 37 | * @version $Id$ 38 | * @since 1.1 39 | */ 40 | @Component 41 | @Singleton 42 | public class DefaultWebfingerJsonSerializer implements WebfingerJsonSerializer 43 | { 44 | @Inject 45 | private ObjectMapperConfiguration objectMapperConfiguration; 46 | 47 | @Override 48 | public String serialize(JSONResourceDescriptor object) throws IOException 49 | { 50 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 51 | this.serialize(byteArrayOutputStream, object); 52 | return new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8); 53 | } 54 | 55 | @Override 56 | public void serialize(OutputStream stream, JSONResourceDescriptor object) throws IOException 57 | { 58 | this.objectMapperConfiguration.getObjectMapper().writeValue(stream, object); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/java/org/xwiki/contrib/activitypub/webfinger/internal/json/ObjectMapperConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger.internal.json; 21 | 22 | import javax.inject.Singleton; 23 | 24 | import org.xwiki.component.annotation.Component; 25 | import org.xwiki.component.phase.Initializable; 26 | 27 | import com.fasterxml.jackson.databind.ObjectMapper; 28 | 29 | import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; 30 | import static com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY; 31 | import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; 32 | import static com.fasterxml.jackson.databind.MapperFeature.SORT_PROPERTIES_ALPHABETICALLY; 33 | import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT; 34 | 35 | /** 36 | * Provides a default json object mapper configuration. 37 | * 38 | * @version $Id$ 39 | * @since 1.1 40 | */ 41 | @Component(roles = ObjectMapperConfiguration.class) 42 | @Singleton 43 | public class ObjectMapperConfiguration implements Initializable 44 | { 45 | private ObjectMapper objectMapper; 46 | 47 | @Override 48 | public void initialize() 49 | { 50 | this.objectMapper = new ObjectMapper() 51 | .setSerializationInclusion(NON_EMPTY) 52 | .enable(ACCEPT_SINGLE_VALUE_AS_ARRAY) 53 | .enable(SORT_PROPERTIES_ALPHABETICALLY) 54 | .enable(INDENT_OUTPUT) 55 | .disable(FAIL_ON_UNKNOWN_PROPERTIES); 56 | } 57 | 58 | /** 59 | * 60 | * @return the default object mapper. 61 | */ 62 | public ObjectMapper getObjectMapper() 63 | { 64 | return this.objectMapper; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/main/resources/META-INF/components.txt: -------------------------------------------------------------------------------- 1 | org.xwiki.contrib.activitypub.webfinger.internal.json.DefaultWebfingerJsonSerializer 2 | org.xwiki.contrib.activitypub.webfinger.internal.json.ObjectMapperConfiguration 3 | org.xwiki.contrib.activitypub.webfinger.internal.json.DefaultWebfingerJsonParser -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/test/resources/webfinger.json: -------------------------------------------------------------------------------- 1 | { 2 | "aliases" : [ "http://link1.txt", "http://link2.txt" ], 3 | "links" : [ { 4 | "href" : "http://link1.txt", 5 | "rel" : "http://link1rel.tst", 6 | "type" : "self" 7 | }, { 8 | "href" : "http://link2.txt", 9 | "rel" : "http://link2rel.tst", 10 | "type" : "self" 11 | } ], 12 | "subject" : "acct:test@xwiki.tst" 13 | } -------------------------------------------------------------------------------- /webfinger-parent/webfinger-core/src/test/resources/webfinger_unknown_field.json: -------------------------------------------------------------------------------- 1 | { 2 | "aliases" : [ "http://link1.txt", "http://link2.txt" ], 3 | "links" : [ { 4 | "href" : "http://link1.txt", 5 | "rel" : "http://link1rel.tst", 6 | "type" : "self" 7 | }, { 8 | "href" : "http://link2.txt", 9 | "rel" : "http://link2rel.tst", 10 | "type" : "self", 11 | "template": {} 12 | } ], 13 | "subject" : "acct:test@xwiki.tst" 14 | } -------------------------------------------------------------------------------- /webfinger-parent/webfinger-server/src/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-server/src/main/java/org/xwiki/contrib/activitypub/webfinger/WebfingerClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger; 21 | 22 | import org.xwiki.component.annotation.Role; 23 | import org.xwiki.contrib.activitypub.webfinger.entities.JSONResourceDescriptor; 24 | import org.xwiki.stability.Unstable; 25 | 26 | /** 27 | * Webfinger query operations. 28 | * 29 | * @since 1.1 30 | * @version $Id$ 31 | */ 32 | @Role 33 | @Unstable 34 | public interface WebfingerClient 35 | { 36 | /** 37 | * Query a webfinger endpoint with a given resource. 38 | * @param webfingerResource The webfinger resource. 39 | * @return The JSON Resource Descript of the webfinger resource. 40 | * @throws WebfingerException In case of error during the query. 41 | */ 42 | JSONResourceDescriptor get(String webfingerResource) throws WebfingerException; 43 | 44 | /** 45 | * Test if the given domain do have a working WebFinger implementation. 46 | * Note that this method should only be used to test an XWiki WebFinger implementation. 47 | * 48 | * @param domain the domain on which WebFinger is supposed to be working. 49 | * @return {@code true} if WebFinger sent the right answer. 50 | * @throws WebfingerException in case of error when performing the check. 51 | */ 52 | boolean testWebFingerConfiguration(String domain) throws WebfingerException; 53 | } 54 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-server/src/main/java/org/xwiki/contrib/activitypub/webfinger/WebfingerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger; 21 | 22 | import java.net.URI; 23 | 24 | import org.xwiki.component.annotation.Role; 25 | import org.xwiki.contrib.activitypub.entities.AbstractActor; 26 | import org.xwiki.stability.Unstable; 27 | 28 | /** 29 | * 30 | * Defines the business operations for {@link org.xwiki.contrib.activitypub.webfinger.internal.WebfingerResourceReferenceHandler}. 31 | * @since 1.1 32 | * @version $Id$ 33 | */ 34 | @Role 35 | @Unstable 36 | public interface WebfingerService 37 | { 38 | /** 39 | * Resolve a username to an actual ActivityPub Actor. 40 | * The following formats are supported for username resolutioon: 41 | * - {@code identifier}: the user named identifier will be looked in the current wiki 42 | * - {@code identifier.otherwiki}: the user named identifier will be looked in the subwiki named otherwiki. 43 | * - {@code identifier.xwiki}: the sub wiki named identifier will be looked. 44 | * - {@code xwiki.xwiki}: it returns always the current wiki actor. 45 | * @param username The username of the actor to find. 46 | * @return the resolve {@link AbstractActor} corresponding of the username. 47 | * @throws WebfingerException in case of serialization error 48 | */ 49 | AbstractActor resolveActivityPubUser(String username) throws WebfingerException; 50 | 51 | /** 52 | * Resolve the activitypub resource of the user. 53 | * @param actor the actor URL to obtain. 54 | * @return the url of the activitypub resource of the user 55 | */ 56 | URI resolveXWikiUserUrl(AbstractActor actor) throws WebfingerException; 57 | } 58 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-server/src/main/java/org/xwiki/contrib/activitypub/webfinger/internal/WebfingerResourceReferenceResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger.internal; 21 | 22 | import java.util.Map; 23 | 24 | import javax.inject.Named; 25 | import javax.inject.Singleton; 26 | 27 | import org.xwiki.component.annotation.Component; 28 | import org.xwiki.contrib.activitypub.webfinger.WebfingerResourceReference; 29 | import org.xwiki.resource.ResourceType; 30 | import org.xwiki.url.ExtendedURL; 31 | import org.xwiki.url.internal.AbstractResourceReferenceResolver; 32 | 33 | /** 34 | * Resolve an {@link ExtendedURL} to an {@link WebfingerResourceReference}. 35 | * 36 | * @since 1.1 37 | * @version $Id$ 38 | */ 39 | @Component 40 | @Named("webfinger") 41 | @Singleton 42 | public class WebfingerResourceReferenceResolver extends AbstractResourceReferenceResolver 43 | { 44 | @Override 45 | public WebfingerResourceReference resolve(ExtendedURL representation, ResourceType resourceType, 46 | Map parameters) 47 | { 48 | WebfingerResourceReference ret = new WebfingerResourceReference(); 49 | this.copyParameters(representation, ret); 50 | return ret; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /webfinger-parent/webfinger-server/src/main/resources/META-INF/components.txt: -------------------------------------------------------------------------------- 1 | org.xwiki.contrib.activitypub.webfinger.internal.WebfingerResourceReferenceHandler 2 | org.xwiki.contrib.activitypub.webfinger.internal.WebfingerResourceReferenceResolver 3 | org.xwiki.contrib.activitypub.webfinger.internal.DefaultWebfingerService 4 | org.xwiki.contrib.activitypub.webfinger.internal.DefaultWebfingerClient 5 | org.xwiki.contrib.activitypub.webfinger.script.WebfingerScriptService -------------------------------------------------------------------------------- /webfinger-parent/webfinger-server/src/test/java/org/xwiki/contrib/activitypub/webfinger/internal/WebfingerResourceReferenceResolverTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * See the NOTICE file distributed with this work for additional 3 | * information regarding copyright ownership. 4 | * 5 | * This is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this software; if not, write to the Free 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 19 | */ 20 | package org.xwiki.contrib.activitypub.webfinger.internal; 21 | 22 | import java.util.HashMap; 23 | import java.util.List; 24 | 25 | import org.junit.jupiter.api.Test; 26 | import org.xwiki.contrib.activitypub.webfinger.WebfingerResourceReference; 27 | import org.xwiki.resource.ResourceType; 28 | import org.xwiki.test.junit5.mockito.ComponentTest; 29 | import org.xwiki.test.junit5.mockito.InjectMockComponents; 30 | import org.xwiki.url.ExtendedURL; 31 | 32 | import static org.junit.jupiter.api.Assertions.assertEquals; 33 | import static org.mockito.Mockito.mock; 34 | import static org.mockito.Mockito.verifyNoInteractions; 35 | import static org.mockito.Mockito.when; 36 | 37 | /** 38 | * 39 | * Test of {@link WebfingerResourceReferenceResolver}. 40 | * 41 | * @since 1.1 42 | * @version $Id$ 43 | */ 44 | @ComponentTest 45 | class WebfingerResourceReferenceResolverTest 46 | { 47 | @InjectMockComponents 48 | private WebfingerResourceReferenceResolver resolver; 49 | 50 | @Test 51 | void resolve() throws Exception 52 | { 53 | ExtendedURL representation = mock(ExtendedURL.class); 54 | ResourceType resourceType = mock(ResourceType.class); 55 | HashMap parameters = mock(HashMap.class); 56 | WebfingerResourceReference actual = this.resolver.resolve(representation, resourceType, parameters); 57 | assertEquals(new HashMap>(), actual.getParameters()); 58 | verifyNoInteractions(parameters); 59 | verifyNoInteractions(resourceType); 60 | when(representation.getParameters()).thenReturn(new HashMap<>()); 61 | } 62 | } --------------------------------------------------------------------------------