Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7b1aded
Merge remote-tracking branch 'upstream/master'
ddhuy Nov 18, 2017
7817195
Merge remote-tracking branch 'upstream/master'
ddhuy Nov 21, 2017
c61b64d
Merge remote-tracking branch 'upstream/master'
ddhuy Nov 24, 2017
b007c24
Merge remote-tracking branch 'upstream/master'
ddhuy Nov 29, 2017
ca8f4e2
scripts & configurations for easy compile/run
ddhuy Nov 30, 2017
17726a7
Merge remote-tracking branch 'upstream/master'
ddhuy Nov 30, 2017
0a4efd6
fix rc start
ddhuy Nov 30, 2017
390dfc3
Merge remote-tracking branch 'upstream/master'
ddhuy Dec 2, 2017
4fc69f9
Merge remote-tracking branch 'upstream/master'
ddhuy Dec 5, 2017
1312f2b
fix 2497: suspend account
ddhuy Dec 5, 2017
c846a5e
Merge remote-tracking branch 'upstream/master'
ddhuy Dec 6, 2017
e453ca1
change release version
ddhuy Dec 6, 2017
d284f95
add regression tests
ddhuy Jan 17, 2018
b775cf6
Merge branch 'master' of https://github.com/RestComm/Restcomm-Connect
ddhuy Jan 18, 2018
a880b53
Merge remote-tracking branch 'upstream/master'
ddhuy Jan 21, 2018
daff37d
Merge remote-tracking branch 'upstream/master'
ddhuy Jan 22, 2018
26f6e9a
Merge remote-tracking branch 'upstream/master'
ddhuy Feb 13, 2018
dd07849
Merge remote-tracking branch 'upstream/master'
ddhuy Mar 1, 2018
7ba20ce
change sql authentication in configuration
ddhuy Mar 8, 2018
16409d5
Merge remote-tracking branch 'upstream/master'
ddhuy Mar 8, 2018
5f59c31
Merge branch 'master' of github.com:RestComm/Restcomm-Connect
ddhuy Mar 10, 2018
bfea85d
Merge remote-tracking branch 'upstream/master'
ddhuy Mar 21, 2018
3ec2d3c
Merge remote-tracking branch 'upstream/master'
ddhuy Mar 22, 2018
3a54d85
Merge remote-tracking branch 'upstream/master'
ddhuy Mar 23, 2018
5d17278
Merge remote-tracking branch 'upstream/master'
ddhuy Mar 30, 2018
4ff436f
Merge remote-tracking branch 'upstream/master'
ddhuy Apr 6, 2018
72e2ea2
fix suspend account & add regression tests
ddhuy Apr 7, 2018
2fef8bd
Merge branch 'issue_2497_ddhuy' of github.com:ddhuy/Restcomm-Connect …
ddhuy Apr 7, 2018
731b99a
fix merging issues
ddhuy Apr 7, 2018
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
43 changes: 43 additions & 0 deletions RC
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
export JAVA_HOME=/opt/java/jdk1.7.0_80
export PATH=$JAVA_HOME/bin:$PATH

export RC_HOME=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
export RC_RELEASE=$RC_HOME/release/target-as7
export RC_CONFIGURATION=$RC_HOME/configurations
export RC_DEPENDENCIES=$RC_HOME/dependencies

export MAVEN_OPTS="-Xms1024m -Xmx2048m -XX:MaxPermSize=1024m"

rc_build()
{
export MAJOR_VERSION_NUMBER=8.2
export BUILD_NUMBER=0
mkdir -p $RC_DEPENDENCIES
ant release -f $RC_HOME/release/build.xml -Drestcomm.release.version=$MAJOR_VERSION_NUMBER.$BUILD_NUMBER -Drestcomm.branch.name=restcomm-release-$MAJOR_VERSION_NUMBER.$BUILD_NUMBER -Dcheckout.restcomm.dir=$RC_HOME -Dworkspace.restcomm.dir=$RC_HOME/restcomm -Dcheckout.dir=$RC_DEPENDENCIES
}

