/* $Header: Logout.java 28-jan-2002.23:34:13 pichan Exp $ */

/* Copyright (c) 2002, 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)
    pichan      01/28/02 - Merged pichan_bug-2173202
    pichan      01/28/02 - remove jazn.com url.
     pichan      01/28/02 - Creation
  */

 /**
  *  @version $Header: Logout.java 28-jan-2002.23:34:13 pichan 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;
 import oracle.security.jazn.oc4j.JAZNServletResponse;

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

     public Logout() 
     {
	 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\">");


	 if (request.getRemoteUser() != null) {

	     // notes that the application is responsible for cleanup
	     //invalidate the HttpSession
	     HttpSession session = request.getSession();
	     session.invalidate();

	     String url=null;
	     oracle.security.jazn.oc4j.WebSSOUtil.globalLogout(response,url);
	
	} else 	out.println("You are not logged in!");
	out.println("</BODY>");
	out.println("</HTML>");
	
    }
	
}
