/* $Header: SsoInfo.java 10-jan-2003.01:34:30 kvthanga Exp $ */

/* Copyright (c) 2000, 2003, Oracle Corporation.  All rights reserved.  */

/*
   DESCRIPTION
    <short description of component this file declares/defines>

   PRIVATE CLASSES
    <list of private classes defined - with one-line descriptions>

   NOTES
    <other useful comments, qualifications, etc.>

   MODIFIED    (MM/DD/YY)
      kvthanga  01/10/03 - Remove redirection
      rkng      11/21/01 - Merged rkng_oc4j_15.9

    pichan        11/20/01 - Creation   
 */

/**
 *  @version $Header: SsoInfo.java 10-jan-2003.01:34:30 kvthanga Exp $
 *  @author  pichan
 *  @since   release specific (what release of product did this appear in)
 */

package oracle.security.jazn.samples.http;

import java.io.IOException;
import java.util.Date;
import java.util.Properties;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.security.Principal;
import oracle.security.jazn.oc4j.JAZNUserAdaptor;

/**
 * A simple demo that exercises JAZN/SSO/LDAP. 
 * 
 * 
 */
public class SsoInfo extends HttpServlet {

    public SsoInfo() 
    {
	super();
    }

    public void init(ServletConfig config) 
	throws ServletException 
    {
	super.init(config);
    }
    
    public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException 
    {

	ServletOutputStream out = response.getOutputStream();

	response.setContentType("text/html");
	out.println("<HTML><BODY bgcolor=\"#FFFFFF\">");
	out.println("Time stamp: " + new Date().toString()+"<p>");
	out.println("request.getRemoteUser = " + request.getRemoteUser() + "<br>");
	Principal p = request.getUserPrincipal();
	out.println("request.getUserPrincipal = " + p + "<br>");
	if (p instanceof JAZNUserAdaptor) {
	    JAZNUserAdaptor jaznuser = (JAZNUserAdaptor)p;
   
	    out.println("SSO user DN [RealmPrincipal.getFullName] = " + jaznuser.getFullName() + "<br>");
	    out.println("Subscriber name [Realm.getName] = " + jaznuser.getRealm().getName() + "<br>");
	    out.println("Subscriber DN [Realm.getFullName] = " + jaznuser.getRealm().getFullName() + "<p>");
	}
	out.println("Click to <a href=logout>global logout</a> <br>");
	out.println("Notes: the application is responsible for doing cleanup before invoking global logout. <br>");
	out.println("Please refers to the sample source code for reference.");

	out.println("</BODY>");
	out.println("</HTML>");
    }

}
