This is an automated email from the ASF dual-hosted git repository. ralaoui pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mina-vysper.git
The following commit(s) were added to refs/heads/master by this push: new db6bfe2 Remove Spring specific code db6bfe2 is described below commit db6bfe269be1e97e0582daa59ad89c726557c303 Author: Réda Housni Alaoui <reda.housniala...@gmail.com> AuthorDate: Mon Aug 26 00:31:11 2019 +0200 Remove Spring specific code --- .../org/apache/vysper/spring/AddUserHelper.java | 64 ------------- .../spring/ResourceBasedTLSContextFactory.java | 46 ---------- .../java/org/apache/vysper/spring/ServerMain.java | 42 --------- ...pringCompatibleDefaultServerRuntimeContext.java | 81 ----------------- .../vysper/spring/SpringCompatibleXMPPServer.java | 100 --------------------- 5 files changed, 333 deletions(-) diff --git a/server/core/src/main/java/org/apache/vysper/spring/AddUserHelper.java b/server/core/src/main/java/org/apache/vysper/spring/AddUserHelper.java deleted file mode 100644 index 9fec2ef..0000000 --- a/server/core/src/main/java/org/apache/vysper/spring/AddUserHelper.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.vysper.spring; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang.RandomStringUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.vysper.storage.StorageProviderRegistry; -import org.apache.vysper.xmpp.addressing.Entity; -import org.apache.vysper.xmpp.addressing.EntityFormatException; -import org.apache.vysper.xmpp.addressing.EntityImpl; -import org.apache.vysper.xmpp.authentication.AccountCreationException; -import org.apache.vysper.xmpp.authentication.AccountManagement; - -/** - * helper to inject user accounts on spring context creation - */ -public class AddUserHelper { - - private final Map<String, String> userPasswordMap = new HashMap<String, String>(); - - public AddUserHelper(Map<String, String> userPasswordMap) { - this.userPasswordMap.putAll(userPasswordMap); - } - - public void setStorageProviderRegistry(StorageProviderRegistry storageProviderRegistry) - throws AccountCreationException, EntityFormatException { - AccountManagement accountManagement = (AccountManagement) storageProviderRegistry - .retrieve(AccountManagement.class); - if (accountManagement == null) - throw new IllegalStateException("no account manager accessible."); - - for (String user : userPasswordMap.keySet()) { - Entity entity = EntityImpl.parse(user); - if (!accountManagement.verifyAccountExists(entity)) { - String password = userPasswordMap.get(user); - if (StringUtils.isEmpty(password)) { - password = RandomStringUtils.randomAlphanumeric(8); - System.out.println(user + " user will be added with random password: '" + password + "'"); - } - accountManagement.addUser(entity, password); - } - } - } -} diff --git a/server/core/src/main/java/org/apache/vysper/spring/ResourceBasedTLSContextFactory.java b/server/core/src/main/java/org/apache/vysper/spring/ResourceBasedTLSContextFactory.java deleted file mode 100644 index 5774f01..0000000 --- a/server/core/src/main/java/org/apache/vysper/spring/ResourceBasedTLSContextFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.vysper.spring; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.vysper.xmpp.cryptography.AbstractTLSContextFactory; -import org.springframework.core.io.Resource; - -/** - * helper factory class to make certificates available to MINA with Spring - * resource injection. - * - * @author The Apache MINA Project (d...@mina.apache.org) - */ -public class ResourceBasedTLSContextFactory extends AbstractTLSContextFactory { - - private Resource certificateResource = null; - - public ResourceBasedTLSContextFactory(Resource certificateResource) { - this.certificateResource = certificateResource; - } - - @Override - protected InputStream getCertificateInputStream() throws IOException { - return certificateResource.getInputStream(); - } -} diff --git a/server/core/src/main/java/org/apache/vysper/spring/ServerMain.java b/server/core/src/main/java/org/apache/vysper/spring/ServerMain.java deleted file mode 100644 index 62bf67d..0000000 --- a/server/core/src/main/java/org/apache/vysper/spring/ServerMain.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.vysper.spring; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * starts the server as a standalone application using a Spring configuration - * - * @author The Apache MINA Project (d...@mina.apache.org) - */ -public class ServerMain { - - /** - * boots the server as a standalone application according to the spring-config.xml file - * found on the classpath - * @param args - */ - public static void main(String[] args) { - - new ClassPathXmlApplicationContext("spring-config.xml"); - - System.out.println("vysper server is running (using spring framework)..."); - } -} diff --git a/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java b/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java deleted file mode 100644 index 86ddac2..0000000 --- a/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.vysper.spring; - -import java.util.List; - -import org.apache.vysper.xmpp.addressing.Entity; -import org.apache.vysper.xmpp.delivery.StanzaRelay; -import org.apache.vysper.xmpp.delivery.failure.DeliveryException; -import org.apache.vysper.xmpp.delivery.failure.DeliveryFailureStrategy; -import org.apache.vysper.xmpp.delivery.failure.ServiceNotAvailableException; -import org.apache.vysper.xmpp.modules.Module; -import org.apache.vysper.xmpp.protocol.HandlerDictionary; -import org.apache.vysper.xmpp.protocol.StanzaProcessor; -import org.apache.vysper.xmpp.server.AlterableComponentRegistry; -import org.apache.vysper.xmpp.server.DefaultServerRuntimeContext; -import org.apache.vysper.xmpp.server.ServerFeatures; -import org.apache.vysper.xmpp.stanza.Stanza; -import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry; - -/** - */ -public class SpringCompatibleDefaultServerRuntimeContext extends DefaultServerRuntimeContext { - - private static class StanzaRelayHull implements StanzaRelay { - - protected StanzaRelay stanzaRelay; - - public void setStanzaRelay(StanzaRelay stanzaRelay) { - this.stanzaRelay = stanzaRelay; - } - - public void relay(Entity receiver, Stanza stanza, DeliveryFailureStrategy deliveryFailureStrategy) - throws DeliveryException { - if (!isRelaying()) { - throw new ServiceNotAvailableException("relay is not relaying"); - } - stanzaRelay.relay(receiver, stanza, deliveryFailureStrategy); - } - - public boolean isRelaying() { - return stanzaRelay.isRelaying(); - } - - public void stop() { - stanzaRelay.stop(); - } - } - - public SpringCompatibleDefaultServerRuntimeContext(Entity serverEntity, ServerFeatures serverFeatures, - List<HandlerDictionary> dictionaries, ResourceRegistry resourceRegistry, - StanzaProcessor stanzaProcessor, - AlterableComponentRegistry componentRegistry) { - super(serverEntity, new StanzaRelayHull(), stanzaProcessor, componentRegistry, resourceRegistry, serverFeatures, dictionaries); - } - - public void setStanzaRelay(StanzaRelay stanzaRelay) { - ((StanzaRelayHull) getStanzaRelay()).setStanzaRelay(stanzaRelay); - } - - public void setModules(List<Module> modules) { - super.addModules(modules); - } -} diff --git a/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleXMPPServer.java b/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleXMPPServer.java deleted file mode 100644 index a05ed1e..0000000 --- a/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleXMPPServer.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.vysper.spring; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.vysper.xmpp.modules.Module; -import org.apache.vysper.xmpp.server.Endpoint; -import org.apache.vysper.xmpp.server.ServerFeatures; -import org.apache.vysper.xmpp.server.XMPPServer; -import org.springframework.core.io.Resource; - -/** - * this class is able to boot a standalone XMPP server in a spring context. - * See the example spring-context.xml for details - * - * @author The Apache MINA Project (d...@mina.apache.org) - */ -public class SpringCompatibleXMPPServer extends XMPPServer { - - protected final List<Module> listOfModules = new ArrayList<Module>(); - protected File certificateFile = null; - protected String certificatePassword = null; - - protected boolean enableFederationFeature = false; - protected boolean disableFederationServerCertificateChecks = false; - - public SpringCompatibleXMPPServer(String domain) { - super(domain); - } - - public void setCertificateFile(Resource certificateFile) throws IOException { - this.certificateFile = certificateFile.getFile(); - } - - public void setCertificatePassword(String certificatePassword) { - this.certificatePassword = certificatePassword; - } - - public void setEndpoints(Collection<Endpoint> endpoints) { - for (Endpoint endpoint : endpoints) { - addEndpoint(endpoint); - } - } - - public void setModules(Collection<Module> modules) { - listOfModules.addAll(modules); - } - - public void setEnableFederationFeature(boolean enableFederationFeature) { - this.enableFederationFeature = enableFederationFeature; - } - - public void setDisableFederationServerCertificateChecks(boolean disable) { - this.disableFederationServerCertificateChecks = disable; - } - - @Override - protected ServerFeatures createServerFeatures() { - final ServerFeatures serverFeatures = super.createServerFeatures(); - serverFeatures.setRelayingToFederationServers(enableFederationFeature); - serverFeatures.setCheckFederationServerCertificates(!disableFederationServerCertificateChecks); - return serverFeatures; - } - - public void init() throws Exception { - setTLSCertificateInfo(certificateFile, certificatePassword); - start(); - if (listOfModules != null) { - for (Module module : listOfModules) { - addModule(module); - } - } - } - - public void destroy() { - stop(); - } -}