Skip to content

Commit

Permalink
SulWowza: consistently call it queryStr; add a couple of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed May 5, 2016
1 parent 09cf716 commit 4b15195
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/edu/stanford/dlss/wowza/SulWowza.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

public class SulWowza extends ModuleBase
{

public String defaultUrl = "http://localhost:3000/";
protected URL baseAuthUrl;

// onAppStart() is defined in the IModuleOnApp interface. This method is invoked when a Wowza application
// instance is started.
// invoked when a Wowza application instance is started;
// defined in the IModuleOnApp interface
public void onAppStart(IApplicationInstance appInstance)
{
String stacksURL = appInstance.getProperties().getPropertyStr("stacksURL", defaultUrl);
Expand All @@ -35,38 +35,42 @@ public void onAppStart(IApplicationInstance appInstance)
}
}


// Invoked when an HTTP MPEGDash Streaming session is created;
// defined in IModuleOnHTTPMPEGDashStreamingSession module interfaces
public void onHTTPMPEGDashStreamingSessionCreate(HTTPStreamerSessionMPEGDash httpSession)
{
getLogger().info("Tommy: SulWowza onHTTPMPEGDashStreamingSessionCreate: " + httpSession.getSessionId());
authorizeSession(httpSession);
}


// Invoked when an HTTP Cupertino Streaming session is created;
// defined in IModuleOnHTTPCupertinoStreamingSession interface
public void onHTTPCupertinoStreamingSessionCreate(HTTPStreamerSessionCupertino httpSession)
{
getLogger().info("Tommy: SulWowza onHTTPCupertinoStreamingSessionCreate: ");
authorizeSession(httpSession);
}

void authorizeSession(IHTTPStreamerSession httpSession)
{
String query = httpSession.getQueryStr();
if (authorize(query))
httpSession.acceptSession();
else httpSession.rejectSession();
String queryStr = httpSession.getQueryStr();
if (authorize(queryStr))
httpSession.acceptSession();
else
httpSession.rejectSession();
}
boolean authorize(String query)

boolean authorize(String queryStr)
{
String authToken = getAuthToken(query);
return validateAuthToken(authToken);
String authToken = getAuthToken(queryStr);
return validateAuthToken(authToken);
}
String getAuthToken(String parameters)

String getAuthToken(String queryStr)
{
if (parameters != null)
if (queryStr != null && queryStr.length() > 6) // "token=" is 6 chars
{
String[] parts = parameters.split("\\?");
String[] parts = queryStr.split("\\?");
String query = parts[parts.length-1];
List<NameValuePair> httpParams = URLEncodedUtils.parse(query,Charset.defaultCharset());
for (NameValuePair param:httpParams)
Expand All @@ -75,7 +79,7 @@ String getAuthToken(String parameters)
}
return null;
}

boolean validateAuthToken(String token)
{
getLogger().info("Tommy: SulWowza token = " + token);
Expand Down

0 comments on commit 4b15195

Please sign in to comment.