From fa0f03eec963a2e341b58ea056ba248ff64ab75d Mon Sep 17 00:00:00 2001 From: Dele Olajide Date: Thu, 23 Nov 2023 21:07:29 +0000 Subject: [PATCH] Revert OF 4.8.0 changes. Stay at OF 4.7.5 for now. --- build.cmd | 8 +- changelog.html | 2 +- plugin.xml | 7 +- pom.xml | 17 +-- src/java/org/ifsoft/download/Servlet.java | 15 +- src/java/org/ifsoft/meet/MeetService.java | 2 +- src/java/org/ifsoft/mta/MtaManager.java | 2 +- src/java/org/ifsoft/sso/Password.java | 12 +- src/java/org/ifsoft/sso/SmartIdCard.java | 14 +- src/java/org/ifsoft/sso/SmartIdCardCert.java | 12 +- .../org/ifsoft/sso/WellKnownHostMeta.java | 10 +- .../ifsoft/websockets/LiveStreamSocket.java | 5 + .../ifsoft/websockets/ProxyConnection.java | 12 +- .../org/ifsoft/websockets/ProxyWebSocket.java | 7 +- .../openfire/plugin/ofmeet/OfMeetPlugin.java | 53 ++++--- .../plugin/ofmeet/WatermarkFilter.java | 30 ++-- .../rest/controller/GroupController.java | 4 - .../UserServiceLegacyController.java | 33 ++--- .../openfire/plugins/pade/PadePlugin.java | 131 ++++++++---------- 19 files changed, 177 insertions(+), 199 deletions(-) diff --git a/build.cmd b/build.cmd index 425b0b98..1573bee7 100644 --- a/build.cmd +++ b/build.cmd @@ -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_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:\Openfire\openfire_4_7_5\plugins\pade" /q /s +del "D:\Openfire\openfire_4_7_5\plugins\pade.jar" +del /q "D:\Openfire\openfire_4_7_5\logs\*.*" +copy pade.jar D:\Openfire\openfire_4_7_5\plugins\pade.jar rd "D:\Projects\openfire-cluster\node1\plugins\pade" /q /s del "D:\Projects\openfire-cluster\node1\plugins\pade.jar" diff --git a/changelog.html b/changelog.html index 6a85ae3e..207e0381 100644 --- a/changelog.html +++ b/changelog.html @@ -44,7 +44,7 @@

Pade Changelog

-

2.0.0 -- June 30, 2024

+

1.7.9 -- December 31, 2023

