Commit 90b30063 authored by Roman S's avatar Roman S

Update the REST API plugin to version 1.1.2

- Added: CORS to all endpoints
parent 31de4ae3
......@@ -44,6 +44,11 @@
REST API Plugin Changelog
</h1>
<p><b>1.1.2</b> -- August 4th, 2015</p>
<ul>
<li>Added: CORS to all endpoints</li>
</ul>
<p><b>1.1.1</b> -- June 29th, 2015</p>
<ul>
<li>Added: new endpoint to close user sessions</li>
......
......@@ -5,8 +5,8 @@
<name>REST API</name>
<description>Allows administration over a RESTful API.</description>
<author>Roman Soldatow</author>
<version>1.1.1</version>
<date>06/29/2015</date>
<version>1.1.2</version>
<date>08/04/2015</date>
<minServerVersion>3.9.0</minServerVersion>
<adminconsole>
......
......@@ -1233,6 +1233,7 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<ul>
<li><a href="#rest-api-plugin-readme">REST API Plugin Readme</a><ul>
<li><a href="#feature-list">Feature list</a></li>
<li><a href="#available-rest-api-clients">Available REST API clients</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#explanation-of-rest">Explanation of REST</a></li>
<li><a href="#authentication">Authentication</a><ul>
......@@ -1438,6 +1439,11 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<li><a href="#examples-32">Examples</a></li>
</ul>
</li>
<li><a href="#close-all-user-sessions">Close all user sessions</a><ul>
<li><a href="#possible-parameters-28">Possible parameters</a></li>
<li><a href="#examples-33">Examples</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#deprecated-user-service-plugin-readme">(Deprecated) User Service Plugin Readme</a><ul>
......@@ -1453,8 +1459,6 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
</div>
</p>
<h2 id="feature-list">Feature list</h2>
<ul>
......@@ -1480,6 +1484,8 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<li>GO Lang <a href="https://github.com/Urethramancer/fireman">https://github.com/Urethramancer/fireman</a> (party implemented)</li>
</ul>
<h2 id="installation">Installation</h2>
<p>Copy restAPI.jar into the plugins directory of your Openfire server. The plugin will then be automatically deployed. To upgrade to a new version, copy the new restAPI.jar file over the existing file.</p>
......@@ -3763,7 +3769,9 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<p><strong>GET</strong> <a href="http://example.org:9090/plugins/restapi/v1/sessions">http://example.org:9090/plugins/restapi/v1/sessions</a></p>
</blockquote>
<h2 id="retrieve-the-user-sessions-1">Retrieve the user sessions</h2>
<h2 id="retrieve-the-user-sessions">Retrieve the user sessions</h2>
<p>Endpoint to get sessions from a user</p>
......@@ -3776,7 +3784,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3 id="possible-parameters-28">Possible parameters</h3>
<h3 id="possible-parameters-27">Possible parameters</h3>
<table>
<thead>
......@@ -3819,7 +3827,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3 id="possible-parameters-27">Possible parameters</h3>
<h3 id="possible-parameters-28">Possible parameters</h3>
<table>
<thead>
......@@ -3847,6 +3855,8 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<p><strong>DELETE</strong> <a href="http://example.org:9090/plugins/restapi/v1/sessions/testuser">http://example.org:9090/plugins/restapi/v1/sessions/testuser</a></p>
<h1 id="deprecated-user-service-plugin-readme">(Deprecated) User Service Plugin Readme</h1>
......
package org.jivesoftware.openfire.plugin.rest;
import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerResponse;
import com.sun.jersey.spi.container.ContainerResponseFilter;
/**
* The Class CORSFilter.
*/
public class CORSFilter implements ContainerResponseFilter {
/* (non-Javadoc)
* @see com.sun.jersey.spi.container.ContainerResponseFilter#filter(com.sun.jersey.spi.container.ContainerRequest, com.sun.jersey.spi.container.ContainerResponse)
*/
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
response.getHttpHeaders().add("Access-Control-Allow-Origin", "*");
response.getHttpHeaders().add("Access-Control-Allow-Headers",
"origin, content-type, accept, authorization");
response.getHttpHeaders().add("Access-Control-Allow-Credentials", "true");
response.getHttpHeaders().add("Access-Control-Allow-Methods",
"GET, POST, PUT, DELETE, OPTIONS, HEAD");
return response;
}
}
......@@ -22,9 +22,15 @@ public class JerseyWrapper extends ServletContainer {
/** The Constant AUTHFILTER. */
private static final String AUTHFILTER = "org.jivesoftware.openfire.plugin.rest.AuthFilter";
/** The Constant CORSFILTER. */
private static final String CORSFILTER = "org.jivesoftware.openfire.plugin.rest.CORSFilter";
/** The Constant CONTAINER_REQUEST_FILTERS. */
private static final String CONTAINER_REQUEST_FILTERS = "com.sun.jersey.spi.container.ContainerRequestFilters";
/** The Constant CONTAINER_RESPONSE_FILTERS. */
private static final String CONTAINER_RESPONSE_FILTERS = "com.sun.jersey.spi.container.ContainerResponseFilters";
/** The Constant RESOURCE_CONFIG_CLASS_KEY. */
private static final String RESOURCE_CONFIG_CLASS_KEY = "com.sun.jersey.config.property.resourceConfigClass";
......@@ -56,6 +62,7 @@ public class JerseyWrapper extends ServletContainer {
prc = new PackagesResourceConfig(SCAN_PACKAGE_DEFAULT);
prc.setPropertiesAndFeatures(config);
prc.getProperties().put(CONTAINER_REQUEST_FILTERS, AUTHFILTER);
prc.getProperties().put(CONTAINER_RESPONSE_FILTERS, CORSFILTER);
prc.getClasses().add(RestAPIService.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment