You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2010/12/01 09:27:01 UTC
svn commit: r1040889 - in
/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp:
cryptography/InputStreamBasedTLSContextFactory.java server/ServerMain.java
server/XMPPServer.java
Author: ngn
Date: Wed Dec 1 08:27:01 2010
New Revision: 1040889
URL: http://svn.apache.org/viewvc?rev=1040889&view=rev
Log:
Adding support for providing the certificate as InputStream, in addition to File (VYSPER-255)
Added:
mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/cryptography/InputStreamBasedTLSContextFactory.java
Modified:
mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerMain.java
mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
Added: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/cryptography/InputStreamBasedTLSContextFactory.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/cryptography/InputStreamBasedTLSContextFactory.java?rev=1040889&view=auto
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/cryptography/InputStreamBasedTLSContextFactory.java (added)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/cryptography/InputStreamBasedTLSContextFactory.java Wed Dec 1 08:27:01 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.xmpp.cryptography;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ */
+public class InputStreamBasedTLSContextFactory extends AbstractTLSContextFactory {
+ private InputStream in;
+
+ public InputStreamBasedTLSContextFactory(InputStream in) {
+ this.in = in;
+ }
+
+ @Override
+ protected InputStream getCertificateInputStream() throws IOException {
+ return in;
+ }
+}
Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerMain.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerMain.java?rev=1040889&r1=1040888&r2=1040889&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerMain.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerMain.java Wed Dec 1 08:27:01 2010
@@ -20,6 +20,7 @@
package org.apache.vysper.xmpp.server;
import java.io.File;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
@@ -53,7 +54,7 @@ public class ServerMain {
*
* @param args
*/
- public static void main(String[] args) throws AccountCreationException, EntityFormatException {
+ public static void main(String[] args) throws AccountCreationException, EntityFormatException, FileNotFoundException {
String addedModuleProperty = System.getProperty("vysper.add.module");
List<Module> listOfModules = null;
Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java?rev=1040889&r1=1040888&r2=1040889&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java Wed Dec 1 08:27:01 2010
@@ -20,6 +20,9 @@
package org.apache.vysper.xmpp.server;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -30,6 +33,7 @@ import org.apache.vysper.xmpp.authorizat
import org.apache.vysper.xmpp.authorization.SASLMechanism;
import org.apache.vysper.xmpp.cryptography.BogusTrustManagerFactory;
import org.apache.vysper.xmpp.cryptography.FileBasedTLSContextFactory;
+import org.apache.vysper.xmpp.cryptography.InputStreamBasedTLSContextFactory;
import org.apache.vysper.xmpp.delivery.RecordingStanzaRelay;
import org.apache.vysper.xmpp.delivery.StanzaRelayBroker;
import org.apache.vysper.xmpp.delivery.inbound.DeliveringInboundStanzaRelay;
@@ -63,7 +67,7 @@ public class XMPPServer {
private StorageProviderRegistry storageProviderRegistry;
- private File tlsCertificateFile;
+ private InputStream tlsCertificate;
private String tlsCertificatePassword;
@@ -84,8 +88,13 @@ public class XMPPServer {
this.storageProviderRegistry = storageProviderRegistry;
}
- public void setTLSCertificateInfo(File certificate, String password) {
- tlsCertificateFile = certificate;
+ public void setTLSCertificateInfo(File certificate, String password) throws FileNotFoundException {
+ tlsCertificate = new FileInputStream(certificate);
+ tlsCertificatePassword = password;
+ }
+
+ public void setTLSCertificateInfo(InputStream certificate, String password) {
+ tlsCertificate = certificate;
tlsCertificatePassword = password;
}
@@ -96,7 +105,7 @@ public class XMPPServer {
public void start() throws Exception {
BogusTrustManagerFactory bogusTrustManagerFactory = new BogusTrustManagerFactory();
- FileBasedTLSContextFactory tlsContextFactory = new FileBasedTLSContextFactory(tlsCertificateFile);
+ InputStreamBasedTLSContextFactory tlsContextFactory = new InputStreamBasedTLSContextFactory(tlsCertificate);
tlsContextFactory.setPassword(tlsCertificatePassword);
tlsContextFactory.setTrustManagerFactory(bogusTrustManagerFactory);