Skip to content

Commit

Permalink
prepare for OF 4.8. may not build
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Nov 14, 2023
1 parent e4fe02d commit 628dfd5
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 171 deletions.
8 changes: 4 additions & 4 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ call mvn clean package -Dmaven.test.skip=true

cd target
rename pade-openfire-plugin-assembly.jar pade.jar
rd "D:\Openfire\openfire_4_7_4\plugins\pade" /q /s
del "D:\Openfire\openfire_4_7_4\plugins\pade.jar"
del /q "D:\Openfire\openfire_4_7_4\logs\*.*"
copy pade.jar D:\Openfire\openfire_4_7_4\plugins\pade.jar
rd "D:\Openfire\openfire_4_8_0\plugins\pade" /q /s
del "D:\Openfire\openfire_4_8_0\plugins\pade.jar"
del /q "D:\Openfire\openfire_4_8_0\logs\*.*"
copy pade.jar D:\Openfire\openfire_4_8_0\plugins\pade.jar

rd "D:\Projects\openfire-cluster\node1\plugins\pade" /q /s
del "D:\Projects\openfire-cluster\node1\plugins\pade.jar"
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>${project.description}</description>
<author>Ignite Realtime</author>
<version>${project.version}</version>
<date>30/06/2024</date>
<date>2024-06-30</date>
<minServerVersion>4.8.0</minServerVersion>

<adminconsole>
Expand Down
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.7.0</version>
<version>4.8.0-SNAPSHOT</version>
</parent>

<groupId>org.igniterealtime.openfire</groupId>
Expand Down Expand Up @@ -290,7 +290,7 @@
<dependency>
<groupId>org.eclipse.jetty.fcgi</groupId>
<artifactId>fcgi-server</artifactId>
<version>9.4.12.v20180830</version>
<version>10.0.17</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.j256.two-factor-auth/two-factor-auth -->
Expand Down Expand Up @@ -396,7 +396,6 @@
<version>3.0-24-g34c2ce5</version>
</dependency>


<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
Expand All @@ -407,8 +406,14 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.4.35.v20201120</version>
<version>10.0.17</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-client</artifactId>
<version>10.0.17</version>
</dependency>

<dependency>
<groupId>com.yubico</groupId>
Expand Down
15 changes: 7 additions & 8 deletions src/java/org/ifsoft/download/Servlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ private void writeHeader(String urlString, HttpServletResponse response)
response.setHeader("Content-Type", "text/html");

response.setHeader("Connection", "close");

HttpBindManager boshManager = HttpBindManager.getInstance();

response.setHeader("Access-Control-Allow-Origin", boshManager.getCORSAllowOrigin());
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT + ", Authorization");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);


HttpBindManager boshManager = HttpBindManager.getInstance();
response.setHeader("Access-Control-Allow-Methods", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getValue()));
response.setHeader("Access-Control-Allow-Headers", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getValue() + ", Authorization"));
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getValue().toSeconds()));
response.setHeader("Access-Control-Allow-Origin", String.valueOf(HttpBindManager.HTTP_BIND_ALLOWED_ORIGINS.getDefaultValue()));
response.setHeader("Access-Control-Allow-Credentials", "true");
}
catch(Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/ifsoft/meet/MeetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public static String sendEmailMessage(String toName, String toEmail, String from
message.setRecipient(Message.RecipientType.TO, to);
message.setFrom(from);
message.setReplyTo(new javax.mail.Address[]{from});
message.setSubject(StringUtils.replace(subject, "\n", ""), encoding);
message.setSubject(StringUtils.replace(subject, "\n", "", new int[2]), encoding);

if (textBody != null && htmlBody != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/ifsoft/mta/MtaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private Connector createSSLConnector( final Server mtaServer ) {
httpsConfig.setSendDateHeader(false);
httpsConfig.addCustomizer(new SecureRequestCustomizer());

final SslContextFactory sslContextFactory = new SslContextFactory();
final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.addExcludeProtocols("SSLv3");
sslContextFactory.setEndpointIdentificationAlgorithm(null);
sslContextFactory.setTrustStorePath(c2sTrustStoreLocation);
Expand Down
12 changes: 6 additions & 6 deletions src/java/org/ifsoft/sso/Password.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ private void writeHeader(HttpServletResponse response)
response.setHeader("Pragma", "no-cache");
response.setHeader("Content-Type", "application/javascript");
response.setHeader("Connection", "close");

HttpBindManager boshManager = HttpBindManager.getInstance();

response.setHeader("Access-Control-Allow-Origin", boshManager.getCORSAllowOrigin());
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT + ", Authorization");

HttpBindManager boshManager = HttpBindManager.getInstance();
response.setHeader("Access-Control-Allow-Methods", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getValue()));
response.setHeader("Access-Control-Allow-Headers", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getValue() + ", Authorization"));
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getValue().toSeconds()));
response.setHeader("Access-Control-Allow-Origin", String.valueOf(HttpBindManager.HTTP_BIND_ALLOWED_ORIGINS.getDefaultValue()));
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
}
}
14 changes: 7 additions & 7 deletions src/java/org/ifsoft/sso/SmartIdCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ private void writeHeader(HttpServletResponse response)
response.setHeader("Pragma", "no-cache");
response.setHeader("Content-Type", "application/javascript");
response.setHeader("Connection", "close");

