Back to List

View Original Layout

Sample code demonstrating how to use omNovia's Single Sign On with ASP
omNovia Technologies Inc.
Latest modifications: November 11, 2008

Single Sign On (SSO) is an API that allows you to send your members, once authenticated, from your site, to the omNovia Secure Conference login page. By passing their identification and other security parameters, they do not need to enter yet another password to access your Secure Conference room.

package com.investools.web.common; 
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.Calendar;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
Example Struts action to redirect from company site to Omnovia room using redirect and sso.
public class OmnoviaRedirectExample extends Action{

	@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
	HttpServletRequest request, HttpServletResponse response)
	throws Exception {
 try{ 
You should do this in a try catch and redirect to friendly error page for fails.
String companyPass = ""; 
This should be your companies company pass code, provided by Omnovia.
String baseOmnoviaLink = "https://www.omnovia.com/pages/sc2/roomlogin?";
This should be the id for the omNovia hosted room you want to redirect to.
This can be hard coded, pulled from an 'omNovia' form, or directly from the action if passed with // the request.
Note: You should have a default in-case no room was passed in.
int roomId = -1; 

	String version = "1.3"; 
	String username = ""; // user's unique username.
	String fname = "";	// user's first name.
	String lname = "";	// user's last name.
	int presenter = 0;	// 0 for attendees.  1 for presenter or moderator

If $directAccess is false it first takes the users to an omNovia login page which would test their Flash install and provide other info. **THIS IS RECOMMENDED**

If $directAccess is true, they would access the room directly . **NOT RECOMMENDED**
boolean directAccess = false;
String inquirey = (directAccess ? "&inquiry=login" : "");
ONLY if you set $directAccess = 1; you might want to open the room in a separate window. The advantage is the room will have a bigger interface as you can remove the navigation buttons and other menus on top of a newly opened browser. You cannot do so on an already open browser.
int seperateWindow = 0;
		
int companyId = -1; // company id is given to you by Omnovia.
		
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT")); // Onmovia uses GMT.
long timestamp = c.getTimeInMillis() / 1000; // get the current GMT time and convert to Unix timestamp.
timestamp = timestamp + 60; // since we are doing a redirect delay can be approx as short as a page load.
see getMD5 method for details.
String md5 = getMD5(companyId+companyPass+roomId+fname+lname+presenter+version+username+timestamp);
create the url to redirect for.
String roomLink = baseOmnoviaLink+
	"companyID="+companyId+"&isPresenter="+presenter+"&loginType=2&roomID="+roomId+inquirey+
	"&firstName="+ URLEncoder.encode(fname, "UTF-8")+ "&lastName="+ URLEncoder.encode(lname, "UTF-8") +
	"&companyUsername="+username+"&_ts="+timestamp+"&_t="+md5+"&_v="+version;
send the user on their way.
response.sendRedirect(roomLink);
not using action mappings as this is a redirect.
return null;

   }
catch(Exception e)
   {

Error Message 
   }
   }
you should have an error message to throw here if something fails.
return hex hash code for provided string value.
@param data string value to hash.
@return hex hash code. */
private String getMD5(String data){
	StringBuffer sb = new StringBuffer();

    try {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.update(data.getBytes());
        byte[] digestBytes = messageDigest.digest();
convert to hexstring
 String hex = null;

    for (int i = 0; i < digestBytes.length; i++) {
       hex = Integer.toHexString(0xFF & digestBytes[i]);
          if (hex.length() < 2) {
                    sb.append("0");
                    sb.append(hex);
                }else
                sb.append(hex);
            }
        }
        catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return sb.toString();
	}
}

THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESSED OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@category Web Services
@copyright omNovia Technologies
@version 1.3

Back to List

View Original Layout