Skip to content

Commit

Permalink
Merge branch 'ghub_rvd_master' into ghub_rvdras_master
Browse files Browse the repository at this point in the history
  • Loading branch information
otsakir committed Nov 3, 2014
2 parents bfa797b + 3df9d84 commit e709b82
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public String getEffectiveRestcommIp(HttpServletRequest request) {
return ip;
}

// Always returns the destination port in the request. When the configuration/settings scheme clears
// out a proper implementation should be done.
// TODO
public String getEffectiveRestcommPort(HttpServletRequest request) {
int port = request.getLocalPort();
return "" + port;
}

/**
* Returns the IP rvd listens to for internal use. This address can be used by restcomm to access applications.
* A request object is required to get it. Even when this request comes from a browser, this function should report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,18 @@ private String processStep(Step step) throws InterpreterException {
URI url;
try {
URIBuilder uri_builder = new URIBuilder(populateVariables(esStep.getUrl()) ); // supports RVD variable expansion

// if this is a relative url fill in missing fields from the request
if (uri_builder.getHost() == null ) {
logger.debug("External Service: Relative url is used. Will override from http request to RVD controller");
// if this is a relative url fill in missing fields from the request
uri_builder.setScheme(httpRequest.getScheme());
uri_builder.setHost(httpRequest.getServerName());
uri_builder.setPort(httpRequest.getServerPort());
if ( ! uri_builder.getPath().startsWith("/") )
uri_builder.setPath("/" + uri_builder.getPath());
}

// Add url parameters for GET requests
if ( esStep.getMethod() == null || "GET".equals(esStep.getMethod()) )
for ( UrlParam urlParam : esStep.getUrlParams() )
uri_builder.addParameter(urlParam.getName(), populateVariables(urlParam.getValue()) );
Expand All @@ -472,7 +474,7 @@ private String processStep(Step step) throws InterpreterException {
HttpPost post = new HttpPost(url);
List <NameValuePair> values = new ArrayList <NameValuePair>();
for ( UrlParam urlParam : esStep.getUrlParams() )
values.add(new BasicNameValuePair(urlParam.getName(), urlParam.getValue()));
values.add(new BasicNameValuePair(urlParam.getName(), populateVariables(urlParam.getValue()) ));
post.setEntity(new UrlEncodedFormEntity(values));
post.addHeader("Authorization", "Basic " + RvdUtils.buildHttpAuthorizationToken(esStep.getUsername(), esStep.getPassword()));
response = client.execute( post );
Expand Down Expand Up @@ -537,10 +539,6 @@ private String processStep(Step step) throws InterpreterException {
// if no next route has been found throw an error
if ( "fixed".equals(esStep.getNextType()) && RvdUtils.isEmpty(next) ) {
throw new InterpreterException("No valid module could be found for ES routing"); // use a general exception for now.
//next = esStep.getDefaultNext();
//if ( RvdUtils.isEmpty(next) )
// throw new ReferencedModuleDoesNotExist("No module specified for ES routing and no default route exists either");
//logger.debug("No valid route returned. Will use default route: " + next );
}
logger.info( "Routing enabled. Chosen target: " + next);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AuthenticationService(RvdConfiguration rvdSettings, HttpServletRequest re
public boolean authenticate( String username, String password ) throws RvdSecurityException {
logger.debug("Authenticating " + username + " on Restcomm");
String restcommIp = rvdSettings.getEffectiveRestcommIp(request);
String restcommAuthUrl = "http://" + restcommIp + ":8080";
String restcommAuthUrl = "http://" + restcommIp + ":" + rvdSettings.getEffectiveRestcommPort(request);

CloseableHttpClient client = HttpClients.createDefault();
URI url;
Expand Down

0 comments on commit e709b82

Please sign in to comment.