rc_start()
{
cp -rf $RC_CONFIGURATION/* $RC_RELEASE/
$RC_RELEASE/bin/restcomm/start-restcomm.sh
}

rc_stop()
{
$RC_RELEASE/bin/restcomm/stop-restcomm.sh
}

case "$@" in
"build")
build_restcomm
;;
"start")
start_restcomm
;;
"stop")
stop_restcomm
;;
*)
;;
esac
10 changes: 10 additions & 0 deletions configurations/modules/org/mysql/jdbc/main/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module xmlns="urn:jboss:module:1.1" name="org.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-5.1.40.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Binary file not shown.
380 changes: 380 additions & 0 deletions configurations/standalone/configuration/standalone-sip.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version. This software is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details. You should have received a copy of the GNU
Lesser General Public License along with this software; if not, write to
the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA, or see the FSF site: http://www.fsf.org. -->

<restcomm>
<!-- <dao-manager class="org.restcomm.connect.dao.mybatis.MybatisDaoManager">
<configuration-file>${restcomm:home}/WEB-INF/conf/mybatis.xml</configuration-file>
<data-files>${restcomm:home}/WEB-INF/data/hsql</data-files>
<sql-files>${restcomm:home}/WEB-INF/sql</sql-files>
</dao-manager> -->
<dao-manager class="org.restcomm.connect.dao.mybatis.MybatisDaoManager">
<configuration-file>${restcomm:home}/WEB-INF/conf/mybatis.xml</configuration-file>
<data-files></data-files>
<sql-files>${restcomm:home}/WEB-INF/scripts/mariadb/sql</sql-files>
</dao-manager>
</restcomm>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC '-//mybatis.org//DTD Config 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-config.dtd'>
<!--
@author thomas.quintana@telestax.com (Thomas Quintana)
-->
<configuration>
<environments default="mysql">
<environment id="mysql">
<transactionManager type="JDBC"/>
<dataSource type="JNDI">
<property name="data_source" value="java:/MysqlDS"/>
</dataSource>
</environment>
<!--
<environment id="production">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:file://${data}/restcomm;ifexists=true;hsqldb.write_delay=false;shutdown=true"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</dataSource>
</environment>
-->
<!--
<environment id="mariadb">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.8.102:3306/restcomm"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</dataSource>
</environment>
-->
</environments>
<mappers>
<mapper url="file://${sql}/accounts.xml"/>
<mapper url="file://${sql}/applications.xml"/>
<mapper url="file://${sql}/available-phone-numbers.xml"/>
<mapper url="file://${sql}/call-detail-records.xml"/>
<mapper url="file://${sql}/conference-detail-records.xml"/>
<mapper url="file://${sql}/clients.xml"/>
<mapper url="file://${sql}/http-cookies.xml"/>
<mapper url="file://${sql}/incoming-phone-numbers.xml"/>
<mapper url="file://${sql}/notifications.xml"/>
<mapper url="file://${sql}/outgoing-caller-ids.xml"/>
<mapper url="file://${sql}/registrations.xml"/>
<mapper url="file://${sql}/recordings.xml"/>
<mapper url="file://${sql}/sand-boxes.xml"/>
<mapper url="file://${sql}/short-codes.xml"/>
<mapper url="file://${sql}/sms-messages.xml"/>
<mapper url="file://${sql}/transcriptions.xml"/>
<mapper url="file://${sql}/gateways.xml"/>
<mapper url="file://${sql}/announcements.xml"/>
<mapper url="file://${sql}/usage.xml"/>
<mapper url="file://${sql}/instanceId.xml"/>
<mapper url="file://${sql}/media-servers.xml"/>
<mapper url="file://${sql}/media-resource-broker-entity.xml"/>
<mapper url="file://${sql}/extensions-configuration.xml"/>
<mapper url="file://${sql}/geolocation.xml"/>
<mapper url="file://${sql}/organization.xml"/>
</mappers>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,32 @@ protected void checkAuthenticatedAccount(UserIdentityContext userIdentityContext

/**
* filter out accounts that are not active
* filter out accounts that have parent is not active
*
* @param userIdentityContext
*/
protected void filterClosedAccounts(UserIdentityContext userIdentityContext, String path) {
if (userIdentityContext.getEffectiveAccount() != null && !userIdentityContext.getEffectiveAccount().getStatus().equals(Account.Status.ACTIVE)) {
if (userIdentityContext.getEffectiveAccount().getStatus().equals(Account.Status.UNINITIALIZED) && path.startsWith("Accounts")) {
return;
Account account = userIdentityContext.getEffectiveAccount();

if (account != null) {
if (!account.getStatus().equals(Account.Status.ACTIVE)) {
if (account.getStatus().equals(Account.Status.UNINITIALIZED) && path.startsWith("Accounts")) {
return;
}
throw new WebApplicationException(status(Status.FORBIDDEN).entity("Provided Account is not active").build());
} else {
Account parentAccount = userIdentityContext.getParrentAccount();
if (parentAccount != null) {
if (parentAccount.getStatus() != Account.Status.ACTIVE && parentAccount.getStatus() != Account.Status.UNINITIALIZED) {
throw new WebApplicationException(status(Status.FORBIDDEN).entity("Parent Account is not active").build());
}
} else {
// Parent account is null -> this could be administrator.
// Administrator account should not be closed/inactive.
}
}
throw new WebApplicationException(status(Status.FORBIDDEN).entity("Provided Account is not active").build());
} else {
throw new WebApplicationException(status(Status.NOT_FOUND).entity("Provided Account is not found").build());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.restcomm.connect.dao.exceptions.AccountHierarchyDepthCrossed;
import org.restcomm.connect.commons.dao.Sid;
import org.restcomm.connect.dao.AccountsDao;
import org.restcomm.connect.dao.entities.Account;

Expand Down Expand Up @@ -132,4 +133,10 @@ public List<String> getEffectiveAccountLineage() {
return accountLineage;
}

public Account getParrentAccount ( ) {
Sid parentSid = this.effectiveAccount.getParentSid();
if (parentSid != null)
return this.accountsDao.getAccount(parentSid);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
Expand All @@ -24,6 +28,12 @@
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.core.util.MultivaluedMapImpl;

/**
* @author <a href="mailto:gvagenas@gmail.com">gvagenas</a>
* @author <a href="mailto:lyhungthinh@gmail.com">Thinh Ly</a>
Expand Down Expand Up @@ -113,6 +123,14 @@ public JsonObject getClientOfAccount(String deploymentUrl, JsonObject account, S
return jsonResponse;
}

public ClientResponse getClientsResponse ( String deploymentUrl, JsonObject account ) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(account.get("email_address").getAsString(), account.get("auth_token").getAsString()));
WebResource webResource = jerseyClient.resource(getClientUrl(deploymentUrl, account));
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
return response;
}

public void updateClientVoiceUrl(String deploymentUrl, JsonObject account, String clientSid, String voiceUrl,
String credentialUsername, String credentialPassword) throws IOException {
String url = getClientUrl(deploymentUrl, account);
Expand Down Expand Up @@ -190,4 +208,51 @@ public String createClient(String deploymentUrl, String accountSid, String authT

return clientSid;
}

public ClientResponse createClientResponse ( String deploymentUrl, String accountUsername, String accountAuthToken,
String accountSid, String clientUsername, String clientPassword,
String clientVoiceUrl ) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(accountUsername, accountAuthToken));
String url = getEndpoint(deploymentUrl) + "/2012-04-24/Accounts/" + accountSid + "/Clients.json";
WebResource webResource = jerseyClient.resource(url);
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
if (clientUsername != null)
params.add("Login", clientUsername);
if (clientPassword != null)
params.add("Password", clientPassword);
if (clientVoiceUrl != null)
params.add("VoiceUrl", clientVoiceUrl);
System.out.println("[createClientResponse]" + url);
System.out.println("[createClientResponse]" + params.toString());
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, params);
return response;
}

public ClientResponse updateClientResponse ( String deploymentUrl, String accountUsername, String accountAuthToken,
String accountSid, String clientSid, String clientPassword,
String clientVoiceUrl ) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(accountUsername, accountAuthToken));
String url = getEndpoint(deploymentUrl) + "/2012-04-24/Accounts/" + accountSid + "/Clients/" + clientSid;
WebResource webResource = jerseyClient.resource(url);
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
if (clientPassword != null)
params.add("Password", clientPassword);
if (clientVoiceUrl != null)
params.add("VoiceUrl", clientVoiceUrl);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, params);
return response;
}

public ClientResponse deleteClientResponse ( String deploymentUrl, String accountUsername, String accountAuthToken,
String accountSid, String clientSid ) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(accountUsername, accountAuthToken));
String url = getEndpoint(deploymentUrl) + "/2012-04-24/Accounts/" + accountSid + "/Clients/" + clientSid;
WebResource webResource = jerseyClient.resource(url);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).delete(ClientResponse.class);
return response;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.core.util.MultivaluedMapImpl;
Expand All @@ -48,15 +49,11 @@ public static NotificationEndpointTool getInstance() {
return instance;
}

private String getAccountsUrl(String deploymentUrl, String username, Boolean json) {
if (accountsUrl == null) {
if (deploymentUrl.endsWith("/")) {
deploymentUrl = deploymentUrl.substring(0, deploymentUrl.length() - 1);
}

accountsUrl = deploymentUrl + "/2012-04-24/Accounts/" + username + "/Notifications" + ((json) ? ".json" : "");
private String getAccountsUrl ( String deploymentUrl, String username, Boolean json ) {
if (deploymentUrl.endsWith("/")) {
deploymentUrl = deploymentUrl.substring(0, deploymentUrl.length() - 1);
}

accountsUrl = deploymentUrl + "/2012-04-24/Accounts/" + username + "/Notifications" + ((json) ? ".json" : "");
return accountsUrl;
}

Expand All @@ -71,8 +68,16 @@ public JsonObject getNotificationList(String deploymentUrl, String username, Str
return jsonObject;
}

public JsonObject getNotificationList(String deploymentUrl, String username, String authToken, Integer page, Integer pageSize, Boolean json) {
public ClientResponse getNotificationListResponse ( String deploymentUrl, String username, String authToken ) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(username, authToken));
String url = getAccountsUrl(deploymentUrl, username, true);
WebResource webResource = jerseyClient.resource(url);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
return response;
}

public JsonObject getNotificationList(String deploymentUrl, String username, String authToken, Integer page, Integer pageSize, Boolean json) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(username, authToken));
String url = getAccountsUrl(deploymentUrl, username, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.core.util.MultivaluedMapImpl;
Expand Down Expand Up @@ -49,14 +50,10 @@ public static RecordingEndpointTool getInstance() {
}

private String getAccountsUrl(String deploymentUrl, String username, Boolean json) {
if (accountsUrl == null) {
if (deploymentUrl.endsWith("/")) {
deploymentUrl = deploymentUrl.substring(0, deploymentUrl.length() - 1);
}

accountsUrl = deploymentUrl + "/2012-04-24/Accounts/" + username + "/Recordings" + ((json) ? ".json" : "");
if (deploymentUrl.endsWith("/")) {
deploymentUrl = deploymentUrl.substring(0, deploymentUrl.length() - 1);
}

accountsUrl = deploymentUrl + "/2012-04-24/Accounts/" + username + "/Recordings" + ((json) ? ".json" : "");
return accountsUrl;
}

Expand All @@ -71,6 +68,15 @@ public JsonObject getRecordingList(String deploymentUrl, String username, String
return jsonObject;
}

public ClientResponse getRecordingListResponse ( String deploymentUrl, String username, String authToken ) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(username, authToken));
String url = getAccountsUrl(deploymentUrl, username, true);
WebResource webResource = jerseyClient.resource(url);
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
return response;
}

public JsonObject getRecordingList(String deploymentUrl, String username, String authToken, Integer page, Integer pageSize, Boolean json) {

Client jerseyClient = Client.create();
Expand Down
Loading