Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jaxrs2 migration #2764

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions restcomm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
<servlet-api.version>7.0.50</servlet-api.version>
<shirocore.version>1.2.0</shirocore.version>
<shiroweb.version>1.2.0</shiroweb.version>
<jersey.version>1.13</jersey.version>
<httpclient.version>4.5.2</httpclient.version>
<httpasyncclient.version>4.1.3</httpasyncclient.version>
<gson.version>2.3.1</gson.version>
Expand Down Expand Up @@ -333,16 +332,12 @@
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>


<dependency>
<groupId>stax</groupId>
Expand Down
10 changes: 7 additions & 3 deletions restcomm/restcomm.application/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<!-- Enable CORS request filter -->
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>org.restcomm.connect.http.cors.CorsFilter</param-value>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.restcomm.connect.http</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.restcomm.connect.http.cors.CorsFilter</param-value>
</init-param>
</servlet>

<context-param>
Expand Down
9 changes: 4 additions & 5 deletions restcomm/restcomm.extension.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
</properties>

<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand Down
21 changes: 5 additions & 16 deletions restcomm/restcomm.http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,16 @@
<artifactId>httpasyncclient</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>

<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>

<dependency>
<groupId>org.restcomm</groupId>
<artifactId>restcomm-connect.commons</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.configuration.Configuration;
import org.apache.shiro.crypto.hash.Md5Hash;
Expand Down Expand Up @@ -70,6 +69,7 @@
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE;
import javax.ws.rs.core.MultivaluedHashMap;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.CONFLICT;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
Expand Down Expand Up @@ -409,7 +409,7 @@ protected Response putAccount(final MultivaluedMap<String, String> data, final M
accountsDao.addAccount(account);

// Create default SIP client data
MultivaluedMap<String, String> clientData = new MultivaluedMapImpl();
MultivaluedMap<String, String> clientData = new MultivaluedHashMap();
String username = data.getFirst("EmailAddress").split("@")[0];
clientData.add("Login", username);
clientData.add("Password", data.getFirst("Password"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

package org.restcomm.connect.http.cors;

import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerResponse;
import com.sun.jersey.spi.container.ContainerResponseFilter;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.lang.StringUtils;
Expand All @@ -33,11 +32,11 @@
import org.restcomm.connect.commons.configuration.sources.ConfigurationSource;

import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import java.io.File;
import java.io.IOException;
import javax.ws.rs.container.ContainerRequestContext;

/**
* @author otsakir@gmail.com - Orestis Tsakiridis
Expand All @@ -46,35 +45,37 @@
public class CorsFilter implements ContainerResponseFilter {
private final Logger logger = Logger.getLogger(CorsFilter.class);

@Context
private HttpServletRequest servletRequest;
/*@Context
private HttpServletRequest servletRequest;*/

// we initialize this lazily upon first request since it can't be injected through the @Context annotation (it didn't work)
@Context
private ServletContext lazyServletContext;

String allowedOrigin;



// We return Access-* headers only in case allowedOrigin is present and equals to the 'Origin' header.
@Override
public ContainerResponse filter(ContainerRequest cres, ContainerResponse response) {
initLazily(servletRequest);
String requestOrigin = cres.getHeaderValue("Origin");
public void filter(ContainerRequestContext cres, ContainerResponseContext response) throws IOException {
initLazily();
String requestOrigin = cres.getHeaderString("Origin");
if (requestOrigin != null) { // is this is a cors request (ajax request that targets a different domain than the one the page was loaded from)
if (allowedOrigin != null && allowedOrigin.startsWith(requestOrigin)) { // no cors allowances make are applied if allowedOrigins == null
// only return the origin the client informed
response.getHttpHeaders().add("Access-Control-Allow-Origin", requestOrigin);
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");
response.getHttpHeaders().add("Access-Control-Max-Age", "1209600");
response.getHeaders().add("Access-Control-Allow-Origin", requestOrigin);
response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
response.getHeaders().add("Access-Control-Max-Age", "1209600");
}
}
return response;
}

private void initLazily(ServletRequest request) {
if (lazyServletContext == null) {
ServletContext context = request.getServletContext();
private void initLazily() {
if (allowedOrigin == null) {
ServletContext context = lazyServletContext;
String rootPath = context.getRealPath("/");
rootPath = StringUtils.stripEnd(rootPath,"/"); // remove trailing "/" character
String restcommXmlPath = rootPath + "/WEB-INF/conf/restcomm.xml";
Expand Down
19 changes: 4 additions & 15 deletions restcomm/restcomm.identity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,10 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>

<dependency>
<groupId>com.thoughtworks.xstream</groupId>
Expand Down
10 changes: 5 additions & 5 deletions restcomm/restcomm.provisioning.number.voxbone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
<artifactId>mail</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
Loading