HttpBindManager boshManager = HttpBindManager.getInstance();

response.setHeader("Access-Control-Allow-Origin", boshManager.getCORSAllowOrigin());
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT + ", Authorization");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
HttpBindManager boshManager = HttpBindManager.getInstance();
response.setHeader("Access-Control-Allow-Methods", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getValue()));
response.setHeader("Access-Control-Allow-Headers", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getValue() + ", Authorization"));
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getValue().toSeconds()));
response.setHeader("Access-Control-Allow-Origin", String.valueOf(HttpBindManager.HTTP_BIND_ALLOWED_ORIGINS.getDefaultValue()));
response.setHeader("Access-Control-Allow-Credentials", "true");
}

public String get(String url) throws ClientProtocolException, IOException
Expand Down
12 changes: 6 additions & 6 deletions src/java/org/ifsoft/sso/SmartIdCardCert.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ private void writeHeader(HttpServletResponse response)
response.setHeader("Content-Type", "application/javascript");
response.setHeader("Connection", "close");

HttpBindManager boshManager = HttpBindManager.getInstance();

response.setHeader("Access-Control-Allow-Origin", boshManager.getCORSAllowOrigin());
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT + ", Authorization");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
HttpBindManager boshManager = HttpBindManager.getInstance();
response.setHeader("Access-Control-Allow-Methods", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getValue()));
response.setHeader("Access-Control-Allow-Headers", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getValue() + ", Authorization"));
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getValue().toSeconds()));
response.setHeader("Access-Control-Allow-Origin", String.valueOf(HttpBindManager.HTTP_BIND_ALLOWED_ORIGINS.getDefaultValue()));
response.setHeader("Access-Control-Allow-Credentials", "true");
}

}
10 changes: 5 additions & 5 deletions src/java/org/ifsoft/sso/WellKnownHostMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ private void writeHeader(HttpServletResponse response)
response.setHeader("Content-Type", "application/javascript");
response.setHeader("Connection", "close");

HttpBindManager boshManager = HttpBindManager.getInstance();

