Skip to content

Commit 4e80640

Browse files
committed
fixes igniterealtime#33: update API to be compatible with Openfire 4.8
1 parent 6ebe3fb commit 4e80640

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

changelog.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141

4242
<h1>HTTP File Upload Plugin Changelog</h1>
4343

44-
<p><b>1.1.4</b> -- (tbd)</p>
44+
<p><b>1.2.0</b> -- (tbd)</p>
4545
<ul>
46+
<li>Now requires Openfire 4.7.0 or later</li>
47+
<li><a href="https://github.com/igniterealtime/openfire-httpFileUpload-plugin/issues/33">Issue #33:</a> Fix API incompatiblities with upcoming Openfire 4.8.</li>
4648
<li>Updated to HttpFileUploadComponent v1.4.0, which resolves:</li>
4749
<ul>
4850
<li>Updated Guava library to 30.0-jre to address known vulnerabilities with earlier versions.</li>

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<parent>
55
<artifactId>plugins</artifactId>
66
<groupId>org.igniterealtime.openfire</groupId>
7-
<version>4.3.0</version>
7+
<version>4.7.0</version>
88
</parent>
99
<groupId>org.igniterealtime.openfire.plugins</groupId>
1010
<artifactId>httpfileupload</artifactId>
1111
<name>HTTP File Upload Plugin</name>
1212
<description>Allows clients to share files, as described in the XEP-0363 'HTTP File Upload' specification.</description>
13-
<version>1.1.4-SNAPSHOT</version>
13+
<version>1.2.0-SNAPSHOT</version>
1414

1515
<distributionManagement>
1616
<!-- Repository in which we deploy this project, when desired. -->

src/java/org/igniterealtime/openfire/plugins/httpfileupload/CORSServlet.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ protected void service( HttpServletRequest request, HttpServletResponse response
2020
final HttpBindManager boshManager = HttpBindManager.getInstance();
2121

2222
// add CORS headers for all HTTP responses (errors, etc.)
23-
if (boshManager.isCORSEnabled())
23+
if (HttpBindManager.HTTP_BIND_CORS_ENABLED.getValue())
2424
{
2525
if (boshManager.isAllOriginsAllowed()) {
2626
// Set the Access-Control-Allow-Origin header to * to allow all Origin to do the CORS
27-
response.setHeader( "Access-Control-Allow-Origin", HttpBindManager.HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT);
27+
response.setHeader( "Access-Control-Allow-Origin", HttpBindManager.HTTP_BIND_CORS_ALLOW_ORIGIN_ALL);
2828
} else {
2929
// Get the Origin header from the request and check if it is in the allowed Origin Map.
3030
// If it is allowed write it back to the Access-Control-Allow-Origin header of the respond.
@@ -33,9 +33,9 @@ protected void service( HttpServletRequest request, HttpServletResponse response
3333
response.setHeader("Access-Control-Allow-Origin", origin);
3434
}
3535
}
36-
response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
37-
response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT);
38-
response.setHeader("Access-Control-Max-Age", HttpBindManager.HTTP_BIND_CORS_MAX_AGE_DEFAULT);
36+
response.setHeader("Access-Control-Allow-Methods", String.join(", ", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS.getDefaultValue()));
37+
response.setHeader("Access-Control-Allow-Headers", String.join(", ", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS.getDefaultValue()));
38+
response.setHeader("Access-Control-Max-Age", String.valueOf(HttpBindManager.HTTP_BIND_CORS_MAX_AGE.getDefaultValue().getSeconds())); // // TODO: replace with 'toSeconds()' after dropping support for Java 8.
3939
}
4040
super.service(request, response);
4141
}

src/java/org/igniterealtime/openfire/plugins/httpfileupload/HttpFileUploadPlugin.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void initializePlugin( PluginManager manager, File pluginDirectory )
5555
{
5656
SlotManager.getInstance().setWebProtocol( JiveGlobals.getProperty( "plugin.httpfileupload.announcedWebProtocol", "https" ) );
5757
SlotManager.getInstance().setWebHost( JiveGlobals.getProperty( "plugin.httpfileupload.announcedWebHost", XMPPServer.getInstance().getServerInfo().getHostname() ) );
58-
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.getInstance().getHttpBindSecurePort() ) );
58+
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.HTTP_BIND_SECURE_PORT.getValue() ) );
5959
SlotManager.getInstance().setWebContextRoot( JiveGlobals.getProperty( "plugin.httpfileupload.announcedWebContextRoot", "/httpfileupload" ) );
6060
SlotManager.getInstance().setMaxFileSize( JiveGlobals.getLongProperty( "plugin.httpfileupload.maxFileSize", SlotManager.DEFAULT_MAX_FILE_SIZE ) );
6161

@@ -177,7 +177,7 @@ public final void setProperty( String property )
177177

178178
if ( "plugin.httpfileupload.announcedWebPort".equals( property ) )
179179
{
180-
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.getInstance().getHttpBindSecurePort() ) );
180+
SlotManager.getInstance().setWebPort( JiveGlobals.getIntProperty( "plugin.httpfileupload.announcedWebPort", HttpBindManager.HTTP_BIND_SECURE_PORT.getValue() ) );
181181
}
182182
}
183183

@@ -203,7 +203,7 @@ public final void deleteProperty( String property )
203203

204204
if ( "plugin.httpfileupload.announcedWebPort".equals( property ) )
205205
{
206-
SlotManager.getInstance().setWebPort( HttpBindManager.getInstance().getHttpBindSecurePort() );
206+
SlotManager.getInstance().setWebPort( HttpBindManager.HTTP_BIND_SECURE_PORT.getValue() );
207207
}
208208
}
209209
}

0 commit comments

Comments
 (0)