├── .gitignore ├── .travis.yml ├── Dockerfile ├── EOL.md ├── LICENSE ├── README.md ├── build.gradle ├── docs ├── README.md ├── _config.yml ├── architecture.md ├── build.md ├── concepts.md ├── configure.md ├── faq.md ├── features │ ├── authentication.md │ ├── bridge-integration.md │ ├── directory.md │ ├── experimental │ │ ├── application-service.md │ │ └── profile.md │ ├── federation.md │ ├── identity.md │ ├── profile.md │ └── registration.md ├── getting-started.md ├── install │ ├── archlinux.md │ ├── debian.md │ ├── docker.md │ ├── nixos.md │ ├── security.md │ └── source.md ├── operations.md ├── stores │ ├── README.md │ ├── exec.md │ ├── firebase.md │ ├── ldap.md │ ├── rest.md │ ├── sql.md │ ├── synapse.md │ └── wordpress.md ├── threepids │ ├── medium │ │ ├── email │ │ │ └── smtp-connector.md │ │ └── msisdn │ │ │ └── twilio-connector.md │ ├── notification │ │ ├── basic-handler.md │ │ ├── sendgrid-handler.md │ │ └── template-generator.md │ └── session │ │ ├── session-views.md │ │ └── session.md └── troubleshooting.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── media ├── mx-id-icon-reverse.png └── mx-id-icon.png ├── mxisd.example.yaml └── src ├── debian ├── control ├── postinst └── prerm ├── docker └── start.sh ├── main ├── java │ ├── edazdarevic │ │ └── commons │ │ │ └── net │ │ │ └── CIDRUtils.java │ └── io │ │ └── kamax │ │ └── mxisd │ │ ├── HttpMxisd.java │ │ ├── Mxisd.java │ │ ├── MxisdStandaloneExec.java │ │ ├── UserID.java │ │ ├── UserIdType.java │ │ ├── as │ │ ├── AppSvcManager.java │ │ ├── processor │ │ │ ├── command │ │ │ │ ├── CommandProcessor.java │ │ │ │ ├── InviteCommandProcessor.java │ │ │ │ ├── LookupCommandProcessor.java │ │ │ │ └── PingCommandProcessor.java │ │ │ └── event │ │ │ │ ├── EventTypeProcessor.java │ │ │ │ ├── MembershipEventProcessor.java │ │ │ │ └── MessageEventProcessor.java │ │ └── registration │ │ │ └── SynapseRegistrationYaml.java │ │ ├── auth │ │ ├── AuthManager.java │ │ ├── AuthProviders.java │ │ ├── UserAuthResult.java │ │ └── provider │ │ │ ├── AuthenticatorProvider.java │ │ │ └── BackendAuthResult.java │ │ ├── backend │ │ ├── IdentityStoreSupplier.java │ │ ├── exec │ │ │ ├── ExecAuthResult.java │ │ │ ├── ExecAuthStore.java │ │ │ ├── ExecDirectoryStore.java │ │ │ ├── ExecIdentityStore.java │ │ │ ├── ExecIdentityStoreSupplier.java │ │ │ ├── ExecProfileStore.java │ │ │ └── ExecStore.java │ │ ├── firebase │ │ │ ├── GoogleFirebaseAuthenticator.java │ │ │ ├── GoogleFirebaseBackend.java │ │ │ ├── GoogleFirebaseProvider.java │ │ │ └── GoogleFirebaseStoreSupplier.java │ │ ├── ldap │ │ │ ├── LdapAuthProvider.java │ │ │ ├── LdapBackend.java │ │ │ ├── LdapDirectoryProvider.java │ │ │ ├── LdapProfileProvider.java │ │ │ ├── LdapStoreSupplier.java │ │ │ ├── LdapThreePidProvider.java │ │ │ └── netiq │ │ │ │ ├── NetIqLdapAuthProvider.java │ │ │ │ ├── NetIqLdapDirectoryProvider.java │ │ │ │ ├── NetIqLdapProfileProvider.java │ │ │ │ ├── NetIqLdapStoreSupplier.java │ │ │ │ └── NetIqLdapThreePidProvider.java │ │ ├── memory │ │ │ ├── MemoryIdentityStore.java │ │ │ └── MemoryIdentityStoreSupplier.java │ │ ├── rest │ │ │ ├── LookupBulkResponseJson.java │ │ │ ├── LookupSingleRequestJson.java │ │ │ ├── LookupSingleResponseJson.java │ │ │ ├── RestAuthProvider.java │ │ │ ├── RestAuthRequestJson.java │ │ │ ├── RestDirectoryProvider.java │ │ │ ├── RestProfileProvider.java │ │ │ ├── RestProvider.java │ │ │ ├── RestStoreSupplier.java │ │ │ └── RestThreePidProvider.java │ │ ├── sql │ │ │ ├── BuiltInDriverLoader.java │ │ │ ├── DriverLoader.java │ │ │ ├── Drivers.java │ │ │ ├── SqlConnectionPool.java │ │ │ ├── SqlProfileProvider.java │ │ │ ├── SqlThreePidProvider.java │ │ │ ├── generic │ │ │ │ ├── GenericSqlAuthProvider.java │ │ │ │ ├── GenericSqlDirectoryProvider.java │ │ │ │ ├── GenericSqlProfileProvider.java │ │ │ │ ├── GenericSqlStoreSupplier.java │ │ │ │ └── GenericSqlThreePidProvider.java │ │ │ └── synapse │ │ │ │ ├── Synapse.java │ │ │ │ ├── SynapseQueries.java │ │ │ │ ├── SynapseSqlDirectoryProvider.java │ │ │ │ ├── SynapseSqlProfileProvider.java │ │ │ │ ├── SynapseSqlStoreSupplier.java │ │ │ │ └── SynapseSqlThreePidProvider.java │ │ └── wordpress │ │ │ ├── WordpressAuthData.java │ │ │ ├── WordpressAuthProvider.java │ │ │ ├── WordpressDirectoryProvider.java │ │ │ ├── WordpressRestBackend.java │ │ │ ├── WordpressStoreSupplier.java │ │ │ ├── WordpressThreePidProvider.java │ │ │ └── WordressSqlBackend.java │ │ ├── config │ │ ├── AppServiceConfig.java │ │ ├── AuthenticationConfig.java │ │ ├── BulkLookupConfig.java │ │ ├── DirectoryConfig.java │ │ ├── DnsOverwriteConfig.java │ │ ├── ExecConfig.java │ │ ├── FirebaseConfig.java │ │ ├── ForwardConfig.java │ │ ├── InvitationConfig.java │ │ ├── KeyConfig.java │ │ ├── MatrixConfig.java │ │ ├── MxisdConfig.java │ │ ├── RecursiveLookupBridgeConfig.java │ │ ├── RecursiveLookupConfig.java │ │ ├── RegisterConfig.java │ │ ├── SQLiteStorageConfig.java │ │ ├── ServerConfig.java │ │ ├── SessionConfig.java │ │ ├── StorageConfig.java │ │ ├── ViewConfig.java │ │ ├── YamlConfigLoader.java │ │ ├── ldap │ │ │ ├── LdapConfig.java │ │ │ ├── generic │ │ │ │ └── GenericLdapConfig.java │ │ │ └── netiq │ │ │ │ └── NetIqLdapConfig.java │ │ ├── memory │ │ │ ├── MemoryIdentityConfig.java │ │ │ ├── MemoryStoreConfig.java │ │ │ └── MemoryThreePid.java │ │ ├── rest │ │ │ └── RestBackendConfig.java │ │ ├── sql │ │ │ ├── SqlConfig.java │ │ │ ├── generic │ │ │ │ └── GenericSqlProviderConfig.java │ │ │ └── synapse │ │ │ │ └── SynapseSqlProviderConfig.java │ │ ├── threepid │ │ │ ├── ThreePidConfig.java │ │ │ ├── connector │ │ │ │ ├── EmailSendGridConfig.java │ │ │ │ ├── EmailSmtpConfig.java │ │ │ │ └── PhoneTwilioConfig.java │ │ │ ├── medium │ │ │ │ ├── EmailConfig.java │ │ │ │ ├── EmailTemplateConfig.java │ │ │ │ ├── GenericTemplateConfig.java │ │ │ │ ├── MediumConfig.java │ │ │ │ ├── PhoneConfig.java │ │ │ │ └── PhoneSmsTemplateConfig.java │ │ │ └── notification │ │ │ │ └── NotificationConfig.java │ │ └── wordpress │ │ │ └── WordpressConfig.java │ │ ├── crypto │ │ ├── CryptoFactory.java │ │ ├── GenericKey.java │ │ ├── GenericKeyIdentifier.java │ │ ├── Key.java │ │ ├── KeyAlgorithm.java │ │ ├── KeyIdentifier.java │ │ ├── KeyManager.java │ │ ├── KeyType.java │ │ ├── RegularKeyIdentifier.java │ │ ├── Signature.java │ │ ├── SignatureManager.java │ │ └── ed25519 │ │ │ ├── Ed25519Key.java │ │ │ ├── Ed25519KeyManager.java │ │ │ ├── Ed25519RegularKeyIdentifier.java │ │ │ └── Ed25519SignatureManager.java │ │ ├── directory │ │ ├── DirectoryManager.java │ │ ├── DirectoryProvider.java │ │ └── DirectoryProviders.java │ │ ├── dns │ │ ├── ClientDnsOverwrite.java │ │ └── FederationDnsOverwrite.java │ │ ├── exception │ │ ├── AccessTokenNotFoundException.java │ │ ├── BadRequestException.java │ │ ├── ConfigurationException.java │ │ ├── FeatureNotAvailable.java │ │ ├── HttpMatrixException.java │ │ ├── InternalServerError.java │ │ ├── InvalidCredentialsException.java │ │ ├── InvalidResponseJsonException.java │ │ ├── JsonMemberNotFoundException.java │ │ ├── MappingAlreadyExistsException.java │ │ ├── MessageForClientException.java │ │ ├── MxisdException.java │ │ ├── NotAllowedException.java │ │ ├── NotFoundException.java │ │ ├── NotImplementedException.java │ │ ├── ObjectNotFoundException.java │ │ ├── RemoteHomeServerException.java │ │ ├── RemoteIdentityServerException.java │ │ ├── RemoteLoginException.java │ │ ├── SessionNotValidatedException.java │ │ └── SessionUnknownException.java │ │ ├── http │ │ ├── IsAPIv1.java │ │ ├── io │ │ │ ├── CredentialsValidationResponse.java │ │ │ ├── UserDirectorySearchRequest.java │ │ │ ├── UserDirectorySearchResult.java │ │ │ └── identity │ │ │ │ ├── BindRequest.java │ │ │ │ ├── ClientBulkLookupAnswer.java │ │ │ │ ├── ClientBulkLookupRequest.java │ │ │ │ ├── GenericTokenRequestJson.java │ │ │ │ ├── KeyValidityJson.java │ │ │ │ ├── RequestTokenResponse.java │ │ │ │ ├── SessionEmailTokenRequestJson.java │ │ │ │ ├── SessionPhoneTokenRequestJson.java │ │ │ │ ├── SingeLookupReplyJson.java │ │ │ │ ├── StoreInviteRequest.java │ │ │ │ ├── SuccessStatusJson.java │ │ │ │ └── ThreePidInviteReplyIO.java │ │ └── undertow │ │ │ └── handler │ │ │ ├── BasicHttpHandler.java │ │ │ ├── HomeserverProxyHandler.java │ │ │ ├── InternalInfoHandler.java │ │ │ ├── OptionsHandler.java │ │ │ ├── SaneHandler.java │ │ │ ├── as │ │ │ └── v1 │ │ │ │ ├── ApplicationServiceHandler.java │ │ │ │ ├── AsNotFoundHandler.java │ │ │ │ ├── AsTransactionHandler.java │ │ │ │ └── AsUserHandler.java │ │ │ ├── auth │ │ │ ├── RestAuthHandler.java │ │ │ └── v1 │ │ │ │ ├── LoginGetHandler.java │ │ │ │ ├── LoginHandler.java │ │ │ │ └── LoginPostHandler.java │ │ │ ├── directory │ │ │ └── v1 │ │ │ │ └── UserDirectorySearchHandler.java │ │ │ ├── identity │ │ │ └── v1 │ │ │ │ ├── BulkLookupHandler.java │ │ │ │ ├── EphemeralKeyIsValidHandler.java │ │ │ │ ├── HelloHandler.java │ │ │ │ ├── KeyGetHandler.java │ │ │ │ ├── KeyIsValidHandler.java │ │ │ │ ├── LookupHandler.java │ │ │ │ ├── RegularKeyIsValidHandler.java │ │ │ │ ├── SessionStartHandler.java │ │ │ │ ├── SessionTpidBindHandler.java │ │ │ │ ├── SessionTpidGetValidatedHandler.java │ │ │ │ ├── SessionTpidUnbindHandler.java │ │ │ │ ├── SessionValidateHandler.java │ │ │ │ ├── SessionValidationGetHandler.java │ │ │ │ ├── SessionValidationPostHandler.java │ │ │ │ ├── SignEd25519Handler.java │ │ │ │ ├── SingleLookupHandler.java │ │ │ │ └── StoreInviteHandler.java │ │ │ ├── invite │ │ │ └── v1 │ │ │ │ └── RoomInviteHandler.java │ │ │ ├── profile │ │ │ └── v1 │ │ │ │ ├── InternalProfileHandler.java │ │ │ │ └── ProfileHandler.java │ │ │ ├── register │ │ │ └── v1 │ │ │ │ └── Register3pidRequestTokenHandler.java │ │ │ └── status │ │ │ ├── StatusHandler.java │ │ │ └── VersionHandler.java │ │ ├── invitation │ │ ├── IMatrixIdInvite.java │ │ ├── IThreePidInvite.java │ │ ├── IThreePidInviteReply.java │ │ ├── InvitationManager.java │ │ ├── MatrixIdInvite.java │ │ ├── ThreePidInvite.java │ │ └── ThreePidInviteReply.java │ │ ├── lookup │ │ ├── ALookupRequest.java │ │ ├── BulkLookupRequest.java │ │ ├── SingleLookupReply.java │ │ ├── SingleLookupRequest.java │ │ ├── ThreePidMapping.java │ │ ├── ThreePidProviders.java │ │ ├── ThreePidValidation.java │ │ ├── fetcher │ │ │ ├── IBridgeFetcher.java │ │ │ └── IRemoteIdentityServerFetcher.java │ │ ├── provider │ │ │ ├── BridgeFetcher.java │ │ │ ├── DnsLookupProvider.java │ │ │ ├── ForwarderProvider.java │ │ │ ├── IThreePidProvider.java │ │ │ ├── RemoteIdentityServerFetcher.java │ │ │ └── RemoteLookupProviderSupplier.java │ │ └── strategy │ │ │ ├── LookupStrategy.java │ │ │ └── RecursivePriorityLookupStrategy.java │ │ ├── matrix │ │ ├── HomeserverFederationResolver.java │ │ └── IdentityServerUtils.java │ │ ├── notification │ │ ├── NotificationHandler.java │ │ ├── NotificationHandlerSupplier.java │ │ ├── NotificationHandlers.java │ │ └── NotificationManager.java │ │ ├── profile │ │ ├── JsonProfileRequest.java │ │ ├── JsonProfileResult.java │ │ ├── ProfileManager.java │ │ ├── ProfileProvider.java │ │ └── ProfileProviders.java │ │ ├── proxy │ │ └── Response.java │ │ ├── registration │ │ ├── RegistrationManager.java │ │ └── RegistrationReply.java │ │ ├── session │ │ ├── SessionManager.java │ │ └── ValidationResult.java │ │ ├── storage │ │ ├── IStorage.java │ │ ├── crypto │ │ │ ├── FileKeyJson.java │ │ │ ├── FileKeyStore.java │ │ │ ├── KeyStore.java │ │ │ └── MemoryKeyStore.java │ │ ├── dao │ │ │ └── IThreePidSessionDao.java │ │ └── ormlite │ │ │ ├── OrmLiteSqlStorage.java │ │ │ └── dao │ │ │ ├── ASTransactionDao.java │ │ │ ├── HistoricalThreePidInviteIO.java │ │ │ ├── ThreePidInviteIO.java │ │ │ └── ThreePidSessionDao.java │ │ ├── threepid │ │ ├── connector │ │ │ ├── ThreePidConnector.java │ │ │ ├── email │ │ │ │ ├── BlackholeEmailConnector.java │ │ │ │ ├── BuiltInEmailConnectorSupplier.java │ │ │ │ ├── EmailConnector.java │ │ │ │ ├── EmailConnectorSupplier.java │ │ │ │ └── EmailSmtpConnector.java │ │ │ └── phone │ │ │ │ ├── BlackholePhoneConnector.java │ │ │ │ ├── BuiltInPhoneConnectorSupplier.java │ │ │ │ ├── PhoneConnector.java │ │ │ │ ├── PhoneConnectorSupplier.java │ │ │ │ └── PhoneSmsTwilioConnector.java │ │ ├── generator │ │ │ ├── GenericTemplateNotificationGenerator.java │ │ │ ├── NotificationGenerator.java │ │ │ ├── PlaceholderNotificationGenerator.java │ │ │ ├── email │ │ │ │ ├── BuiltInEmailGeneratorSupplier.java │ │ │ │ ├── EmailGenerator.java │ │ │ │ ├── EmailGeneratorSupplier.java │ │ │ │ └── GenericEmailNotificationGenerator.java │ │ │ └── phone │ │ │ │ ├── BuiltInPhoneGeneratorSupplier.java │ │ │ │ ├── PhoneGenerator.java │ │ │ │ ├── PhoneGeneratorSupplier.java │ │ │ │ └── SmsNotificationGenerator.java │ │ ├── notification │ │ │ ├── BuiltInNotificationHandlerSupplier.java │ │ │ ├── GenericNotificationHandler.java │ │ │ ├── email │ │ │ │ ├── EmailRawNotificationHandler.java │ │ │ │ └── EmailSendGridNotificationHandler.java │ │ │ └── phone │ │ │ │ └── PhoneNotificationHandler.java │ │ └── session │ │ │ ├── IThreePidSession.java │ │ │ └── ThreePidSession.java │ │ └── util │ │ ├── FileUtil.java │ │ ├── GsonParser.java │ │ ├── GsonUtil.java │ │ ├── JsonUtils.java │ │ ├── OptionalUtil.java │ │ ├── RestClientUtils.java │ │ └── TriFunction.java └── resources │ ├── META-INF │ └── services │ │ ├── io.kamax.mxisd.backend.IdentityStoreSupplier │ │ ├── io.kamax.mxisd.backend.sql.DriverLoader │ │ ├── io.kamax.mxisd.notification.NotificationHandlerSupplier │ │ ├── io.kamax.mxisd.threepid.connector.email.EmailConnectorSupplier │ │ ├── io.kamax.mxisd.threepid.connector.phone.PhoneConnectorSupplier │ │ ├── io.kamax.mxisd.threepid.generator.email.EmailGeneratorSupplier │ │ └── io.kamax.mxisd.threepid.generator.phone.PhoneGeneratorSupplier │ ├── simplelogger.properties │ ├── templates │ └── session │ │ ├── tokenSubmitFailure.html │ │ └── tokenSubmitSuccess.html │ └── threepids │ ├── email │ ├── invite-template.eml │ ├── mxid-template.eml │ ├── unbind-fraudulent.eml │ └── validate-template.eml │ └── sms │ ├── invite-template.txt │ ├── unbind-fraudulent.txt │ └── validate-template.txt ├── script └── mxisd ├── systemd └── mxisd.service └── test ├── java └── io │ └── kamax │ └── mxisd │ └── test │ ├── MxisdDefaultTest.java │ ├── MxisdTest.java │ ├── auth │ └── AuthManagerTest.java │ ├── backend │ ├── exec │ │ ├── ExecAuthStoreTest.java │ │ ├── ExecDirectoryStoreTest.java │ │ ├── ExecIdentityStoreTest.java │ │ ├── ExecProfileStoreTest.java │ │ ├── ExecStoreTest.java │ │ └── auth │ │ │ └── input │ │ │ ├── ExecAuthArgsTest.java │ │ │ ├── ExecAuthEnvTest.java │ │ │ └── ExecAuthInputMultilinesTest.java │ ├── ldap │ │ └── LdapAuthTest.java │ └── rest │ │ ├── RestDirectoryProviderTest.java │ │ ├── RestProfileProviderTest.java │ │ └── RestThreePidProviderTest.java │ ├── crypto │ ├── KeyTest.java │ └── SignatureManagerTest.java │ ├── matrix │ └── HomeserverFederationResolverTest.java │ ├── notification │ └── EmailNotificationTest.java │ ├── storage │ ├── OrmLiteSqlStorageTest.java │ └── crypto │ │ ├── FileKeyStoreTest.java │ │ ├── KeyStoreTest.java │ │ └── MemoryKeyStoreTest.java │ └── util │ └── RestClientUtilsTest.java └── resources └── store └── exec └── input ├── argsTest.sh ├── envTest.sh └── multilinesTest.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Build directories 2 | .gradle/ 3 | build/ 4 | out/ 5 | 6 | # IDEs directories 7 | .idea/ 8 | 9 | # Local dev config 10 | /mxisd.yaml 11 | /application.yaml 12 | 13 | # Local dev storage 14 | /mxisd.db 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | before_cache: 3 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 4 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 5 | cache: 6 | directories: 7 | - $HOME/.gradle/caches/ 8 | - $HOME/.gradle/wrapper/ 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre-alpine 2 | 3 | RUN apk update && apk add bash && rm -rf /var/lib/apk/* /var/cache/apk/* 4 | 5 | VOLUME /etc/mxisd 6 | VOLUME /var/mxisd 7 | EXPOSE 8090 8 | 9 | ENV JAVA_OPTS="" 10 | ENV CONF_FILE_PATH="/etc/mxisd/mxisd.yaml" 11 | ENV SIGN_KEY_PATH="/var/mxisd/sign.key" 12 | ENV SQLITE_DATABASE_PATH="/var/mxisd/mxisd.db" 13 | 14 | CMD [ "/start.sh" ] 15 | 16 | ADD src/docker/start.sh /start.sh 17 | ADD src/script/mxisd /app/mxisd 18 | ADD build/libs/mxisd.jar /app/mxisd.jar 19 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | - [Identity Concepts in Matrix](concepts.md) 3 | - [Getting Started](getting-started.md) 4 | - [Build from sources](build.md) (Optional) 5 | - Installation 6 | - [Debian package](install/debian.md) 7 | - [ArchLinux](install/archlinux.md) 8 | - [NixOS](install/nixos.md) 9 | - [Docker](install/docker.md) 10 | - [From source](install/source.md) 11 | - [Architecture overview](architecture.md) 12 | - [Configuration](configure.md) 13 | - Features 14 | - [Authentication](features/authentication.md) 15 | - [Directory search](features/directory.md) 16 | - [Identity](features/identity.md) 17 | - [Federation](features/federation.md) 18 | - [Bridge integration](features/bridge-integration.md) 19 | - [Identity Stores](stores/README.md) 20 | - Notifications 21 | - Handlers 22 | - [Basic](threepids/notification/basic-handler.md) 23 | - [SendGrid](threepids/notification/sendgrid-handler.md) 24 | - [Sessions](threepids/session/session.md) 25 | - [Views](threepids/session/session-views.md) 26 | - [FAQ](faq.md) 27 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker -------------------------------------------------------------------------------- /docs/architecture.md: -------------------------------------------------------------------------------- 1 | # Architecture 2 | ## Overview 3 | ### Basic setup with default settings 4 | ``` 5 | Client 6 | | 7 | TCP 443 8 | | +---------------------+ +---------------------------+ 9 | +-> | Reverse proxy | | Homeserver | 10 | | | TCP 8008 | | 11 | | /_matrix/* -------------------> | - 3PID invite from client | 12 | | | | | | 13 | | /_matrix/identity/ | | | | 14 | +--|------------------+ +---|-----------------------+ 15 | | | 16 | +<---------------------------------<+ 17 | | 18 | | +-------------------+ 19 | TCP 8090 +-> | mxisd | 20 | | | 21 | | - Profile's 3PIDs | 22 | | - 3PID Invites | 23 | +-|-----------------+ 24 | | 25 | TCP 443 26 | | +------------------------+ 27 | | | Remote Federated | 28 | | | mxisd servers | 29 | | | | 30 | +--> - 3PID Invites | 31 | +------------------------+ 32 | ``` 33 | ### With Authentication 34 | See the [dedicated document](features/authentication.md). 35 | 36 | ### With Directory 37 | See the [dedicated document](features/directory.md). 38 | 39 | ### With Federation 40 | See the [dedicated document](features/federation.md). 41 | -------------------------------------------------------------------------------- /docs/concepts.md: -------------------------------------------------------------------------------- 1 | # Concepts 2 | - [Matrix](#matrix) 3 | - [mxisd](#mxisd) 4 | 5 | ## Matrix 6 | The following concepts are part of the Matrix ecosystem and specification. 7 | 8 | ### 3PID 9 | `3PID` stands for Third-Party Identifier. 10 | It is also commonly written: 11 | - `3pid` 12 | - `tpid` 13 | 14 | A 3PID is a globally unique canonical identifier which is made of: 15 | - Medium, which describes what network it belongs to (Email, Phone, Twitter, Discord, etc.) 16 | - Address, the actual value people typically use on a daily basis. 17 | 18 | mxisd core mission is to map those identifiers to Matrix User IDs. 19 | 20 | ### Homeserver 21 | Where a user **account and data** are stored. 22 | 23 | ### Identity server 24 | An Identity server: 25 | - Does lookup of 3PIDs to User Matrix IDs. 26 | - Does validate 3PIDs ownership, typically by sending a code that the user has to enter in an application/on a website. 27 | - Does send notifications about room invites where no Matrix User ID could be found for the invitee. 28 | 29 | An Identity server: 30 | - **DOES NOT** store user accounts. 31 | - **DOES NOT** store user data. 32 | - **DOES NOT** allow migration of user account and/or data between homeservers. 33 | 34 | ### 3PID session 35 | The fact to validate a 3PID (email, phone number, etc.) via the introduction of a token which was sent to the 3PID address. 36 | 37 | ## mxisd 38 | The following concepts are specific to mxisd. 39 | 40 | ### Identity store 41 | Where your user accounts and 3PID mappings are stored. 42 | 43 | mxisd itself **DOES NOT STORE** user accounts or 3PID mappings. 44 | -------------------------------------------------------------------------------- /docs/features/bridge-integration.md: -------------------------------------------------------------------------------- 1 | # Bridge Integration 2 | To help natural bridge integration into the regular usage of a Matrix client, mxisd provides a way for bridge to reply 3 | to 3PID queries if no mapping was found, allowing seamless bridging to a network. 4 | 5 | This is performed by implementing a specific endpoint on the bridge to map a 3PID lookup to a virtual user. 6 | 7 | **NOTE**: This document is incomplete and might be misleading. In doubt, come in our Matrix room. 8 | You can also look at our [Email Bridge README](https://github.com/kamax-matrix/matrix-appservice-email#mxisd) for an example 9 | of working configuration. 10 | 11 | ## Configuration 12 | ```yaml 13 | lookup: 14 | recursive: 15 | bridge: 16 | enabled: 17 | recursiveOnly: 18 | server: 19 | mappings: 20 | <3PID MEDIUM HERE>: 21 | 22 | ``` 23 | 24 | ## Integration 25 | Implement a simplified version of the [Identity service single lookup endpoint](https://kamax.io/matrix/api/identity_service/unstable.html#get-matrix-identity-api-v1-lookup) 26 | with only the following parameters needed: 27 | - `address` 28 | - `medium` 29 | - `mxid` 30 | 31 | Or an empty object if no resolution exists or desired. 32 | -------------------------------------------------------------------------------- /docs/features/experimental/profile.md: -------------------------------------------------------------------------------- 1 | # Profile 2 | **WARNING**: The following sub-features are considered experimental and not officially supported. Use at your own peril. 3 | 4 | ## Public Profile enhancement 5 | This feature allows to enhance a public profile query with more info than just Matrix ID and Display name, allowing for 6 | custom applications to retrieve custom data not currently provided by synapse, per example. 7 | 8 | **WARNING**: This information can be queried without authentication as per the specification. Do not enable unless in a 9 | controlled environment. 10 | 11 | ### Configuration 12 | #### Reverse proxy 13 | ##### Apache 14 | ```apache 15 | ProxyPassMatch "^/_matrix/client/r0/profile/([^/]+)$" "http://127.0.0.1:8090/_matrix/client/r0/profile/$1" 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/features/profile.md: -------------------------------------------------------------------------------- 1 | # Profile 2 | The profile feature does not do anything on its own and acts as a support feature for others, allowing to retrieve 3 | information about a user based on its Matrix ID by querying enabled [Identity stores](../stores/README.md). 4 | 5 | Currently supported: 6 | - Display name 7 | - 3PIDs 8 | - Roles/Groups 9 | 10 | Experimental sub-features are also available. See [the dedicated document](experimental/profile.md). 11 | -------------------------------------------------------------------------------- /docs/install/archlinux.md: -------------------------------------------------------------------------------- 1 | # Arch Linux package 2 | An Arch Linux package in the AUR repos is maintained by [r3pek](https://matrix.to/#/@r3pek:r3pek.org), a community member. 3 | See https://aur.archlinux.org/packages/mxisd/ 4 | -------------------------------------------------------------------------------- /docs/install/debian.md: -------------------------------------------------------------------------------- 1 | # Debian package 2 | ## Requirements 3 | - Any distribution that supports Java 8 4 | 5 | ## Install 6 | 1. Download the [latest release](https://github.com/kamax-matrix/mxisd/releases/latest) 7 | 2. Run: 8 | ```bash 9 | dpkg -i /path/to/downloaded/mxisd.deb 10 | ``` 11 | ## Files 12 | | Location | Purpose | 13 | |-------------------------------------|----------------------------------------------| 14 | | `/etc/mxisd` | Configuration directory | 15 | | `/etc/mxisd/mxisd.yaml` | Main configuration file | 16 | | `/etc/systemd/system/mxisd.service` | Systemd configuration file for mxisd service | 17 | | `/usr/lib/mxisd` | Binaries | 18 | | `/var/lib/mxisd` | Data | 19 | | `/var/lib/mxisd/signing.key` | Default location for mxisd signing keys | 20 | 21 | ## Control 22 | Start mxisd using: 23 | ```bash 24 | sudo systemctl start mxisd 25 | ``` 26 | 27 | Stop mxisd using: 28 | ```bash 29 | sudo systemctl stop mxisd 30 | ``` 31 | 32 | ## Troubleshoot 33 | All logs are sent to `STDOUT` which are saved in `/var/log/syslog` by default. 34 | You can: 35 | - grep & tail using `mxisd`: 36 | ``` 37 | tail -n 99 -f /var/log/syslog | grep mxisd 38 | ``` 39 | - use Systemd's journal: 40 | ``` 41 | journalctl -f -n 99 -u mxisd 42 | ``` 43 | -------------------------------------------------------------------------------- /docs/install/docker.md: -------------------------------------------------------------------------------- 1 | # Docker 2 | ## Fetch 3 | Pull the latest stable image: 4 | ```bash 5 | docker pull kamax/mxisd 6 | ``` 7 | 8 | ## Configure 9 | On first run, simply using `MATRIX_DOMAIN` as an environment variable will create a default config for you. 10 | You can also provide a configuration file named `mxisd.yaml` in the volume mapped to `/etc/mxisd` before starting your 11 | container. 12 | 13 | ## Run 14 | Use the following command after adapting to your needs: 15 | - The `MATRIX_DOMAIN` environment variable to yours 16 | - The volumes host paths 17 | 18 | ```bash 19 | docker run --rm -e MATRIX_DOMAIN=example.org -v /data/mxisd/etc:/etc/mxisd -v /data/mxisd/var:/var/mxisd -p 8090:8090 -t kamax/mxisd 20 | ``` 21 | 22 | For more info, including the list of possible tags, see [the public repository](https://hub.docker.com/r/kamax/mxisd/) 23 | 24 | ## Troubleshoot 25 | Please read the [Troubleshooting guide](../troubleshooting.md). -------------------------------------------------------------------------------- /docs/install/nixos.md: -------------------------------------------------------------------------------- 1 | # NixOS package 2 | mxisd is available as a NixOS package in the official repos. 3 | 4 | It is maintained by [maximilian](https://matrix.to/#/@maximilian:transformierende-gesellschaft.org), a community member. 5 | 6 | Related resources: 7 | - [NixOS](https://nixos.org/) 8 | - [The module definition](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/mxisd.nix) 9 | -------------------------------------------------------------------------------- /docs/install/security.md: -------------------------------------------------------------------------------- 1 | # Security hardening 2 | ## Overview 3 | This document outlines the various operations you may want to perform to increase the security of your installation and 4 | avoid leak of credentials/key pairs 5 | 6 | ## Configuration 7 | Your config file should have the following ownership: 8 | - Dedicated user for mxisd, used to run the software 9 | - Dedicated group for mxisd, used by other applications to access and read configuration files 10 | 11 | Your config file should have the following access: 12 | - Read and write for the mxisd user 13 | - Read for the mxisd group 14 | - Nothing for others 15 | 16 | This translates into `640` and be applied with `chmod 640 /path/to/config/file.yaml`. 17 | 18 | ## Data 19 | The only sensible place is the key store where mxisd's signing keys are stored. You should therefore limit access to only 20 | the mxisd user, and deny access to anything else. 21 | 22 | Your key store should have the following access: 23 | - Read and write for the mxisd user 24 | - Nothing for the mxisd group 25 | - Nothing for others 26 | 27 | The identity store can either be a file or a directory, depending on your version. v1.4 and higher are using a directory, 28 | everything before is using a file. 29 | - If your version is directory-based, you will want to apply chmod `700` on it. 30 | - If your version is file-based, you will want to apply chmod `600` on it. 31 | -------------------------------------------------------------------------------- /docs/install/source.md: -------------------------------------------------------------------------------- 1 | # Install from sources 2 | ## Instructions 3 | Follow the [build instructions](../build.md) then: 4 | 5 | ### Prepare files and directories: 6 | ```bash 7 | # Create a dedicated user 8 | useradd -r mxisd 9 | 10 | # Create config directory 11 | mkdir -p /etc/mxisd 12 | 13 | # Create data directory and set ownership 14 | mkdir -p /var/lib/mxisd 15 | chown -R mxisd /var/lib/mxisd 16 | 17 | # Create bin directory, copy the jar and launch scriot to bin directory 18 | mkdir /usr/lib/mxisd 19 | cp ./build/libs/mxisd.jar /usr/lib/mxisd/ 20 | cp ./src/script/mxisd /usr/lib/mxisd 21 | chown -R mxisd /usr/lib/mxisd 22 | chmod a+x /usr/lib/mxisd/mxisd 23 | 24 | # Create symlink for easy exec 25 | ln -s /usr/lib/mxisd/mxisd /usr/bin/mxisd 26 | ``` 27 | 28 | ### Prepare config file 29 | Copy the configuration file you've created following the build instructions to `/etc/mxisd/mxisd.yaml` 30 | 31 | ### Prepare Systemd 32 | 1. Copy `src/systemd/mxisd.service` to `/etc/systemd/system/` and edit if needed 33 | 2. Enable service for auto-startup 34 | ```bash 35 | systemctl enable mxisd 36 | ``` 37 | 38 | ### Run 39 | ```bash 40 | systemctl start mxisd 41 | ``` 42 | 43 | ## Debug 44 | mxisd logs to stdout, which is normally sent to `/var/log/syslog` or `/var/log/messages`. 45 | -------------------------------------------------------------------------------- /docs/operations.md: -------------------------------------------------------------------------------- 1 | # Operations Guide 2 | - [Overview](#overview) 3 | - [Maintenance](#maintenance) 4 | - [Backup](#backup) 5 | 6 | ## Overview 7 | This document gives various information for the day-to-day management and operations of mxisd. 8 | 9 | ## Maintenance 10 | mxisd does not require any maintenance task to run at optimal performance. 11 | 12 | ## Backup 13 | ### Run 14 | mxisd requires all file in its configuration and data directory to be backed up. 15 | They are usually located at: 16 | - `/etc/mxisd` 17 | - `/var/lib/mxisd` 18 | 19 | ### Restore 20 | Reinstall mxisd, restore the two folders above in the appropriate location (depending on your install method) and you 21 | will be good to go. Simply start mxisd to restore functionality. 22 | -------------------------------------------------------------------------------- /docs/stores/README.md: -------------------------------------------------------------------------------- 1 | # Identity Stores 2 | - [Synapse](synapse.md) - Turn your SynapseDB into a self-contained Identity store 3 | - [LDAP-based](ldap.md) - Any LDAP-based product like Active Directory, Samba, NetIQ, OpenLDAP 4 | - [SQL Databases](sql.md) - Most common databases like MariaDB, MySQL, PostgreSQL, SQLite 5 | - [Website / Web service / Web app](rest.md) - Arbitrary REST endpoints 6 | - [Executables](exec.md) - Run arbitrary executables with configurable stdin, arguments, environment and stdout 7 | - [Wordpress](wordpress.md) - Connect your Wordpress-powered website DB 8 | - [Google Firebase](firebase.md) - Use your Firebase users (with experimental SSO support!) 9 | -------------------------------------------------------------------------------- /docs/stores/firebase.md: -------------------------------------------------------------------------------- 1 | # Google Firebase Identity store 2 | https://firebase.google.com/ 3 | 4 | ## Features 5 | | Name | Supported | 6 | |-------------------------------------------------|-----------| 7 | | [Authentication](../features/authentication.md) | Yes | 8 | | [Directory](../features/directory.md) | No | 9 | | [Identity](../features/identity.md) | Yes | 10 | | [Profile](../features/profile.md) | No | 11 | 12 | ## Requirements 13 | This backend requires a suitable Matrix client capable of performing Firebase authentication and passing the following 14 | information: 15 | - Firebase User ID as Matrix username 16 | - Firebase token as Matrix password 17 | 18 | If your client is Riot, you will need a custom version. 19 | 20 | ## Configuration 21 | ```yaml 22 | firebase: 23 | enabled: 24 | ``` 25 | Enable/disable this identity store. 26 | 27 | Example: 28 | ```yaml 29 | firebase: 30 | enabled: 31 | ``` 32 | 33 | --- 34 | 35 | ```yaml 36 | firebase: 37 | credentials: 38 | ``` 39 | Path to the credentials file provided by Google Firebase to use with an external app. 40 | 41 | Example: 42 | ```yaml 43 | firebase: 44 | credentials: '/path/to/firebase/credentials.json' 45 | ``` 46 | 47 | --- 48 | 49 | ```yaml 50 | firebase: 51 | database: 52 | ``` 53 | URL to your Firebase database. 54 | 55 | Example: 56 | ```yaml 57 | firebase: 58 | database: 'https://my-project.firebaseio.com/' 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/stores/synapse.md: -------------------------------------------------------------------------------- 1 | # Synapse Identity Store 2 | Synapse's Database itself can be used as an Identity store. This identity store is a regular SQL store with 3 | built-in default queries that matches Synapse DB. 4 | 5 | ## Features 6 | | Name | Supported | 7 | |-------------------------------------------------|-----------| 8 | | [Authentication](../features/authentication.md) | No | 9 | | [Directory](../features/directory.md) | Yes | 10 | | [Identity](../features/identity.md) | Yes | 11 | | [Profile](../features/profile.md) | Yes | 12 | 13 | - Authentication is done by Synapse itself. 14 | - Roles are mapped to communities. The Role name/ID uses the community ID in the form `+id:domain.tld` 15 | 16 | ## Configuration 17 | ### Basic 18 | ```yaml 19 | synapseSql: 20 | enabled: 21 | ``` 22 | Enable/disable the identity store 23 | 24 | --- 25 | 26 | ```yaml 27 | synapseSql: 28 | type: 29 | ``` 30 | Set the SQL backend to use which is configured in synapse: 31 | - `sqlite` 32 | - `postgresql` 33 | 34 | ### SQLite 35 | ```yaml 36 | synapseSql: 37 | connection: 38 | ``` 39 | Set the value to the absolute path to the Synapse SQLite DB file. 40 | Example: `/path/to/synapse/sqliteFile.db` 41 | 42 | ### PostgreSQL 43 | ```yaml 44 | synapseSql: 45 | connection: // **WARNING:** This section is incomplete and may be misleading. Contact us if guidance is needed. 3 | 4 | Enable with: 5 | ```yaml 6 | notification: 7 | handler: 8 | email: 'sendgrid' 9 | ``` 10 | 11 | Available Configuration keys: 12 | ```yaml 13 | notification: 14 | handlers: 15 | sendgrid: 16 | api: 17 | key: 18 | identity: 19 | from: 20 | name: 21 | templates: 22 | invite: 23 | subject: 24 | body: 25 | text: 26 | html: 27 | session: 28 | validation: 29 | subject: 30 | body: 31 | text: 32 | html: 33 | unbind: 34 | fraudulent: 35 | subject: 36 | body: 37 | text: 38 | html: 39 | ``` 40 | -------------------------------------------------------------------------------- /docs/threepids/session/session-views.md: -------------------------------------------------------------------------------- 1 | # Web pages for the 3PID sessions 2 | You can customize the various pages used during a 3PID validation using the options below. 3 | 4 | ## Configuration 5 | Pseudo-configuration to illustrate the structure: 6 | ```yaml 7 | # CONFIGURATION EXAMPLE 8 | # DO NOT COPY/PASTE THIS IN YOUR CONFIGURATION 9 | view: 10 | session: 11 | onTokenSubmit: 12 | success: '/path/to/session/tokenSubmitSuccess-page.html' 13 | failure: '/path/to/session/tokenSubmitFailure-page.html' 14 | # CONFIGURATION EXAMPLE 15 | # DO NOT COPY/PASTE THIS IN YOUR CONFIGURATION 16 | ``` 17 | 18 | `view.session`: 19 | This is triggered when a user submit a validation token for a 3PID session. It is typically visited when clicking the 20 | link in a validation email. 21 | 22 | The template should typically inform the user that the validation was successful and to go back in their Matrix client 23 | to finish the validation process, or that the validation failed. 24 | 25 | Two configuration keys are available that accept paths to HTML templates: 26 | - `success` 27 | - `failure` 28 | 29 | ### Serving static assets 30 | mxisd will not serve any static asset (images, JS, CSS, etc.). If such are needed, you will need to serve them using the 31 | reverse proxy sitting in front of mxisd using a path outside of the `/_matrix/identity/` namespace. We advise using 32 | the base path `/static/` for such use cases, allowing to remain under the same hostname/origin. 33 | 34 | You can also serve such assets using absolute URL, possibly under other domains, but be aware of Cross-Origin restrictions 35 | in browsers which are out of scope of mxisd. 36 | 37 | ## Placeholders 38 | ### Success 39 | No object/placeholder are currently available. 40 | 41 | ### Failure 42 | No object/placeholder are currently available. 43 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamax-matrix/mxisd/c4fdcc7fb013f3013b84b8f16cff5a0213dda354/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /media/mx-id-icon-reverse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamax-matrix/mxisd/c4fdcc7fb013f3013b84b8f16cff5a0213dda354/media/mx-id-icon-reverse.png -------------------------------------------------------------------------------- /media/mx-id-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kamax-matrix/mxisd/c4fdcc7fb013f3013b84b8f16cff5a0213dda354/media/mx-id-icon.png -------------------------------------------------------------------------------- /src/debian/control: -------------------------------------------------------------------------------- 1 | Package: mxisd 2 | Maintainer: Kamax.io 3 | Homepage: https://github.com/kamax-matrix/mxisd 4 | Description: Federated Matrix Identity Server 5 | Architecture: all 6 | Section: net 7 | Priority: optional 8 | Depends: openjdk-8-jre | openjdk-8-jre-headless | openjdk-8-jdk | openjdk-8-jdk-headless 9 | Version: 0 10 | -------------------------------------------------------------------------------- /src/debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Add service account 4 | useradd -r mxisd || true 5 | 6 | # Set permissions for data directory 7 | chown -R mxisd:mxisd %DEB_DATA_DIR% 8 | 9 | # Create symlink to mxisd run script 10 | ln -sfT /usr/lib/mxisd/mxisd /usr/bin/mxisd 11 | 12 | # Enable systemd service 13 | systemctl enable mxisd.service 14 | 15 | # If we already have a config file setup, we attempt to run mxisd automatically 16 | # Specifically targeted at upgrades where the service needs to be restarted 17 | if [ -f "%DEB_CONF_FILE%" ]; then 18 | systemctl restart mxisd.service 19 | fi 20 | -------------------------------------------------------------------------------- /src/debian/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Stop running instance if needed 4 | systemctl stop mxisd.service 5 | 6 | # Disable service if exists 7 | systemctl disable mxisd.service 8 | 9 | # remove symlink 10 | rm /usr/bin/mxisd 11 | -------------------------------------------------------------------------------- /src/docker/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -n "$CONF_FILE_PATH" ]] && [ ! -f "$CONF_FILE_PATH" ]; then 4 | echo "Generating config file $CONF_FILE_PATH" 5 | touch "CONF_FILE_PATH" 6 | 7 | if [[ -n "$MATRIX_DOMAIN" ]]; then 8 | echo "Setting matrix domain to $MATRIX_DOMAIN" 9 | echo "matrix:" >> "$CONF_FILE_PATH" 10 | echo " domain: '$MATRIX_DOMAIN'" >> "$CONF_FILE_PATH" 11 | echo >> "$CONF_FILE_PATH" 12 | fi 13 | 14 | if [[ -n "$SIGN_KEY_PATH" ]]; then 15 | echo "Setting signing key path to $SIGN_KEY_PATH" 16 | echo "key:" >> "$CONF_FILE_PATH" 17 | echo " path: '$SIGN_KEY_PATH'" >> "$CONF_FILE_PATH" 18 | echo >> "$CONF_FILE_PATH" 19 | fi 20 | 21 | if [[ -n "$SQLITE_DATABASE_PATH" ]]; then 22 | echo "Setting SQLite DB path to $SQLITE_DATABASE_PATH" 23 | echo "storage:" >> "$CONF_FILE_PATH" 24 | echo " provider:" >> "$CONF_FILE_PATH" 25 | echo " sqlite:" >> "$CONF_FILE_PATH" 26 | echo " database: '$SQLITE_DATABASE_PATH'" >> "$CONF_FILE_PATH" 27 | echo >> "$CONF_FILE_PATH" 28 | fi 29 | 30 | echo "Starting mxisd..." 31 | echo 32 | fi 33 | 34 | exec java -jar /app/mxisd.jar -c /etc/mxisd/mxisd.yaml 35 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/UserID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd; 22 | 23 | // FIXME consider integrating in matrix-java-sdk? 24 | public class UserID { 25 | 26 | private String type; 27 | private String value; 28 | 29 | protected UserID() { 30 | // stub for (de)serialization 31 | } 32 | 33 | public UserID(UserIdType type, String value) { 34 | this(type.getId(), value); 35 | } 36 | 37 | public UserID(String type, String value) { 38 | this.type = type; 39 | this.value = value; 40 | } 41 | 42 | public String getType() { 43 | return type; 44 | } 45 | 46 | public String getValue() { 47 | return value; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/UserIdType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd; 22 | 23 | import org.apache.commons.lang.StringUtils; 24 | 25 | // FIXME consider integrating in matrix-java-sdk? 26 | public enum UserIdType { 27 | 28 | Localpart("localpart"), 29 | MatrixID("mxid"), 30 | EmailLocalpart("email_localpart"), 31 | Email("email"); 32 | 33 | private String id; 34 | 35 | UserIdType(String id) { 36 | this.id = id; 37 | } 38 | 39 | public String getId() { 40 | return id; 41 | } 42 | 43 | public boolean is(String id) { 44 | return StringUtils.equalsIgnoreCase(this.id, id); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/as/processor/command/CommandProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.as.processor.command; 22 | 23 | import io.kamax.matrix.client._MatrixClient; 24 | import io.kamax.matrix.hs._MatrixRoom; 25 | import io.kamax.mxisd.Mxisd; 26 | import org.apache.commons.cli.CommandLine; 27 | 28 | public interface CommandProcessor { 29 | 30 | void process(Mxisd m, _MatrixClient client, _MatrixRoom room, CommandLine cmdLine); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/as/processor/command/PingCommandProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.as.processor.command; 22 | 23 | import io.kamax.matrix.client._MatrixClient; 24 | import io.kamax.matrix.hs._MatrixRoom; 25 | import io.kamax.mxisd.Mxisd; 26 | import org.apache.commons.cli.CommandLine; 27 | 28 | public class PingCommandProcessor implements CommandProcessor { 29 | 30 | public static final String Command = "ping"; 31 | 32 | @Override 33 | public void process(Mxisd m, _MatrixClient client, _MatrixRoom room, CommandLine cmdLine) { 34 | room.sendNotice("Pong!"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/as/processor/event/EventTypeProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.as.processor.event; 22 | 23 | import com.google.gson.JsonObject; 24 | import io.kamax.matrix._MatrixID; 25 | 26 | public interface EventTypeProcessor { 27 | 28 | void process(JsonObject ev, _MatrixID sender, String roomId); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/auth/AuthProviders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.auth; 22 | 23 | import io.kamax.mxisd.auth.provider.AuthenticatorProvider; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | import java.util.function.Supplier; 28 | import java.util.stream.Collectors; 29 | 30 | public class AuthProviders { 31 | 32 | private static final List> suppliers = new ArrayList<>(); 33 | 34 | public static void register(Supplier supplier) { 35 | suppliers.add(supplier); 36 | } 37 | 38 | public static List get() { 39 | return suppliers.stream().map(Supplier::get).collect(Collectors.toList()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/auth/provider/AuthenticatorProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.auth.provider; 22 | 23 | import io.kamax.matrix._MatrixID; 24 | 25 | public interface AuthenticatorProvider { 26 | 27 | boolean isEnabled(); 28 | 29 | BackendAuthResult authenticate(_MatrixID mxid, String password); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/IdentityStoreSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | 25 | import java.util.function.Consumer; 26 | 27 | public interface IdentityStoreSupplier extends Consumer { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/exec/ExecAuthResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.exec; 22 | 23 | import io.kamax.mxisd.auth.provider.BackendAuthResult; 24 | 25 | public class ExecAuthResult extends BackendAuthResult { 26 | 27 | private int exitStatus; 28 | 29 | public int getExitStatus() { 30 | return exitStatus; 31 | } 32 | 33 | public void setExitStatus(int exitStatus) { 34 | this.exitStatus = exitStatus; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/firebase/GoogleFirebaseStoreSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.firebase; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | import io.kamax.mxisd.auth.AuthProviders; 25 | import io.kamax.mxisd.backend.IdentityStoreSupplier; 26 | import io.kamax.mxisd.config.MxisdConfig; 27 | import io.kamax.mxisd.lookup.ThreePidProviders; 28 | 29 | public class GoogleFirebaseStoreSupplier implements IdentityStoreSupplier { 30 | 31 | @Override 32 | public void accept(Mxisd mxisd) { 33 | accept(mxisd.getConfig()); 34 | } 35 | 36 | public void accept(MxisdConfig cfg) { 37 | if (cfg.getFirebase().isEnabled()) { 38 | AuthProviders.register(() -> new GoogleFirebaseAuthenticator(cfg.getFirebase())); 39 | ThreePidProviders.register(() -> new GoogleFirebaseProvider(cfg)); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapAuthProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.ldap.netiq; 22 | 23 | import io.kamax.mxisd.backend.ldap.LdapAuthProvider; 24 | import io.kamax.mxisd.config.MatrixConfig; 25 | import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig; 26 | 27 | public class NetIqLdapAuthProvider extends LdapAuthProvider { 28 | 29 | public NetIqLdapAuthProvider(NetIqLdapConfig cfg, MatrixConfig mxCfg) { 30 | super(cfg, mxCfg); 31 | } 32 | 33 | // FIXME this is duplicated in the other NetIQ classes, due to the Matrix ID generation code that was not abstracted 34 | @Override 35 | public String buildMatrixIdFromUid(String uid) { 36 | return super.buildMatrixIdFromUid(uid).toLowerCase(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapDirectoryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.ldap.netiq; 22 | 23 | import io.kamax.mxisd.backend.ldap.LdapDirectoryProvider; 24 | import io.kamax.mxisd.config.MatrixConfig; 25 | import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig; 26 | 27 | public class NetIqLdapDirectoryProvider extends LdapDirectoryProvider { 28 | 29 | public NetIqLdapDirectoryProvider(NetIqLdapConfig cfg, MatrixConfig mxCfg) { 30 | super(cfg, mxCfg); 31 | } 32 | 33 | // FIXME this is duplicated in the other NetIQ classes, due to the Matrix ID generation code that was not abstracted 34 | @Override 35 | public String buildMatrixIdFromUid(String uid) { 36 | return super.buildMatrixIdFromUid(uid).toLowerCase(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapThreePidProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.ldap.netiq; 22 | 23 | import io.kamax.mxisd.backend.ldap.LdapThreePidProvider; 24 | import io.kamax.mxisd.config.MatrixConfig; 25 | import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig; 26 | 27 | public class NetIqLdapThreePidProvider extends LdapThreePidProvider { 28 | 29 | public NetIqLdapThreePidProvider(NetIqLdapConfig cfg, MatrixConfig mxCfg) { 30 | super(cfg, mxCfg); 31 | } 32 | 33 | // FIXME this is duplicated in the other NetIQ classes, due to the Matrix ID generation code that was not abstracted 34 | @Override 35 | public String buildMatrixIdFromUid(String uid) { 36 | return super.buildMatrixIdFromUid(uid).toLowerCase(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/rest/LookupBulkResponseJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.rest; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | public class LookupBulkResponseJson { 27 | 28 | private List lookup = new ArrayList<>(); 29 | 30 | public List getLookup() { 31 | return lookup; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/rest/LookupSingleRequestJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.rest; 22 | 23 | public class LookupSingleRequestJson { 24 | 25 | private String medium; 26 | private String address; 27 | 28 | public LookupSingleRequestJson(String medium, String address) { 29 | this.medium = medium; 30 | this.address = address; 31 | } 32 | 33 | public String getMedium() { 34 | return medium; 35 | } 36 | 37 | public String getAddress() { 38 | return address; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/rest/LookupSingleResponseJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.rest; 22 | 23 | import io.kamax.matrix.ThreePidMedium; 24 | import io.kamax.mxisd.UserID; 25 | 26 | public class LookupSingleResponseJson { 27 | 28 | private String medium; 29 | private String address; 30 | private UserID id; 31 | 32 | public String getMedium() { 33 | return medium; 34 | } 35 | 36 | public void setMedium(String medium) { 37 | this.medium = medium; 38 | } 39 | 40 | public void setMedium(ThreePidMedium medium) { 41 | setMedium(medium.getId()); 42 | } 43 | 44 | public String getAddress() { 45 | return address; 46 | } 47 | 48 | public void setAddress(String address) { 49 | this.address = address; 50 | } 51 | 52 | public UserID getId() { 53 | return id; 54 | } 55 | 56 | public void setId(UserID id) { 57 | this.id = id; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/rest/RestProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.rest; 22 | 23 | import com.google.gson.FieldNamingPolicy; 24 | import com.google.gson.Gson; 25 | import com.google.gson.GsonBuilder; 26 | import io.kamax.mxisd.config.rest.RestBackendConfig; 27 | import io.kamax.mxisd.util.GsonParser; 28 | import org.apache.http.impl.client.CloseableHttpClient; 29 | import org.apache.http.impl.client.HttpClients; 30 | 31 | public class RestProvider { 32 | 33 | protected RestBackendConfig cfg; 34 | protected Gson gson; 35 | protected GsonParser parser; 36 | protected CloseableHttpClient client; 37 | 38 | public RestProvider(RestBackendConfig cfg) { 39 | this.cfg = cfg; 40 | 41 | client = HttpClients.createDefault(); 42 | gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); 43 | parser = new GsonParser(gson); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/sql/DriverLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.sql; 22 | 23 | import java.util.function.Consumer; 24 | 25 | public interface DriverLoader extends Consumer { 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/sql/Drivers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.sql; 22 | 23 | import java.util.Objects; 24 | import java.util.ServiceLoader; 25 | 26 | public class Drivers { 27 | 28 | private static ServiceLoader svcLoader; 29 | 30 | public static void load(String type) { 31 | if (Objects.isNull(svcLoader)) { 32 | svcLoader = ServiceLoader.load(DriverLoader.class); 33 | } 34 | 35 | svcLoader.iterator().forEachRemaining(drv -> drv.accept(type)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/sql/generic/GenericSqlProfileProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.sql.generic; 22 | 23 | import io.kamax.mxisd.backend.sql.SqlProfileProvider; 24 | import io.kamax.mxisd.config.sql.generic.GenericSqlProviderConfig; 25 | 26 | public class GenericSqlProfileProvider extends SqlProfileProvider { 27 | 28 | public GenericSqlProfileProvider(GenericSqlProviderConfig cfg) { 29 | super(cfg); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/sql/generic/GenericSqlThreePidProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.sql.generic; 22 | 23 | import io.kamax.mxisd.backend.sql.SqlThreePidProvider; 24 | import io.kamax.mxisd.config.MatrixConfig; 25 | import io.kamax.mxisd.config.sql.generic.GenericSqlProviderConfig; 26 | 27 | public class GenericSqlThreePidProvider extends SqlThreePidProvider { 28 | 29 | public GenericSqlThreePidProvider(GenericSqlProviderConfig cfg, MatrixConfig mxCfg) { 30 | super(cfg, mxCfg); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/sql/synapse/SynapseSqlProfileProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.sql.synapse; 22 | 23 | import io.kamax.mxisd.backend.sql.SqlProfileProvider; 24 | import io.kamax.mxisd.config.sql.synapse.SynapseSqlProviderConfig; 25 | 26 | public class SynapseSqlProfileProvider extends SqlProfileProvider { 27 | 28 | public SynapseSqlProfileProvider(SynapseSqlProviderConfig cfg) { 29 | super(cfg); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/backend/sql/synapse/SynapseSqlThreePidProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.backend.sql.synapse; 22 | 23 | import io.kamax.mxisd.backend.sql.SqlThreePidProvider; 24 | import io.kamax.mxisd.config.MatrixConfig; 25 | import io.kamax.mxisd.config.sql.synapse.SynapseSqlProviderConfig; 26 | 27 | public class SynapseSqlThreePidProvider extends SqlThreePidProvider { 28 | 29 | public SynapseSqlThreePidProvider(SynapseSqlProviderConfig cfg, MatrixConfig mxCfg) { 30 | super(cfg, mxCfg); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/BulkLookupConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config; 22 | 23 | import java.util.Objects; 24 | 25 | public class BulkLookupConfig { 26 | 27 | private Boolean enabled; 28 | 29 | public Boolean getEnabled() { 30 | return enabled; 31 | } 32 | 33 | public void setEnabled(Boolean enabled) { 34 | this.enabled = enabled; 35 | } 36 | 37 | public void build() { 38 | if (Objects.isNull(enabled)) { 39 | enabled = true; 40 | } 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/ForwardConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | public class ForwardConfig { 27 | 28 | private List servers = new ArrayList<>(); 29 | 30 | public List getServers() { 31 | return servers; 32 | } 33 | 34 | public void setServers(List servers) { 35 | this.servers = servers; 36 | } 37 | 38 | public void build() { 39 | // no-op 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/KeyConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config; 22 | 23 | import io.kamax.mxisd.exception.ConfigurationException; 24 | import org.apache.commons.lang.StringUtils; 25 | 26 | public class KeyConfig { 27 | 28 | private String path; 29 | 30 | public void setPath(String path) { 31 | this.path = path; 32 | } 33 | 34 | public String getPath() { 35 | return path; 36 | } 37 | 38 | public void build() { 39 | if (StringUtils.isBlank(getPath())) { 40 | throw new ConfigurationException("key.path"); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/SQLiteStorageConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config; 22 | 23 | public class SQLiteStorageConfig { 24 | 25 | private String database; 26 | 27 | public String getDatabase() { 28 | return database; 29 | } 30 | 31 | public void setDatabase(String database) { 32 | this.database = database; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/ldap/generic/GenericLdapConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config.ldap.generic; 22 | 23 | import io.kamax.mxisd.config.ldap.LdapConfig; 24 | 25 | public class GenericLdapConfig extends LdapConfig { 26 | 27 | @Override 28 | protected String getConfigName() { 29 | return "Generic LDAP"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/ldap/netiq/NetIqLdapConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config.ldap.netiq; 22 | 23 | import io.kamax.mxisd.config.ldap.LdapConfig; 24 | 25 | public class NetIqLdapConfig extends LdapConfig { 26 | 27 | @Override 28 | protected String getConfigName() { 29 | return "NetIQ eDirectory"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/memory/MemoryStoreConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config.memory; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | public class MemoryStoreConfig { 27 | 28 | private boolean enabled; 29 | private List identities = new ArrayList<>(); 30 | 31 | public boolean isEnabled() { 32 | return enabled; 33 | } 34 | 35 | public void setEnabled(boolean enabled) { 36 | this.enabled = enabled; 37 | } 38 | 39 | public List getIdentities() { 40 | return identities; 41 | } 42 | 43 | public void setIdentities(List identities) { 44 | this.identities = identities; 45 | } 46 | 47 | public void build() { 48 | // no-op 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/memory/MemoryThreePid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config.memory; 22 | 23 | import io.kamax.matrix._ThreePid; 24 | 25 | public class MemoryThreePid implements _ThreePid { 26 | 27 | private String medium; 28 | private String address; 29 | 30 | @Override 31 | public String getMedium() { 32 | return medium; 33 | } 34 | 35 | public void setMedium(String medium) { 36 | this.medium = medium; 37 | } 38 | 39 | @Override 40 | public String getAddress() { 41 | return address; 42 | } 43 | 44 | public void setAddress(String address) { 45 | this.address = address; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/sql/generic/GenericSqlProviderConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config.sql.generic; 22 | 23 | import io.kamax.mxisd.config.sql.SqlConfig; 24 | 25 | public class GenericSqlProviderConfig extends SqlConfig { 26 | 27 | @Override 28 | protected String getProviderName() { 29 | return "Generic SQL"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/config/threepid/medium/PhoneConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.config.threepid.medium; 22 | 23 | import io.kamax.mxisd.threepid.connector.phone.PhoneSmsTwilioConnector; 24 | import io.kamax.mxisd.threepid.generator.phone.SmsNotificationGenerator; 25 | 26 | public class PhoneConfig extends MediumConfig { 27 | 28 | public PhoneConfig() { 29 | setConnector(PhoneSmsTwilioConnector.ID); 30 | setGenerator(SmsNotificationGenerator.ID); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/GenericKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | public class GenericKey implements Key { 24 | 25 | private final KeyIdentifier id; 26 | private final boolean isValid; 27 | private final String privKey; 28 | 29 | public GenericKey(KeyIdentifier id, boolean isValid, String privKey) { 30 | this.id = new GenericKeyIdentifier(id); 31 | this.isValid = isValid; 32 | this.privKey = privKey; 33 | } 34 | 35 | 36 | @Override 37 | public KeyIdentifier getId() { 38 | return id; 39 | } 40 | 41 | @Override 42 | public boolean isValid() { 43 | return isValid; 44 | } 45 | 46 | @Override 47 | public String getPrivateKeyBase64() { 48 | return privKey; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/Key.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | /** 24 | * A signing key 25 | */ 26 | public interface Key { 27 | 28 | KeyIdentifier getId(); 29 | 30 | /** 31 | * If the key is currently valid 32 | * 33 | * @return true if the key is valid, false if not 34 | */ 35 | boolean isValid(); 36 | 37 | /** 38 | * Get the private key 39 | * 40 | * @return the private key encoded as Base64 41 | */ 42 | String getPrivateKeyBase64(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/KeyAlgorithm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | public interface KeyAlgorithm { 24 | 25 | String Ed25519 = "ed25519"; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/KeyIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | /** 24 | * Identifying data for a given Key. 25 | */ 26 | public interface KeyIdentifier { 27 | 28 | /** 29 | * Type of key. 30 | * 31 | * @return The type of the key 32 | */ 33 | KeyType getType(); 34 | 35 | /** 36 | * Algorithm of the key. Typically ed25519. 37 | * 38 | * @return The algorithm of the key 39 | */ 40 | String getAlgorithm(); 41 | 42 | /** 43 | * Serial of the key, unique for the algorithm. 44 | * It is typically made of random alphanumerical characters. 45 | * 46 | * @return The serial of the key 47 | */ 48 | String getSerial(); 49 | 50 | default String getId() { 51 | return getAlgorithm().toLowerCase() + ":" + getSerial(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/KeyManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | import java.util.List; 24 | 25 | public interface KeyManager { 26 | 27 | KeyIdentifier generateKey(KeyType type); 28 | 29 | List getKeys(KeyType type); 30 | 31 | Key getServerSigningKey(); 32 | 33 | Key getKey(KeyIdentifier id); 34 | 35 | void disableKey(KeyIdentifier id); 36 | 37 | String getPublicKeyBase64(KeyIdentifier id); 38 | 39 | boolean isValid(KeyType type, String publicKeyBase64); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/KeyType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | /** 24 | * Types of keys used by an Identity server. 25 | * See https://matrix.org/docs/spec/identity_service/r0.2.0.html#key-management 26 | */ 27 | public enum KeyType { 28 | 29 | /** 30 | * Ephemeral keys are related to 3PID invites and are only valid while the invite is pending. 31 | */ 32 | Ephemeral, 33 | 34 | /** 35 | * Regular keys are used by the Identity Server itself to sign requests/responses 36 | */ 37 | Regular 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/RegularKeyIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | public class RegularKeyIdentifier extends GenericKeyIdentifier { 24 | 25 | public RegularKeyIdentifier(String algo, String serial) { 26 | super(KeyType.Regular, algo, serial); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/Signature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto; 22 | 23 | public interface Signature { 24 | 25 | KeyIdentifier getKey(); 26 | 27 | String getSignature(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/crypto/ed25519/Ed25519RegularKeyIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.crypto.ed25519; 22 | 23 | import io.kamax.mxisd.crypto.KeyAlgorithm; 24 | import io.kamax.mxisd.crypto.RegularKeyIdentifier; 25 | 26 | public class Ed25519RegularKeyIdentifier extends RegularKeyIdentifier { 27 | 28 | public Ed25519RegularKeyIdentifier(String serial) { 29 | super(KeyAlgorithm.Ed25519, serial); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/directory/DirectoryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.directory; 22 | 23 | import io.kamax.mxisd.http.io.UserDirectorySearchResult; 24 | 25 | public interface DirectoryProvider { 26 | 27 | UserDirectorySearchResult searchByDisplayName(String query); 28 | 29 | UserDirectorySearchResult searchBy3pid(String query); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/directory/DirectoryProviders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.directory; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.function.Supplier; 26 | import java.util.stream.Collectors; 27 | 28 | public class DirectoryProviders { 29 | 30 | private static final List> suppliers = new ArrayList<>(); 31 | 32 | public static void register(Supplier supplier) { 33 | suppliers.add(supplier); 34 | } 35 | 36 | public static List get() { 37 | return suppliers.stream().map(Supplier::get).collect(Collectors.toList()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/AccessTokenNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class AccessTokenNotFoundException extends HttpMatrixException { 24 | 25 | public AccessTokenNotFoundException() { 26 | super(401, "M_UNKNOWN_TOKEN", "An access token is required to access this resource"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class BadRequestException extends RuntimeException { 24 | 25 | public BadRequestException(String s) { 26 | super(s); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/ConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class ConfigurationException extends RuntimeException { 24 | 25 | private String detailedMsg; 26 | 27 | public ConfigurationException(String key) { 28 | super("Invalid or empty value for configuration item: " + key); 29 | } 30 | 31 | public ConfigurationException(Throwable t) { 32 | super(t.getMessage(), t); 33 | } 34 | 35 | public ConfigurationException(String key, String detailedMsg) { 36 | this(key); 37 | this.detailedMsg = detailedMsg; 38 | } 39 | 40 | public String getDetailedMessage() { 41 | return detailedMsg; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/FeatureNotAvailable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | import org.apache.http.HttpStatus; 24 | 25 | public class FeatureNotAvailable extends HttpMatrixException { 26 | 27 | private String internalReason; 28 | 29 | public FeatureNotAvailable(String internalReason) { 30 | super( 31 | HttpStatus.SC_INTERNAL_SERVER_ERROR, 32 | "M_NOT_AVAILABLE", 33 | "This action is currently not available. Contact your administrator to enable it." 34 | ); 35 | 36 | this.internalReason = internalReason; 37 | } 38 | 39 | public String getInternalReason() { 40 | return internalReason; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/HttpMatrixException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | import io.kamax.matrix.MatrixException; 24 | 25 | public class HttpMatrixException extends MatrixException { 26 | 27 | private int status; 28 | 29 | public HttpMatrixException(int status, String errorCode, String error) { 30 | super(errorCode, error); 31 | this.status = status; 32 | } 33 | 34 | public int getStatus() { 35 | return status; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/InvalidCredentialsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class InvalidCredentialsException extends RuntimeException { 24 | 25 | public InvalidCredentialsException() { 26 | super("Supplied credentials are invalid"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/InvalidResponseJsonException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class InvalidResponseJsonException extends RuntimeException { 24 | 25 | public InvalidResponseJsonException(String s) { 26 | super(s); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/JsonMemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class JsonMemberNotFoundException extends RuntimeException { 24 | 25 | public JsonMemberNotFoundException(String s) { 26 | super(s); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/MappingAlreadyExistsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class MappingAlreadyExistsException extends RuntimeException { 24 | 25 | public MappingAlreadyExistsException() { 26 | super("A mapping already exists for this 3PID"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/MessageForClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | import org.apache.http.HttpStatus; 24 | 25 | public class MessageForClientException extends HttpMatrixException { 26 | 27 | public MessageForClientException(String error) { 28 | super(HttpStatus.SC_OK, "M_MESSAGE_FOR_CLIENT", error); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/MxisdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class MxisdException extends RuntimeException { 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/NotAllowedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | 24 | import org.apache.http.HttpStatus; 25 | 26 | public class NotAllowedException extends HttpMatrixException { 27 | 28 | public static final String ErrCode = "M_FORBIDDEN"; 29 | 30 | public NotAllowedException(int code, String s) { 31 | super(code, ErrCode, s); 32 | } 33 | 34 | public NotAllowedException(String s) { 35 | super(HttpStatus.SC_FORBIDDEN, ErrCode, s); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/NotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | // FIXME duplicate of ObjectNotFoundException - see if we can merge 24 | public class NotFoundException extends HttpMatrixException { 25 | 26 | public NotFoundException() { 27 | super(404, "M_NOT_FOUND", "Not found"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/NotImplementedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class NotImplementedException extends RuntimeException { 24 | 25 | public NotImplementedException(String s) { 26 | super(s); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/ObjectNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | public class ObjectNotFoundException extends RuntimeException { 24 | 25 | public ObjectNotFoundException(String message) { 26 | super(message); 27 | } 28 | 29 | public ObjectNotFoundException(String type, String id) { 30 | this(type + " with ID " + id + " does not exist"); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/RemoteHomeServerException.java: -------------------------------------------------------------------------------- 1 | package io.kamax.mxisd.exception; 2 | 3 | import org.apache.http.HttpStatus; 4 | 5 | public class RemoteHomeServerException extends HttpMatrixException { 6 | 7 | public RemoteHomeServerException(String error) { 8 | super(HttpStatus.SC_SERVICE_UNAVAILABLE, "M_REMOTE_HS_ERROR", "Error from remote server: " + error); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/RemoteIdentityServerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | import org.apache.http.HttpStatus; 24 | 25 | public class RemoteIdentityServerException extends HttpMatrixException { 26 | 27 | public RemoteIdentityServerException(String error) { 28 | super(HttpStatus.SC_SERVICE_UNAVAILABLE, "M_REMOTE_IS_ERROR", "Error from remote server: " + error); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/RemoteLoginException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | 24 | import com.google.gson.JsonObject; 25 | 26 | public class RemoteLoginException extends HttpMatrixException { 27 | 28 | private JsonObject errorBodyMsgResp; 29 | 30 | public RemoteLoginException(int status, String errorCode, String error) { 31 | super(status, errorCode, error); 32 | this.errorBodyMsgResp = null; 33 | } 34 | 35 | public RemoteLoginException(int status, String errorCode, String error, JsonObject errorBodyMsgResp) { 36 | super(status, errorCode, error); 37 | this.errorBodyMsgResp = errorBodyMsgResp; 38 | } 39 | 40 | public JsonObject getErrorBodyMsgResp() { 41 | return errorBodyMsgResp; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/SessionNotValidatedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | import org.apache.http.HttpStatus; 24 | 25 | public class SessionNotValidatedException extends HttpMatrixException { 26 | 27 | public SessionNotValidatedException() { 28 | super(HttpStatus.SC_BAD_REQUEST, "M_SESSION_NOT_VALIDATED", "This validation session has not yet been completed"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/exception/SessionUnknownException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.exception; 22 | 23 | import org.apache.http.HttpStatus; 24 | 25 | public class SessionUnknownException extends HttpMatrixException { 26 | 27 | public SessionUnknownException() { 28 | this("No valid session was found matching that sid and client secret"); 29 | } 30 | 31 | public SessionUnknownException(String error) { 32 | super(HttpStatus.SC_NOT_FOUND, "M_NO_VALID_SESSION", error); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/IsAPIv1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http; 22 | 23 | public class IsAPIv1 { 24 | 25 | public static final String Base = "/_matrix/identity/api/v1"; 26 | 27 | public static String getValidate(String medium, String sid, String secret, String token) { 28 | // FIXME use some kind of URLBuilder 29 | return Base + "/validate/" + medium + "/submitToken?sid=" + sid + "&client_secret=" + secret + "&token=" + token; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/UserDirectorySearchRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io; 22 | 23 | public class UserDirectorySearchRequest { 24 | 25 | private String by; 26 | private String searchTerm; 27 | 28 | public UserDirectorySearchRequest(String searchTerm) { 29 | setSearchTerm(searchTerm); 30 | } 31 | 32 | public UserDirectorySearchRequest(String type, String searchTerm) { 33 | setBy(type); 34 | setSearchTerm(searchTerm); 35 | } 36 | 37 | public String getBy() { 38 | return by; 39 | } 40 | 41 | public void setBy(String by) { 42 | this.by = by; 43 | } 44 | 45 | public String getSearchTerm() { 46 | return searchTerm; 47 | } 48 | 49 | public void setSearchTerm(String searchTerm) { 50 | this.searchTerm = searchTerm; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/ClientBulkLookupAnswer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | import io.kamax.mxisd.lookup.ThreePidMapping; 24 | 25 | import java.util.ArrayList; 26 | import java.util.Arrays; 27 | import java.util.Collection; 28 | import java.util.List; 29 | 30 | public class ClientBulkLookupAnswer { 31 | 32 | private List> threepids = new ArrayList<>(); 33 | 34 | public void addAll(Collection mappings) { 35 | for (ThreePidMapping mapping : mappings) { 36 | threepids.add(Arrays.asList(mapping.getMedium(), mapping.getValue(), mapping.getMxid())); 37 | } 38 | } 39 | 40 | public List> getThreepids() { 41 | return threepids; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/ClientBulkLookupRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | import io.kamax.mxisd.lookup.ThreePidMapping; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | public class ClientBulkLookupRequest { 29 | 30 | private List> threepids = new ArrayList<>(); 31 | 32 | public List> getThreepids() { 33 | return threepids; 34 | } 35 | 36 | public void setThreepids(List> threepids) { 37 | this.threepids = threepids; 38 | } 39 | 40 | public void setMappings(List mappings) { 41 | for (ThreePidMapping mapping : mappings) { 42 | List threepid = new ArrayList<>(); 43 | threepid.add(mapping.getMedium()); 44 | threepid.add(mapping.getValue()); 45 | threepids.add(threepid); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/GenericTokenRequestJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | public abstract class GenericTokenRequestJson { 24 | 25 | private String client_secret; 26 | private int send_attempt; 27 | private String next_link; 28 | 29 | public String getSecret() { 30 | return client_secret; 31 | } 32 | 33 | public int getAttempt() { 34 | return send_attempt; 35 | } 36 | 37 | public String getNextLink() { 38 | return next_link; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/KeyValidityJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | public class KeyValidityJson { 24 | 25 | private boolean valid; 26 | 27 | public KeyValidityJson(boolean isValid) { 28 | this.valid = isValid; 29 | } 30 | 31 | public boolean isValid() { 32 | return valid; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/RequestTokenResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | public class RequestTokenResponse { 24 | 25 | private String sid; 26 | 27 | public RequestTokenResponse() { 28 | // for (de)serializers 29 | } 30 | 31 | public RequestTokenResponse(String sid) { 32 | this.sid = sid; 33 | } 34 | 35 | public String getSid() { 36 | return sid; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/SessionEmailTokenRequestJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | import io.kamax.matrix.ThreePidMedium; 24 | 25 | public class SessionEmailTokenRequestJson extends GenericTokenRequestJson { 26 | 27 | private String email; 28 | 29 | public String getMedium() { 30 | return ThreePidMedium.Email.getId(); 31 | } 32 | 33 | public String getValue() { 34 | return email; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/io/identity/SuccessStatusJson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.io.identity; 22 | 23 | public class SuccessStatusJson { 24 | 25 | private boolean success; 26 | 27 | public SuccessStatusJson(boolean success) { 28 | this.success = success; 29 | } 30 | 31 | public boolean isSuccess() { 32 | return success; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/OptionsHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler; 22 | 23 | import io.undertow.server.HttpServerExchange; 24 | 25 | public class OptionsHandler extends BasicHttpHandler { 26 | 27 | @Override 28 | public void handleRequest(HttpServerExchange exchange) { 29 | // no-op 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/as/v1/ApplicationServiceHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.as.v1; 22 | 23 | import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler; 24 | import io.undertow.server.HttpServerExchange; 25 | 26 | import java.util.LinkedList; 27 | import java.util.Optional; 28 | 29 | public abstract class ApplicationServiceHandler extends BasicHttpHandler { 30 | 31 | protected String getToken(HttpServerExchange ex) { 32 | return Optional.ofNullable(ex.getQueryParameters() 33 | .getOrDefault("access_token", new LinkedList<>()) 34 | .peekFirst() 35 | ).orElse(""); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/as/v1/AsNotFoundHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.as.v1; 22 | 23 | import io.kamax.mxisd.as.AppSvcManager; 24 | import io.kamax.mxisd.exception.NotFoundException; 25 | import io.undertow.server.HttpServerExchange; 26 | 27 | public class AsNotFoundHandler extends ApplicationServiceHandler { 28 | 29 | private final AppSvcManager app; 30 | 31 | public AsNotFoundHandler(AppSvcManager app) { 32 | this.app = app; 33 | } 34 | 35 | @Override 36 | public void handleRequest(HttpServerExchange exchange) { 37 | app.withToken(getToken(exchange)); 38 | 39 | throw new NotFoundException(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/as/v1/AsUserHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.as.v1; 22 | 23 | import io.kamax.mxisd.as.AppSvcManager; 24 | import io.undertow.server.HttpServerExchange; 25 | 26 | import java.util.LinkedList; 27 | 28 | public class AsUserHandler extends ApplicationServiceHandler { 29 | 30 | public static final String ID = "userId"; 31 | public static final String Path = "/_matrix/app/v1/users/{" + ID + "}"; 32 | 33 | private final AppSvcManager app; 34 | 35 | public AsUserHandler(AppSvcManager app) { 36 | this.app = app; 37 | } 38 | 39 | @Override 40 | public void handleRequest(HttpServerExchange exchange) { 41 | String userId = exchange.getQueryParameters().getOrDefault(ID, new LinkedList<>()).peekFirst(); 42 | app.withToken(getToken(exchange)).processUser(userId); 43 | respondJson(exchange, "{}"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/auth/v1/LoginHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.auth.v1; 22 | 23 | import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler; 24 | 25 | public abstract class LoginHandler extends BasicHttpHandler { 26 | 27 | public static final String Path = "/_matrix/client/r0/login"; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/auth/v1/LoginPostHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.auth.v1; 22 | 23 | import io.kamax.mxisd.auth.AuthManager; 24 | import io.undertow.server.HttpServerExchange; 25 | import org.apache.commons.io.IOUtils; 26 | 27 | import java.net.URI; 28 | import java.nio.charset.StandardCharsets; 29 | 30 | public class LoginPostHandler extends LoginHandler { 31 | 32 | private AuthManager mgr; 33 | 34 | public LoginPostHandler(AuthManager mgr) { 35 | this.mgr = mgr; 36 | } 37 | 38 | @Override 39 | public void handleRequest(HttpServerExchange exchange) throws Exception { 40 | respondJson(exchange, mgr.proxyLogin( 41 | URI.create(exchange.getRequestURL()), 42 | IOUtils.toString(exchange.getInputStream(), StandardCharsets.UTF_8) 43 | ) 44 | ); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/identity/v1/HelloHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.identity.v1; 22 | 23 | import io.kamax.mxisd.http.IsAPIv1; 24 | import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler; 25 | import io.undertow.server.HttpServerExchange; 26 | 27 | public class HelloHandler extends BasicHttpHandler { 28 | 29 | public static final String Path = IsAPIv1.Base; 30 | 31 | @Override 32 | public void handleRequest(HttpServerExchange exchange) { 33 | respondJson(exchange, "{}"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/identity/v1/KeyIsValidHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.identity.v1; 22 | 23 | import io.kamax.matrix.json.GsonUtil; 24 | import io.kamax.mxisd.http.io.identity.KeyValidityJson; 25 | import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler; 26 | 27 | public abstract class KeyIsValidHandler extends BasicHttpHandler { 28 | 29 | protected final String validKey = GsonUtil.get().toJson(new KeyValidityJson(true)); 30 | protected final String invalidKey = GsonUtil.get().toJson(new KeyValidityJson(false)); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/status/StatusHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.status; 22 | 23 | import com.google.gson.JsonObject; 24 | import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler; 25 | import io.undertow.server.HttpServerExchange; 26 | 27 | public class StatusHandler extends BasicHttpHandler { 28 | 29 | public static final String Path = "/status"; 30 | 31 | @Override 32 | public void handleRequest(HttpServerExchange exchange) { 33 | // TODO link to backend 34 | JsonObject status = new JsonObject(); 35 | status.addProperty("health", "OK"); 36 | 37 | JsonObject obj = new JsonObject(); 38 | obj.add("status", status); 39 | 40 | respond(exchange, obj); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/http/undertow/handler/status/VersionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.http.undertow.handler.status; 22 | 23 | import com.google.gson.JsonObject; 24 | import io.kamax.matrix.json.GsonUtil; 25 | import io.kamax.mxisd.Mxisd; 26 | import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler; 27 | import io.undertow.server.HttpServerExchange; 28 | 29 | public class VersionHandler extends BasicHttpHandler { 30 | 31 | public static final String Path = "/version"; 32 | 33 | private final String body; 34 | 35 | public VersionHandler() { 36 | JsonObject server = new JsonObject(); 37 | server.addProperty("name", Mxisd.Name); 38 | server.addProperty("version", Mxisd.Version); 39 | 40 | body = GsonUtil.getPrettyForLog(GsonUtil.makeObj("server", server)); 41 | } 42 | 43 | @Override 44 | public void handleRequest(HttpServerExchange exchange) { 45 | respondJson(exchange, body); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/invitation/IMatrixIdInvite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.invitation; 22 | 23 | import io.kamax.matrix._MatrixID; 24 | 25 | public interface IMatrixIdInvite extends IThreePidInvite { 26 | 27 | _MatrixID getInvitee(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/invitation/IThreePidInvite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.invitation; 22 | 23 | import io.kamax.matrix._MatrixID; 24 | 25 | import java.util.Map; 26 | 27 | public interface IThreePidInvite { 28 | 29 | _MatrixID getSender(); 30 | 31 | String getMedium(); 32 | 33 | String getAddress(); 34 | 35 | String getRoomId(); 36 | 37 | Map getProperties(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/invitation/IThreePidInviteReply.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.invitation; 22 | 23 | import java.util.List; 24 | 25 | public interface IThreePidInviteReply { 26 | 27 | String getId(); 28 | 29 | IThreePidInvite getInvite(); 30 | 31 | String getToken(); 32 | 33 | String getDisplayName(); 34 | 35 | List getPublicKeys(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/BulkLookupRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup; 22 | 23 | import java.util.List; 24 | 25 | public class BulkLookupRequest extends ALookupRequest { 26 | 27 | private List mappings; 28 | 29 | public List getMappings() { 30 | return mappings; 31 | } 32 | 33 | public void setMappings(List mappings) { 34 | this.mappings = mappings; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/SingleLookupRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup; 22 | 23 | public class SingleLookupRequest extends ALookupRequest { 24 | 25 | private String type; 26 | private String threePid; 27 | 28 | public String getType() { 29 | return type; 30 | } 31 | 32 | public void setType(String type) { 33 | this.type = type; 34 | } 35 | 36 | public String getThreePid() { 37 | return threePid; 38 | } 39 | 40 | public void setThreePid(String threePid) { 41 | this.threePid = threePid; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/ThreePidProviders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup; 22 | 23 | import io.kamax.mxisd.lookup.provider.IThreePidProvider; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | import java.util.function.Supplier; 28 | import java.util.stream.Collectors; 29 | 30 | public class ThreePidProviders { 31 | 32 | private static final List> suppliers = new ArrayList<>(); 33 | 34 | public static void register(Supplier supplier) { 35 | suppliers.add(supplier); 36 | } 37 | 38 | public static List get() { 39 | return suppliers.stream().map(Supplier::get).collect(Collectors.toList()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/ThreePidValidation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup; 22 | 23 | import io.kamax.matrix.ThreePid; 24 | 25 | import java.time.Instant; 26 | 27 | public class ThreePidValidation extends ThreePid { 28 | 29 | private Instant validation; 30 | 31 | public ThreePidValidation(ThreePid tpid, Instant validation) { 32 | super(tpid.getMedium(), tpid.getAddress()); 33 | this.validation = validation; 34 | } 35 | 36 | public Instant getValidation() { 37 | return validation; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/fetcher/IBridgeFetcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup.fetcher; 22 | 23 | import io.kamax.mxisd.lookup.SingleLookupReply; 24 | import io.kamax.mxisd.lookup.SingleLookupRequest; 25 | import io.kamax.mxisd.lookup.ThreePidMapping; 26 | 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public interface IBridgeFetcher { 31 | 32 | Optional find(SingleLookupRequest request); 33 | 34 | List populate(List mappings); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/fetcher/IRemoteIdentityServerFetcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup.fetcher; 22 | 23 | import io.kamax.mxisd.lookup.SingleLookupReply; 24 | import io.kamax.mxisd.lookup.SingleLookupRequest; 25 | import io.kamax.mxisd.lookup.ThreePidMapping; 26 | 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public interface IRemoteIdentityServerFetcher { 31 | 32 | boolean isUsable(String remote); 33 | 34 | Optional find(String remote, SingleLookupRequest request); 35 | 36 | List find(String remote, List mappings); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/provider/IThreePidProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup.provider; 22 | 23 | import io.kamax.mxisd.lookup.SingleLookupReply; 24 | import io.kamax.mxisd.lookup.SingleLookupRequest; 25 | import io.kamax.mxisd.lookup.ThreePidMapping; 26 | 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public interface IThreePidProvider { 31 | 32 | boolean isLocal(); 33 | 34 | /** 35 | * Higher has more priority 36 | */ 37 | int getPriority(); // Should not be here but let's KISS for now 38 | 39 | Optional find(SingleLookupRequest request); 40 | 41 | List populate(List mappings); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/lookup/provider/RemoteLookupProviderSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.lookup.provider; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | import io.kamax.mxisd.backend.IdentityStoreSupplier; 25 | import io.kamax.mxisd.lookup.ThreePidProviders; 26 | 27 | public class RemoteLookupProviderSupplier implements IdentityStoreSupplier { 28 | 29 | @Override 30 | public void accept(Mxisd mxisd) { 31 | ThreePidProviders.register(() -> new DnsLookupProvider(mxisd.getConfig().getMatrix(), mxisd.getServerFetcher())); 32 | ThreePidProviders.register(() -> new ForwarderProvider(mxisd.getConfig(), mxisd.getServerFetcher())); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/notification/NotificationHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.notification; 22 | 23 | import io.kamax.matrix.ThreePid; 24 | import io.kamax.mxisd.invitation.IMatrixIdInvite; 25 | import io.kamax.mxisd.invitation.IThreePidInviteReply; 26 | import io.kamax.mxisd.threepid.session.IThreePidSession; 27 | 28 | public interface NotificationHandler { 29 | 30 | String getId(); 31 | 32 | String getMedium(); 33 | 34 | void sendForInvite(IMatrixIdInvite invite); 35 | 36 | void sendForReply(IThreePidInviteReply invite); 37 | 38 | void sendForValidation(IThreePidSession session); 39 | 40 | void sendForFraudulentUnbind(ThreePid tpid); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/notification/NotificationHandlerSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.notification; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | 25 | import java.util.function.Consumer; 26 | 27 | public interface NotificationHandlerSupplier extends Consumer { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/notification/NotificationHandlers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.notification; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.function.Supplier; 26 | import java.util.stream.Collectors; 27 | 28 | public class NotificationHandlers { 29 | 30 | private static final List> suppliers = new ArrayList<>(); 31 | 32 | public static void register(Supplier supplier) { 33 | suppliers.add(supplier); 34 | } 35 | 36 | public static List get() { 37 | return suppliers.stream().map(Supplier::get).collect(Collectors.toList()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/profile/ProfileProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.profile; 22 | 23 | import io.kamax.matrix._MatrixID; 24 | import io.kamax.matrix._ThreePid; 25 | 26 | import java.util.List; 27 | import java.util.Optional; 28 | 29 | public interface ProfileProvider { 30 | 31 | Optional getDisplayName(_MatrixID userId); 32 | 33 | List<_ThreePid> getThreepids(_MatrixID userId); 34 | 35 | List getRoles(_MatrixID userId); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/profile/ProfileProviders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.profile; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.function.Supplier; 26 | import java.util.stream.Collectors; 27 | 28 | public class ProfileProviders { 29 | 30 | private static final List> providers = new ArrayList<>(); 31 | 32 | public static void register(Supplier supplier) { 33 | providers.add(supplier); 34 | } 35 | 36 | public static List get() { 37 | return providers.stream().map(Supplier::get).collect(Collectors.toList()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/proxy/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.proxy; 22 | 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | public class Response { 27 | 28 | private int status; 29 | private Map> headers; 30 | private String body; 31 | 32 | public int getStatus() { 33 | return status; 34 | } 35 | 36 | public void setStatus(int status) { 37 | this.status = status; 38 | } 39 | 40 | public Map> getHeaders() { 41 | return headers; 42 | } 43 | 44 | public void setHeaders(Map> headers) { 45 | this.headers = headers; 46 | } 47 | 48 | public String getBody() { 49 | return body; 50 | } 51 | 52 | public void setBody(String body) { 53 | this.body = body; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/registration/RegistrationReply.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.registration; 22 | 23 | import com.google.gson.JsonObject; 24 | 25 | public class RegistrationReply { 26 | 27 | private int status; 28 | private JsonObject body; 29 | 30 | public int getStatus() { 31 | return status; 32 | } 33 | 34 | public void setStatus(int status) { 35 | this.status = status; 36 | } 37 | 38 | public JsonObject getBody() { 39 | return body; 40 | } 41 | 42 | public void setBody(JsonObject body) { 43 | this.body = body; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/session/ValidationResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.session; 22 | 23 | import io.kamax.mxisd.threepid.session.IThreePidSession; 24 | 25 | import java.util.Optional; 26 | 27 | public class ValidationResult { 28 | 29 | private IThreePidSession session; 30 | private String nextUrl; 31 | 32 | public ValidationResult(IThreePidSession session) { 33 | this.session = session; 34 | } 35 | 36 | public IThreePidSession getSession() { 37 | return session; 38 | } 39 | 40 | public Optional getNextUrl() { 41 | return Optional.ofNullable(nextUrl); 42 | } 43 | 44 | public void setNextUrl(String nextUrl) { 45 | this.nextUrl = nextUrl; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/storage/dao/IThreePidSessionDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.storage.dao; 22 | 23 | public interface IThreePidSessionDao { 24 | 25 | String getId(); 26 | 27 | long getCreationTime(); 28 | 29 | String getServer(); 30 | 31 | String getMedium(); 32 | 33 | String getAddress(); 34 | 35 | String getSecret(); 36 | 37 | int getAttempt(); 38 | 39 | String getNextLink(); 40 | 41 | String getToken(); 42 | 43 | boolean getValidated(); 44 | 45 | long getValidationTime(); 46 | 47 | boolean isRemote(); 48 | 49 | String getRemoteServer(); 50 | 51 | String getRemoteId(); 52 | 53 | String getRemoteSecret(); 54 | 55 | int getRemoteAttempt(); 56 | 57 | boolean isRemoteValidated(); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/ThreePidConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector; 22 | 23 | public interface ThreePidConnector { 24 | 25 | String getId(); 26 | 27 | String getMedium(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/email/BlackholeEmailConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector.email; 22 | 23 | public class BlackholeEmailConnector implements EmailConnector { 24 | 25 | public static final String ID = "none"; 26 | 27 | @Override 28 | public String getId() { 29 | return ID; 30 | } 31 | 32 | @Override 33 | public void send(String senderAddress, String senderName, String recipient, String content) { 34 | //dev/null 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/email/EmailConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector.email; 22 | 23 | import io.kamax.matrix.ThreePidMedium; 24 | import io.kamax.mxisd.threepid.connector.ThreePidConnector; 25 | 26 | public interface EmailConnector extends ThreePidConnector { 27 | 28 | @Override 29 | default String getMedium() { 30 | return ThreePidMedium.Email.getId(); 31 | } 32 | 33 | void send(String senderAddress, String senderName, String recipient, String content); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/email/EmailConnectorSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector.email; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | import io.kamax.mxisd.config.threepid.medium.EmailConfig; 25 | 26 | import java.util.Optional; 27 | import java.util.function.BiFunction; 28 | 29 | public interface EmailConnectorSupplier extends BiFunction> { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/phone/BlackholePhoneConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector.phone; 22 | 23 | public class BlackholePhoneConnector implements PhoneConnector { 24 | 25 | public static final String ID = "none"; 26 | 27 | @Override 28 | public String getId() { 29 | return ID; 30 | } 31 | 32 | @Override 33 | public void send(String recipient, String content) { 34 | //dev/null 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/phone/PhoneConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector.phone; 22 | 23 | import io.kamax.matrix.ThreePidMedium; 24 | import io.kamax.mxisd.threepid.connector.ThreePidConnector; 25 | 26 | public interface PhoneConnector extends ThreePidConnector { 27 | 28 | @Override 29 | default String getMedium() { 30 | return ThreePidMedium.PhoneNumber.getId(); 31 | } 32 | 33 | void send(String recipient, String content); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/connector/phone/PhoneConnectorSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.connector.phone; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | import io.kamax.mxisd.config.threepid.medium.PhoneConfig; 25 | 26 | import java.util.Optional; 27 | import java.util.function.BiFunction; 28 | 29 | public interface PhoneConnectorSupplier extends BiFunction> { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/generator/NotificationGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.generator; 22 | 23 | import io.kamax.matrix.ThreePid; 24 | import io.kamax.mxisd.invitation.IMatrixIdInvite; 25 | import io.kamax.mxisd.invitation.IThreePidInviteReply; 26 | import io.kamax.mxisd.threepid.session.IThreePidSession; 27 | 28 | public interface NotificationGenerator { 29 | 30 | String getId(); 31 | 32 | String getMedium(); 33 | 34 | String getForInvite(IMatrixIdInvite invite); 35 | 36 | String getForReply(IThreePidInviteReply invite); 37 | 38 | String getForValidation(IThreePidSession session); 39 | 40 | String getForFraudulentUnbind(ThreePid tpid); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/generator/email/EmailGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.generator.email; 22 | 23 | import io.kamax.matrix.ThreePidMedium; 24 | import io.kamax.mxisd.threepid.generator.NotificationGenerator; 25 | 26 | public interface EmailGenerator extends NotificationGenerator { 27 | 28 | @Override 29 | default String getMedium() { 30 | return ThreePidMedium.Email.getId(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/generator/email/EmailGeneratorSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.generator.email; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | import io.kamax.mxisd.config.threepid.medium.EmailConfig; 25 | 26 | import java.util.Optional; 27 | import java.util.function.BiFunction; 28 | 29 | public interface EmailGeneratorSupplier extends BiFunction> { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/generator/phone/PhoneGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.generator.phone; 22 | 23 | import io.kamax.mxisd.threepid.generator.NotificationGenerator; 24 | 25 | public interface PhoneGenerator extends NotificationGenerator { 26 | 27 | default String getMedium() { 28 | return "msisdn"; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/generator/phone/PhoneGeneratorSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.generator.phone; 22 | 23 | import io.kamax.mxisd.Mxisd; 24 | import io.kamax.mxisd.config.threepid.medium.PhoneConfig; 25 | 26 | import java.util.Optional; 27 | import java.util.function.BiFunction; 28 | 29 | public interface PhoneGeneratorSupplier extends BiFunction> { 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/threepid/generator/phone/SmsNotificationGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.threepid.generator.phone; 22 | 23 | import io.kamax.mxisd.config.MatrixConfig; 24 | import io.kamax.mxisd.config.ServerConfig; 25 | import io.kamax.mxisd.config.threepid.medium.PhoneSmsTemplateConfig; 26 | import io.kamax.mxisd.threepid.generator.GenericTemplateNotificationGenerator; 27 | 28 | public class SmsNotificationGenerator extends GenericTemplateNotificationGenerator implements PhoneGenerator { 29 | 30 | public static final String ID = "template"; 31 | 32 | public SmsNotificationGenerator(MatrixConfig mxCfg, ServerConfig srvCfg, PhoneSmsTemplateConfig cfg) { 33 | super(mxCfg, srvCfg, cfg.build()); 34 | } 35 | 36 | @Override 37 | public String getId() { 38 | return ID; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/util/GsonUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.util; 22 | 23 | import com.google.gson.*; 24 | 25 | import java.util.Optional; 26 | 27 | public class GsonUtil { 28 | 29 | public static Gson build() { 30 | return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); 31 | } 32 | 33 | public static Optional findElement(JsonObject o, String key) { 34 | return Optional.ofNullable(o.get(key)); 35 | } 36 | 37 | public static Optional findObj(JsonObject o, String key) { 38 | return findElement(o, key).map(el -> el.isJsonObject() ? el.getAsJsonObject() : null); 39 | } 40 | 41 | public static Optional findPrimitive(JsonObject o, String key) { 42 | return findElement(o, key).map(el -> el.isJsonPrimitive() ? el.getAsJsonPrimitive() : null); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/util/JsonUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2017 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.util; 22 | 23 | import com.google.gson.Gson; 24 | import com.google.gson.JsonObject; 25 | 26 | public class JsonUtils { 27 | 28 | public static JsonObject getObj(Gson gson, String property, Object value) { 29 | JsonObject obj = new JsonObject(); 30 | obj.add(property, gson.toJsonTree(value)); 31 | return obj; 32 | } 33 | 34 | public static String getObjAsString(Gson gson, String property, Object value) { 35 | return gson.toJson(getObj(gson, property, value)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/util/OptionalUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.util; 22 | 23 | import java.util.Optional; 24 | import java.util.function.Supplier; 25 | import java.util.stream.Stream; 26 | 27 | public class OptionalUtil { 28 | 29 | public static Optional findFirst(Supplier>... suppliers) { 30 | return Stream.of(suppliers).map(Supplier::get).filter(Optional::isPresent).map(Optional::get).findFirst(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/kamax/mxisd/util/TriFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.util; 22 | 23 | @FunctionalInterface 24 | public interface TriFunction { 25 | 26 | R apply(T t, U u, V v); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.backend.IdentityStoreSupplier: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.backend.exec.ExecIdentityStoreSupplier 2 | io.kamax.mxisd.backend.firebase.GoogleFirebaseStoreSupplier 3 | io.kamax.mxisd.backend.ldap.LdapStoreSupplier 4 | io.kamax.mxisd.backend.ldap.netiq.NetIqLdapStoreSupplier 5 | io.kamax.mxisd.backend.memory.MemoryIdentityStoreSupplier 6 | io.kamax.mxisd.backend.rest.RestStoreSupplier 7 | io.kamax.mxisd.backend.sql.generic.GenericSqlStoreSupplier 8 | io.kamax.mxisd.backend.sql.synapse.SynapseSqlStoreSupplier 9 | io.kamax.mxisd.backend.wordpress.WordpressStoreSupplier 10 | io.kamax.mxisd.lookup.provider.RemoteLookupProviderSupplier 11 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.backend.sql.DriverLoader: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.backend.sql.BuiltInDriverLoader 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.notification.NotificationHandlerSupplier: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.threepid.notification.BuiltInNotificationHandlerSupplier 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.threepid.connector.email.EmailConnectorSupplier: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.threepid.connector.email.BuiltInEmailConnectorSupplier 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.threepid.connector.phone.PhoneConnectorSupplier: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.threepid.connector.phone.BuiltInPhoneConnectorSupplier 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.threepid.generator.email.EmailGeneratorSupplier: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.threepid.generator.email.BuiltInEmailGeneratorSupplier 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/io.kamax.mxisd.threepid.generator.phone.PhoneGeneratorSupplier: -------------------------------------------------------------------------------- 1 | io.kamax.mxisd.threepid.generator.phone.BuiltInPhoneGeneratorSupplier 2 | -------------------------------------------------------------------------------- /src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | org.slf4j.simpleLogger.logFile=System.out 2 | org.slf4j.simpleLogger.log.org.xnio=warn 3 | org.slf4j.simpleLogger.log.com.j256.ormlite.table.TableUtils=warn 4 | org.slf4j.simpleLogger.log.com.mchange.v2.log.MLog=warn 5 | -------------------------------------------------------------------------------- /src/main/resources/templates/session/tokenSubmitFailure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Matrix Token Verification 6 | 34 | 35 | 36 |
37 |