response.setHeader("Access-Control-Allow-Origin", boshManager.getCORSAllowOrigin());
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT + ", Authorization");
HttpBindManager boshManager = HttpBindManager.getInstance();
response.setHeader("Access-Control-Allow-Methods", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getValue()));
response.setHeader("Access-Control-Allow-Headers", String.join(",", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getValue() + ", Authorization"));
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getValue().toSeconds()));
response.setHeader("Access-Control-Allow-Origin", String.valueOf(HttpBindManager.HTTP_BIND_ALLOWED_ORIGINS.getDefaultValue()));
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
}
}
5 changes: 0 additions & 5 deletions src/java/org/ifsoft/websockets/LiveStreamSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
Expand Down
12 changes: 5 additions & 7 deletions src/java/org/ifsoft/websockets/ProxyConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
import java.security.cert.X509Certificate;
import java.util.*;
import java.util.concurrent.*;
import java.time.Duration;
import javax.net.*;
import javax.net.ssl.*;
import javax.security.auth.callback.*;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
Expand Down Expand Up @@ -53,7 +52,6 @@ public ProxyConnection(URI uri, List<String> subprotocol, int connectTimeout)
{
Log.debug("ProxyConnection " + uri + " " + subprotocol);

final SslContextFactory clientSslContextFactory = SslContextFactoryProvider.getClientSslContextFactory();
if("wss".equals(uri.getScheme()))
{
Log.debug("ProxyConnection - SSL");
Expand All @@ -62,7 +60,7 @@ public ProxyConnection(URI uri, List<String> subprotocol, int connectTimeout)
}
else isSecure = false;

httpClient = new HttpClient(new HttpClientTransportOverHTTP(1),clientSslContextFactory);
httpClient = new HttpClient();
final QueuedThreadPool queuedThreadPool = QueuedThreadPoolProvider.getQueuedThreadPool("ProxyConnection-HttpClient");
httpClient.setExecutor(queuedThreadPool);
httpClient.setConnectTimeout(connectTimeout);
Expand All @@ -71,10 +69,10 @@ public ProxyConnection(URI uri, List<String> subprotocol, int connectTimeout)
{
httpClient.start();
wsClient = new WebSocketClient(httpClient);
wsClient.setIdleTimeout(Duration.ofMinutes(5));
wsClient.start();

final ClientUpgradeRequest request = new ClientUpgradeRequest();
request.setRequestURI​(uri);
final ClientUpgradeRequest request = new ClientUpgradeRequest(uri);
if (subprotocol != null) request.setSubProtocols(subprotocol);

proxySocket = new ProxySocket(this);
Expand Down Expand Up @@ -245,7 +243,7 @@ public void deliver(String text)
{
try {
Log.debug("ProxySocket deliver: \n" + text);
session.getRemote().sendStringByFuture(text);
session.getRemote().sendString(text);
lastMessage = null;
} catch (Exception e) {
Log.error("ProxySocket deliver", e);
Expand Down
7 changes: 1 addition & 6 deletions src/java/org/ifsoft/websockets/ProxyWebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
Expand Down Expand Up @@ -95,7 +90,7 @@ public void deliver(String message)
{
try {
Log.debug(" : Delivered : \n" + message );
wsSession.getRemote().sendStringByFuture(message);
wsSession.getRemote().sendString(message);
} catch (Exception e) {
Log.error("ProxyWebSocket deliver " + e);
Log.warn("Could not deliver : \n" + message );
Expand Down
53 changes: 23 additions & 30 deletions src/java/org/jivesoftware/openfire/plugin/ofmeet/OfMeetPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import org.eclipse.jetty.servlet.*;
import org.eclipse.jetty.websocket.servlet.*;
import org.eclipse.jetty.websocket.server.*;
import org.eclipse.jetty.websocket.server.pathmap.ServletPathSpec;
import org.eclipse.jetty.websocket.server.config.*;
import org.eclipse.jetty.http.pathmap.ServletPathSpec;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -398,18 +399,15 @@ public void destroyPlugin()
protected void loadPublicWebApp() throws Exception
{
Log.info( "Initializing public web application for /colibri-ws web socket" );

jvbWsContext = new ServletContextHandler(null, "/colibri-ws", ServletContextHandler.SESSIONS);

try {
WebSocketUpgradeFilter wsfilter = WebSocketUpgradeFilter.configureContext(jvbWsContext);
wsfilter.getFactory().getPolicy().setIdleTimeout(60 * 60 * 1000);
wsfilter.getFactory().getPolicy().setMaxTextMessageSize(64000000);
wsfilter.addMapping(new ServletPathSpec("/*"), new JvbSocketCreator());

} catch (Exception e) {
Log.error("loadPublicWebApp", e);
}

JettyWebSocketServlet websocketServlet = new JettyWebSocketServlet() {
@Override protected void configure(JettyWebSocketServletFactory factory) {
factory.addMapping("/*", (req, res) -> new JvbSocketCreator());
}
};
jvbWsContext = new ServletContextHandler();
jvbWsContext.addServlet(new ServletHolder(websocketServlet), "/colibri-ws");
JettyWebSocketServletContainerInitializer.configure(jvbWsContext, (JettyWebSocketServletContainerInitializer.Configurator) null);

HttpBindManager.getInstance().addJettyHandler(jvbWsContext);

Expand All @@ -427,9 +425,9 @@ protected void loadPublicWebApp() throws Exception
}


public static class JvbSocketCreator implements WebSocketCreator
public static class JvbSocketCreator implements JettyWebSocketCreator
{
@Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
@Override public Object createWebSocket(JettyServerUpgradeRequest req, JettyServerUpgradeResponse resp)
{
String ipaddr = JiveGlobals.getProperty( "ofmeet.videobridge.rest.host", OfMeetPlugin.self.getIpAddress());
String jvbPort = JiveGlobals.getProperty( "ofmeet.websockets.plainport", "8180");
Expand Down Expand Up @@ -822,19 +820,14 @@ private void setupFFMPEG(File pluginDirectory)

private void startFFMPEG(String path)
{
streamWsContext = new ServletContextHandler(null, "/livestream-ws", ServletContextHandler.SESSIONS);

try {
WebSocketUpgradeFilter wsfilter2 = WebSocketUpgradeFilter.configureContext(streamWsContext);
wsfilter2.getFactory().getPolicy().setIdleTimeout(60 * 60 * 1000);
wsfilter2.getFactory().getPolicy().setMaxTextMessageSize(64000000);
wsfilter2.getFactory().getPolicy().setMaxBinaryMessageSize(64000000);

wsfilter2.addMapping(new ServletPathSpec("/*"), new StreamSocketCreator());

} catch (Exception e) {
Log.error("loadPublicWebApp", e);
}
JettyWebSocketServlet websocketServlet = new JettyWebSocketServlet() {
@Override protected void configure(JettyWebSocketServletFactory factory) {
factory.addMapping("/*", (req, res) -> new StreamSocketCreator());
}
};
streamWsContext = new ServletContextHandler();
streamWsContext.addServlet(new ServletHolder(websocketServlet), "/livestream-ws");
JettyWebSocketServletContainerInitializer.configure(streamWsContext, (JettyWebSocketServletContainerInitializer.Configurator) null);

try {
String ffmpegName = null;
Expand Down Expand Up @@ -867,9 +860,9 @@ private void extractFile(ZipInputStream zipIn, String filePath) throws IOExcepti
bos.close();
}

public static class StreamSocketCreator implements WebSocketCreator
public static class StreamSocketCreator implements JettyWebSocketCreator
{
@Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
@Override public Object createWebSocket(JettyServerUpgradeRequest req, JettyServerUpgradeResponse resp)
{
String streamKey = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,26 @@ protected static void serve( HttpServletResponse response, URL url ) throws IOEx
{
final URLConnection urlConnection = url.openConnection();
response.setContentLength( urlConnection.getContentLength() );
response.setContentType( urlConnection.getContentType() );
String contentType = urlConnection.getContentType();

if (contentType != null && contentType.toLowerCase().startsWith("image")) {
response.setContentType( contentType );

try ( final InputStream input = urlConnection.getInputStream();
final OutputStream output = response.getOutputStream() )
{
final byte[] buffer = new byte[ 1024 ];
int bytesRead;
while ( ( bytesRead = input.read( buffer ) ) != -1 )
{
output.write( buffer, 0, bytesRead );
}
}
try ( final InputStream input = urlConnection.getInputStream();
final OutputStream output = response.getOutputStream() )
{
final byte[] buffer = new byte[ 1024 ];
int bytesRead;

while ( ( bytesRead = input.read( buffer ) ) != -1 )
{
output.write( buffer, 0, bytesRead );
}
}
} else {
Log.warn( "Unable to serve the URL '{}' as proxied content.", url);
response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
}
}
catch ( IOException e )
{
Expand Down
Loading

0 comments on commit 628dfd5

Please sign in to comment.