diff --git a/plugin.xml b/plugin.xml index 295ef243..7c549832 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,9 +5,10 @@ ${project.description} Ignite Realtime ${project.version} - 2024-06-30 - 4.8.0 - + 08/10/2023 + 4.8.0 + 4.7.0 + 1.8 diff --git a/pom.xml b/pom.xml index fa3ae4a1..2bc788ca 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ plugins org.igniterealtime.openfire - 4.8.0-SNAPSHOT + 4.7.0 org.igniterealtime.openfire pade - 2.0.0-SNAPSHOT + 1.7.9-SNAPSHOT Pade Web-based chat, groupchat, telephones, audio and video conferencing solution using ConverseJS, Jitsi and FreeSWITCH @@ -290,7 +290,7 @@ org.eclipse.jetty.fcgi fcgi-server - 10.0.17 + 9.4.12.v20180830 @@ -309,7 +309,7 @@ org.json json - 20231013 + 20230227 @@ -396,6 +396,7 @@ 3.0-24-g34c2ce5 + org.jboss.netty netty @@ -406,14 +407,8 @@ org.eclipse.jetty jetty-util - 10.0.17 + 9.4.35.v20201120 - - - org.eclipse.jetty.websocket - websocket-jetty-client - 10.0.17 - com.yubico diff --git a/src/java/org/ifsoft/download/Servlet.java b/src/java/org/ifsoft/download/Servlet.java index 9600eee8..e15b4172 100644 --- a/src/java/org/ifsoft/download/Servlet.java +++ b/src/java/org/ifsoft/download/Servlet.java @@ -62,13 +62,14 @@ 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-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"); + + 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); + } catch(Exception e) { diff --git a/src/java/org/ifsoft/meet/MeetService.java b/src/java/org/ifsoft/meet/MeetService.java index 8203ac9b..aa2bc1c8 100644 --- a/src/java/org/ifsoft/meet/MeetService.java +++ b/src/java/org/ifsoft/meet/MeetService.java @@ -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", "", new int[2]), encoding); + message.setSubject(StringUtils.replace(subject, "\n", ""), encoding); if (textBody != null && htmlBody != null) { diff --git a/src/java/org/ifsoft/mta/MtaManager.java b/src/java/org/ifsoft/mta/MtaManager.java index 3e6f3fc4..59827ddc 100644 --- a/src/java/org/ifsoft/mta/MtaManager.java +++ b/src/java/org/ifsoft/mta/MtaManager.java @@ -171,7 +171,7 @@ private Connector createSSLConnector( final Server mtaServer ) { httpsConfig.setSendDateHeader(false); httpsConfig.addCustomizer(new SecureRequestCustomizer()); - final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); + final SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.addExcludeProtocols("SSLv3"); sslContextFactory.setEndpointIdentificationAlgorithm(null); sslContextFactory.setTrustStorePath(c2sTrustStoreLocation); diff --git a/src/java/org/ifsoft/sso/Password.java b/src/java/org/ifsoft/sso/Password.java index 0126c672..2dc68868 100644 --- a/src/java/org/ifsoft/sso/Password.java +++ b/src/java/org/ifsoft/sso/Password.java @@ -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-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())); + + 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); } } diff --git a/src/java/org/ifsoft/sso/SmartIdCard.java b/src/java/org/ifsoft/sso/SmartIdCard.java index d833c665..a56e6fed 100644 --- a/src/java/org/ifsoft/sso/SmartIdCard.java +++ b/src/java/org/ifsoft/sso/SmartIdCard.java @@ -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-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"); + + 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); } public String get(String url) throws ClientProtocolException, IOException diff --git a/src/java/org/ifsoft/sso/SmartIdCardCert.java b/src/java/org/ifsoft/sso/SmartIdCardCert.java index c6295a4c..639c7bd0 100644 --- a/src/java/org/ifsoft/sso/SmartIdCardCert.java +++ b/src/java/org/ifsoft/sso/SmartIdCardCert.java @@ -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-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"); + 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); } } diff --git a/src/java/org/ifsoft/sso/WellKnownHostMeta.java b/src/java/org/ifsoft/sso/WellKnownHostMeta.java index b402becb..2eea8dab 100644 --- a/src/java/org/ifsoft/sso/WellKnownHostMeta.java +++ b/src/java/org/ifsoft/sso/WellKnownHostMeta.java @@ -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-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())); + 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); } } diff --git a/src/java/org/ifsoft/websockets/LiveStreamSocket.java b/src/java/org/ifsoft/websockets/LiveStreamSocket.java index d637981e..794eb443 100644 --- a/src/java/org/ifsoft/websockets/LiveStreamSocket.java +++ b/src/java/org/ifsoft/websockets/LiveStreamSocket.java @@ -15,6 +15,11 @@ 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; diff --git a/src/java/org/ifsoft/websockets/ProxyConnection.java b/src/java/org/ifsoft/websockets/ProxyConnection.java index f5e4af62..89031c6b 100644 --- a/src/java/org/ifsoft/websockets/ProxyConnection.java +++ b/src/java/org/ifsoft/websockets/ProxyConnection.java @@ -12,12 +12,13 @@ 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; @@ -52,6 +53,7 @@ public ProxyConnection(URI uri, List subprotocol, int connectTimeout) { Log.debug("ProxyConnection " + uri + " " + subprotocol); + final SslContextFactory clientSslContextFactory = SslContextFactoryProvider.getClientSslContextFactory(); if("wss".equals(uri.getScheme())) { Log.debug("ProxyConnection - SSL"); @@ -60,7 +62,7 @@ public ProxyConnection(URI uri, List subprotocol, int connectTimeout) } else isSecure = false; - httpClient = new HttpClient(); + httpClient = new HttpClient(new HttpClientTransportOverHTTP(1),clientSslContextFactory); final QueuedThreadPool queuedThreadPool = QueuedThreadPoolProvider.getQueuedThreadPool("ProxyConnection-HttpClient"); httpClient.setExecutor(queuedThreadPool); httpClient.setConnectTimeout(connectTimeout); @@ -69,10 +71,10 @@ public ProxyConnection(URI uri, List subprotocol, int connectTimeout) { httpClient.start(); wsClient = new WebSocketClient(httpClient); - wsClient.setIdleTimeout(Duration.ofMinutes(5)); wsClient.start(); - final ClientUpgradeRequest request = new ClientUpgradeRequest(uri); + final ClientUpgradeRequest request = new ClientUpgradeRequest(); + request.setRequestURI​(uri); if (subprotocol != null) request.setSubProtocols(subprotocol); proxySocket = new ProxySocket(this); @@ -243,7 +245,7 @@ public void deliver(String text) { try { Log.debug("ProxySocket deliver: \n" + text); - session.getRemote().sendString(text); + session.getRemote().sendStringByFuture(text); lastMessage = null; } catch (Exception e) { Log.error("ProxySocket deliver", e); diff --git a/src/java/org/ifsoft/websockets/ProxyWebSocket.java b/src/java/org/ifsoft/websockets/ProxyWebSocket.java index 3ea632ce..0d3b2605 100644 --- a/src/java/org/ifsoft/websockets/ProxyWebSocket.java +++ b/src/java/org/ifsoft/websockets/ProxyWebSocket.java @@ -15,6 +15,11 @@ 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; @@ -90,7 +95,7 @@ public void deliver(String message) { try { Log.debug(" : Delivered : \n" + message ); - wsSession.getRemote().sendString(message); + wsSession.getRemote().sendStringByFuture(message); } catch (Exception e) { Log.error("ProxyWebSocket deliver " + e); Log.warn("Could not deliver : \n" + message ); diff --git a/src/java/org/jivesoftware/openfire/plugin/ofmeet/OfMeetPlugin.java b/src/java/org/jivesoftware/openfire/plugin/ofmeet/OfMeetPlugin.java index db826f17..a3035588 100644 --- a/src/java/org/jivesoftware/openfire/plugin/ofmeet/OfMeetPlugin.java +++ b/src/java/org/jivesoftware/openfire/plugin/ofmeet/OfMeetPlugin.java @@ -28,8 +28,7 @@ import org.eclipse.jetty.servlet.*; import org.eclipse.jetty.websocket.servlet.*; import org.eclipse.jetty.websocket.server.*; -import org.eclipse.jetty.websocket.server.config.*; -import org.eclipse.jetty.http.pathmap.ServletPathSpec; +import org.eclipse.jetty.websocket.server.pathmap.ServletPathSpec; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -399,15 +398,18 @@ public void destroyPlugin() protected void loadPublicWebApp() throws Exception { Log.info( "Initializing public web application for /colibri-ws web socket" ); - - 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); + + 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); + } HttpBindManager.getInstance().addJettyHandler(jvbWsContext); @@ -425,9 +427,9 @@ protected void loadPublicWebApp() throws Exception } - public static class JvbSocketCreator implements JettyWebSocketCreator + public static class JvbSocketCreator implements WebSocketCreator { - @Override public Object createWebSocket(JettyServerUpgradeRequest req, JettyServerUpgradeResponse resp) + @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { String ipaddr = JiveGlobals.getProperty( "ofmeet.videobridge.rest.host", OfMeetPlugin.self.getIpAddress()); String jvbPort = JiveGlobals.getProperty( "ofmeet.websockets.plainport", "8180"); @@ -820,14 +822,19 @@ private void setupFFMPEG(File pluginDirectory) private void startFFMPEG(String path) { - 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); + 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); + } try { String ffmpegName = null; @@ -860,9 +867,9 @@ private void extractFile(ZipInputStream zipIn, String filePath) throws IOExcepti bos.close(); } - public static class StreamSocketCreator implements JettyWebSocketCreator + public static class StreamSocketCreator implements WebSocketCreator { - @Override public Object createWebSocket(JettyServerUpgradeRequest req, JettyServerUpgradeResponse resp) + @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { String streamKey = null; diff --git a/src/java/org/jivesoftware/openfire/plugin/ofmeet/WatermarkFilter.java b/src/java/org/jivesoftware/openfire/plugin/ofmeet/WatermarkFilter.java index a21facf9..3642a057 100644 --- a/src/java/org/jivesoftware/openfire/plugin/ofmeet/WatermarkFilter.java +++ b/src/java/org/jivesoftware/openfire/plugin/ofmeet/WatermarkFilter.java @@ -48,26 +48,18 @@ protected static void serve( HttpServletResponse response, URL url ) throws IOEx { final URLConnection urlConnection = url.openConnection(); response.setContentLength( urlConnection.getContentLength() ); - String contentType = urlConnection.getContentType(); - - if (contentType != null && contentType.toLowerCase().startsWith("image")) { - response.setContentType( contentType ); + response.setContentType( urlConnection.getContentType() ); - 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 ); - } + 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 ); + } + } } catch ( IOException e ) { diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/controller/GroupController.java b/src/java/org/jivesoftware/openfire/plugin/rest/controller/GroupController.java index 41102044..f71b0bfa 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/controller/GroupController.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/controller/GroupController.java @@ -10,7 +10,6 @@ import org.jivesoftware.openfire.group.GroupAlreadyExistsException; import org.jivesoftware.openfire.group.GroupManager; import org.jivesoftware.openfire.group.GroupNotFoundException; -import org.jivesoftware.openfire.group.GroupNameInvalidException; import org.jivesoftware.openfire.plugin.rest.entity.GroupEntity; import org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType; import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException; @@ -94,9 +93,6 @@ public Group createGroup(GroupEntity groupEntity) throws ServiceException { group.getProperties().put("sharedRoster.showInRoster", "onlyGroup"); group.getProperties().put("sharedRoster.displayName", groupEntity.getName()); group.getProperties().put("sharedRoster.groupList", ""); - } catch (GroupNameInvalidException e1) { - throw new ServiceException("Could not create new group", "groups", - ExceptionType.ILLEGAL_ARGUMENT_EXCEPTION, Response.Status.BAD_REQUEST); } catch (GroupAlreadyExistsException e) { throw new ServiceException("Could not create a group", groupEntity.getName(), ExceptionType.GROUP_ALREADY_EXISTS, Response.Status.CONFLICT, e); diff --git a/src/java/org/jivesoftware/openfire/plugin/rest/controller/UserServiceLegacyController.java b/src/java/org/jivesoftware/openfire/plugin/rest/controller/UserServiceLegacyController.java index c8b8190b..a8b0932e 100644 --- a/src/java/org/jivesoftware/openfire/plugin/rest/controller/UserServiceLegacyController.java +++ b/src/java/org/jivesoftware/openfire/plugin/rest/controller/UserServiceLegacyController.java @@ -25,7 +25,6 @@ import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.group.Group; import org.jivesoftware.openfire.group.GroupAlreadyExistsException; -import org.jivesoftware.openfire.group.GroupNameInvalidException; import org.jivesoftware.openfire.group.GroupManager; import org.jivesoftware.openfire.group.GroupNotFoundException; import org.jivesoftware.openfire.lockout.LockOutManager; @@ -104,19 +103,14 @@ public void createUser(String username, String password, String name, String ema try { group = GroupManager.getInstance().getGroup(groupName); - groups.add(group); } catch (GroupNotFoundException e) { // Create this group ; - try { - group = GroupManager.getInstance().createGroup(groupName); - group.getProperties().put("sharedRoster.showInRoster", "onlyGroup"); - group.getProperties().put("sharedRoster.displayName", groupName); - group.getProperties().put("sharedRoster.groupList", ""); - groups.add(group); - } catch (GroupNameInvalidException e1) { - //Log.warn("Unable to get or create group " + groupName, e1); - } + group = GroupManager.getInstance().createGroup(groupName); + group.getProperties().put("sharedRoster.showInRoster", "onlyGroup"); + group.getProperties().put("sharedRoster.displayName", groupName); + group.getProperties().put("sharedRoster.groupList", ""); } + groups.add(group); } for (Group group : groups) { group.getMembers().add(server.createJID(username, null)); @@ -191,20 +185,15 @@ public void updateUser(String username, String password, String name, String ema try { group = GroupManager.getInstance().getGroup(groupName); - newGroups.add(group); } catch (GroupNotFoundException e) { // Create this group ; - - try { - group = GroupManager.getInstance().createGroup(groupName); - group.getProperties().put("sharedRoster.showInRoster", "onlyGroup"); - group.getProperties().put("sharedRoster.displayName", groupName); - group.getProperties().put("sharedRoster.groupList", ""); - newGroups.add(group); - } catch (GroupNameInvalidException e1) { - //Log.warn("Unable to get or create group " + groupName, e1); - } + group = GroupManager.getInstance().createGroup(groupName); + group.getProperties().put("sharedRoster.showInRoster", "onlyGroup"); + group.getProperties().put("sharedRoster.displayName", groupName); + group.getProperties().put("sharedRoster.groupList", ""); } + + newGroups.add(group); } Collection existingGroups = GroupManager.getInstance().getGroups(user); diff --git a/src/java/uk/ifsoft/openfire/plugins/pade/PadePlugin.java b/src/java/uk/ifsoft/openfire/plugins/pade/PadePlugin.java index 10dd28f4..3f0def28 100644 --- a/src/java/uk/ifsoft/openfire/plugins/pade/PadePlugin.java +++ b/src/java/uk/ifsoft/openfire/plugins/pade/PadePlugin.java @@ -96,86 +96,71 @@ public void initializePlugin( final PluginManager manager, final File pluginDire self = this; webRoot = pluginDirectory.getPath() + "/classes"; server = XMPPServer.getInstance().getServerInfo().getHostname() + ":" + JiveGlobals.getProperty("httpbind.port.secure", "7443"); + Log.info("start pade server " + server); interceptor = new WebPushInterceptor(); InterceptorManager.getInstance().addInterceptor( interceptor ); OfflineMessageStrategy.addListener( interceptor ); - try { - contextRest = new ServletContextHandler(ServletContextHandler.SESSIONS); - contextRest.setContextPath("/rest"); - contextRest.setClassLoader(this.getClass().getClassLoader()); - contextRest.addServlet(new ServletHolder(new JerseyWrapper()), "/api/*"); - HttpBindManager.getInstance().addJettyHandler(contextRest); - - } catch ( Exception ex ) { - Log.error( "An exception occurred", ex ); - } - - try { - contextWellKnown = new WebAppContext(null, pluginDirectory.getPath() + "/classes/well-known", "/.well-known"); - contextWellKnown.setClassLoader(this.getClass().getClassLoader()); - final List initializersWellKnown = new ArrayList<>(); - initializersWellKnown.add(new ContainerInitializer(new JettyJasperInitializer(), null)); - contextWellKnown.setAttribute("org.eclipse.jetty.containerInitializers", initializersWellKnown); - contextWellKnown.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); - contextWellKnown.setWelcomeFiles(new String[]{"index.jsp"}); - HttpBindManager.getInstance().addJettyHandler(contextWellKnown); - - contextPrivate = new WebAppContext(null, pluginDirectory.getPath() + "/classes/private", "/dashboard"); - contextPrivate.setClassLoader(this.getClass().getClassLoader()); - contextPrivate.getMimeTypes().addMimeMapping("wasm", "application/wasm"); - SecurityHandler securityHandler = basicAuth("ofmeet"); - contextPrivate.setSecurityHandler(securityHandler); - final List initializersDashboard = new ArrayList<>(); - initializersDashboard.add(new ContainerInitializer(new JettyJasperInitializer(), null)); - contextPrivate.setAttribute("org.eclipse.jetty.containerInitializers", initializersDashboard); - contextPrivate.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); - contextPrivate.setWelcomeFiles(new String[]{"index.jsp"}); - HttpBindManager.getInstance().addJettyHandler(contextPrivate); - - contextPublic = new WebAppContext(null, pluginDirectory.getPath() + "/classes/docs", "/pade"); - contextPublic.setClassLoader(this.getClass().getClassLoader()); - contextPublic.getMimeTypes().addMimeMapping("wasm", "application/wasm"); - final List initializersCRM = new ArrayList<>(); - initializersCRM.add(new ContainerInitializer(new JettyJasperInitializer(), null)); - contextPublic.setAttribute("org.eclipse.jetty.containerInitializers", initializersCRM); - contextPublic.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); - contextPublic.setWelcomeFiles(new String[]{"index.html"}); - HttpBindManager.getInstance().addJettyHandler(contextPublic); - - } catch ( Exception ex ) { - Log.error( "An exception occurred", ex ); - } - - try { - contextWinSSO = new WebAppContext(null, pluginDirectory.getPath() + "/classes/win-sso", "/sso"); - contextWinSSO.setClassLoader(this.getClass().getClassLoader()); - final List initializers7 = new ArrayList<>(); - initializers7.add(new ContainerInitializer(new JettyJasperInitializer(), null)); - contextWinSSO.setAttribute("org.eclipse.jetty.containerInitializers", initializers7); - contextWinSSO.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); - contextWinSSO.setWelcomeFiles(new String[]{"index.jsp"}); - - if (OSUtils.IS_WINDOWS) - { - NegotiateSecurityFilter securityFilter = new NegotiateSecurityFilter(); - FilterHolder filterHolder = new FilterHolder(); - filterHolder.setFilter(securityFilter); - EnumSet enums = EnumSet.of(DispatcherType.REQUEST); - enums.add(DispatcherType.REQUEST); - - contextWinSSO.addFilter(filterHolder, "/*", enums); - contextWinSSO.addServlet(new ServletHolder(new WaffleInfoServlet()), "/waffle"); - } - contextWinSSO.addServlet(new ServletHolder(new org.ifsoft.sso.Password()), "/password"); - HttpBindManager.getInstance().addJettyHandler(contextWinSSO); - - } catch ( Exception ex ) { - Log.error( "An exception occurred", ex ); + contextRest = new ServletContextHandler(null, "/rest", ServletContextHandler.SESSIONS); + contextRest.setClassLoader(this.getClass().getClassLoader()); + contextRest.addServlet(new ServletHolder(new JerseyWrapper()), "/api/*"); + HttpBindManager.getInstance().addJettyHandler(contextRest); + + contextWellKnown = new WebAppContext(null, pluginDirectory.getPath() + "/classes/well-known", "/.well-known"); + contextWellKnown.setClassLoader(this.getClass().getClassLoader()); + final List initializersWellKnown = new ArrayList<>(); + initializersWellKnown.add(new ContainerInitializer(new JettyJasperInitializer(), null)); + contextWellKnown.setAttribute("org.eclipse.jetty.containerInitializers", initializersWellKnown); + contextWellKnown.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); + contextWellKnown.setWelcomeFiles(new String[]{"index.jsp"}); + HttpBindManager.getInstance().addJettyHandler(contextWellKnown); + + contextPrivate = new WebAppContext(null, pluginDirectory.getPath() + "/classes/private", "/dashboard"); + contextPrivate.setClassLoader(this.getClass().getClassLoader()); + contextPrivate.getMimeTypes().addMimeMapping("wasm", "application/wasm"); + SecurityHandler securityHandler = basicAuth("ofmeet"); + contextPrivate.setSecurityHandler(securityHandler); + final List initializersDashboard = new ArrayList<>(); + initializersDashboard.add(new ContainerInitializer(new JettyJasperInitializer(), null)); + contextPrivate.setAttribute("org.eclipse.jetty.containerInitializers", initializersDashboard); + contextPrivate.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); + contextPrivate.setWelcomeFiles(new String[]{"index.jsp"}); + HttpBindManager.getInstance().addJettyHandler(contextPrivate); + + contextPublic = new WebAppContext(null, pluginDirectory.getPath() + "/classes/docs", "/pade"); + contextPublic.setClassLoader(this.getClass().getClassLoader()); + contextPublic.getMimeTypes().addMimeMapping("wasm", "application/wasm"); + final List initializersCRM = new ArrayList<>(); + initializersCRM.add(new ContainerInitializer(new JettyJasperInitializer(), null)); + contextPublic.setAttribute("org.eclipse.jetty.containerInitializers", initializersCRM); + contextPublic.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); + contextPublic.setWelcomeFiles(new String[]{"index.html"}); + HttpBindManager.getInstance().addJettyHandler(contextPublic); + + contextWinSSO = new WebAppContext(null, pluginDirectory.getPath() + "/classes/win-sso", "/sso"); + contextWinSSO.setClassLoader(this.getClass().getClassLoader()); + final List initializers7 = new ArrayList<>(); + initializers7.add(new ContainerInitializer(new JettyJasperInitializer(), null)); + contextWinSSO.setAttribute("org.eclipse.jetty.containerInitializers", initializers7); + contextWinSSO.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); + contextWinSSO.setWelcomeFiles(new String[]{"index.jsp"}); + + if (OSUtils.IS_WINDOWS) + { + NegotiateSecurityFilter securityFilter = new NegotiateSecurityFilter(); + FilterHolder filterHolder = new FilterHolder(); + filterHolder.setFilter(securityFilter); + EnumSet enums = EnumSet.of(DispatcherType.REQUEST); + enums.add(DispatcherType.REQUEST); + + contextWinSSO.addFilter(filterHolder, "/*", enums); + contextWinSSO.addServlet(new ServletHolder(new WaffleInfoServlet()), "/waffle"); } - + contextWinSSO.addServlet(new ServletHolder(new org.ifsoft.sso.Password()), "/password"); + HttpBindManager.getInstance().addJettyHandler(contextWinSSO); + try { Security.addProvider( new OfChatSaslProvider() );