Verification failed: you may need to request another verification email

38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/templates/session/tokenSubmitSuccess.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Matrix Token Verification 6 | 34 | 35 | 36 |
37 |

Verification successful: return to your Matrix client to complete the process.

38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/threepids/sms/invite-template.txt: -------------------------------------------------------------------------------- 1 | You have been invited to a Matrix room by %SENDER_NAME_OR_ID%. Please get in touch with them for further instructions. -------------------------------------------------------------------------------- /src/main/resources/threepids/sms/unbind-fraudulent.txt: -------------------------------------------------------------------------------- 1 | INFORMATIONAL ONLY - Someone attempted to change your Matrix 3PIDs, with a potential data leak. Please contact your system administrator. -------------------------------------------------------------------------------- /src/main/resources/threepids/sms/validate-template.txt: -------------------------------------------------------------------------------- 1 | Your Matrix token is %VALIDATION_TOKEN% -------------------------------------------------------------------------------- /src/systemd/mxisd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=mxisd 3 | After=syslog.target 4 | 5 | [Service] 6 | User=mxisd 7 | ExecStart=/usr/bin/mxisd -c /etc/mxisd/mxisd.yaml 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /src/test/java/io/kamax/mxisd/test/MxisdDefaultTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.test; 22 | 23 | import io.kamax.matrix.ThreePidMedium; 24 | import io.kamax.mxisd.Mxisd; 25 | import io.kamax.mxisd.config.MxisdConfig; 26 | import org.junit.Test; 27 | 28 | import static junit.framework.TestCase.*; 29 | 30 | public class MxisdDefaultTest { 31 | 32 | private final String domain = "localhost"; 33 | 34 | @Test 35 | public void defaultConfig() { 36 | MxisdConfig cfg = MxisdConfig.forDomain(domain).inMemory(); 37 | Mxisd m = new Mxisd(cfg); 38 | m.start(); 39 | 40 | assertNotNull(m.getConfig()); 41 | assertEquals(domain, m.getConfig().getMatrix().getDomain()); 42 | 43 | assertTrue(m.getNotif().isMediumSupported(ThreePidMedium.Email.getId())); 44 | assertTrue(m.getNotif().isMediumSupported(ThreePidMedium.PhoneNumber.getId())); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/io/kamax/mxisd/test/crypto/KeyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.test.crypto; 22 | 23 | public class KeyTest { 24 | 25 | // As per https://matrix.org/docs/spec/appendices.html#signing-key 26 | public static final String Private = "YJDBA9Xnr2sVqXD9Vj7XVUnmFZcZrlw8Md7kMW+3XA1"; 27 | 28 | // The corresponding public key, not being documented in the spec 29 | public static final String Public = "XGX0JRS2Af3be3knz2fBiRbApjm2Dh61gXDJA8kcJNI"; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/io/kamax/mxisd/test/storage/OrmLiteSqlStorageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2018 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.test.storage; 22 | 23 | import io.kamax.mxisd.storage.ormlite.OrmLiteSqlStorage; 24 | import org.junit.Test; 25 | 26 | import java.time.Instant; 27 | 28 | public class OrmLiteSqlStorageTest { 29 | 30 | @Test 31 | public void insertAsTxnDuplicate() { 32 | OrmLiteSqlStorage store = new OrmLiteSqlStorage("sqlite", ":memory:"); 33 | store.insertTransactionResult("mxisd", "1", Instant.now(), "{}"); 34 | store.insertTransactionResult("mxisd", "2", Instant.now(), "{}"); 35 | } 36 | 37 | @Test(expected = RuntimeException.class) 38 | public void insertAsTxnSame() { 39 | OrmLiteSqlStorage store = new OrmLiteSqlStorage("sqlite", ":memory:"); 40 | store.insertTransactionResult("mxisd", "1", Instant.now(), "{}"); 41 | store.insertTransactionResult("mxisd", "1", Instant.now(), "{}"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/io/kamax/mxisd/test/storage/crypto/FileKeyStoreTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.test.storage.crypto; 22 | 23 | import io.kamax.mxisd.storage.crypto.FileKeyStore; 24 | import io.kamax.mxisd.storage.crypto.KeyStore; 25 | import org.apache.commons.io.FileUtils; 26 | 27 | import java.io.File; 28 | import java.io.IOException; 29 | import java.util.UUID; 30 | 31 | public class FileKeyStoreTest extends KeyStoreTest { 32 | 33 | @Override 34 | public KeyStore create() throws IOException { 35 | String path = FileUtils.getTempDirectoryPath() + 36 | "/mxisd-test-key-store-" + 37 | UUID.randomUUID().toString().replace("-", ""); 38 | FileUtils.forceDeleteOnExit(new File(path)); 39 | return new FileKeyStore(path); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/io/kamax/mxisd/test/storage/crypto/MemoryKeyStoreTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sàrl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.test.storage.crypto; 22 | 23 | import io.kamax.mxisd.storage.crypto.KeyStore; 24 | import io.kamax.mxisd.storage.crypto.MemoryKeyStore; 25 | 26 | public class MemoryKeyStoreTest extends KeyStoreTest { 27 | 28 | @Override 29 | public KeyStore create() { 30 | return new MemoryKeyStore(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/io/kamax/mxisd/test/util/RestClientUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * mxisd - Matrix Identity Server Daemon 3 | * Copyright (C) 2019 Kamax Sarl 4 | * 5 | * https://www.kamax.io/ 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License as 9 | * published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program 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 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.kamax.mxisd.test.util; 22 | 23 | import io.kamax.mxisd.util.RestClientUtils; 24 | import org.junit.Test; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | 28 | public class RestClientUtilsTest { 29 | 30 | @Test 31 | public void urlEncode() { 32 | String encoded = RestClientUtils.urlEncode("john+doe@example.org"); 33 | assertEquals("john%2Bdoe%40example.org", encoded); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/resources/store/exec/input/argsTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # mxisd - Matrix Identity Server Daemon 4 | # Copyright (C) 2018 Kamax Sarl 5 | # 6 | # https://www.kamax.io/ 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU Affero General Public License as 10 | # published by the Free Software Foundation, either version 3 of the 11 | # License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | 21 | if [ -n "$WITH_LOCALPART" ]; then 22 | [ -n "$1" ] || exit 10 23 | [ "$1" = "$REQ_LOCALPART" ] || exit 20 24 | shift 25 | fi 26 | 27 | if [ -n "$WITH_DOMAIN" ]; then 28 | [ -n "$1" ] || exit 11 29 | [ "$1" = "$REQ_DOMAIN" ] || exit 21 30 | shift 31 | fi 32 | 33 | if [ -n "$WITH_MXID" ]; then 34 | [ -n "$1" ] || exit 12 35 | [ "$1" = "$REQ_MXID" ] || exit 22 36 | shift 37 | fi 38 | 39 | [ "$1" = "$REQ_PASS" ] || exit 1 40 | 41 | exit 0 42 | -------------------------------------------------------------------------------- /src/test/resources/store/exec/input/envTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # mxisd - Matrix Identity Server Daemon 4 | # Copyright (C) 2018 Kamax Sarl 5 | # 6 | # https://www.kamax.io/ 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU Affero General Public License as 10 | # published by the Free Software Foundation, either version 3 of the 11 | # License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | 21 | if [ -n "$WITH_LOCALPART" ]; then 22 | [ -n "$LOCALPART" ] || exit 10 23 | [ "$LOCALPART" = "$REQ_LOCALPART" ] || exit 20 24 | fi 25 | 26 | if [ -n "$WITH_DOMAIN" ]; then 27 | [ -n "$DOMAIN" ] || exit 11 28 | [ "$DOMAIN" = "$REQ_DOMAIN" ] || exit 21 29 | fi 30 | 31 | if [ -n "$WITH_MXID" ]; then 32 | [ -n "$MXID" ] || exit 12 33 | [ "$MXID" = "$REQ_MXID" ] || exit 22 34 | fi 35 | 36 | [ "$PASS" = "$REQ_PASS" ] || exit 1 37 | 38 | exit 0 39 | -------------------------------------------------------------------------------- /src/test/resources/store/exec/input/multilinesTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # mxisd - Matrix Identity Server Daemon 4 | # Copyright (C) 2018 Kamax Sarl 5 | # 6 | # https://www.kamax.io/ 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU Affero General Public License as 10 | # published by the Free Software Foundation, either version 3 of the 11 | # License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | 21 | if [ -n "$WITH_LOCALPART" ]; then 22 | read LOCALPART 23 | [ -n "$LOCALPART" ] || exit 10 24 | [ "$LOCALPART" = "$REQ_LOCALPART" ] || exit 20 25 | fi 26 | 27 | if [ -n "$WITH_DOMAIN" ]; then 28 | read DOMAIN 29 | [ -n "$DOMAIN" ] || exit 11 30 | [ "$DOMAIN" = "$REQ_DOMAIN" ] || exit 21 31 | fi 32 | 33 | if [ -n "$WITH_MXID" ]; then 34 | read MXID 35 | [ -n "$MXID" ] || exit 12 36 | [ "$MXID" = "$REQ_MXID" ] || exit 22 37 | fi 38 | 39 | read PASS 40 | [ "$PASS" = "$REQ_PASS" ] || exit 1 41 | 42 | exit 0 43 | --------------------------------------------------------------------------------