home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / index_jsp.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-05-17  |  5.0 KB  |  112 lines

  1. package org.apache.jsp.security.protected_;
  2.  
  3. import java.io.IOException;
  4. import java.util.List;
  5. import java.util.Vector;
  6. import javax.servlet.ServletConfig;
  7. import javax.servlet.ServletContext;
  8. import javax.servlet.ServletException;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import javax.servlet.http.HttpSession;
  12. import javax.servlet.jsp.JspFactory;
  13. import javax.servlet.jsp.JspWriter;
  14. import javax.servlet.jsp.PageContext;
  15. import javax.servlet.jsp.SkipPageException;
  16. import org.apache.jasper.runtime.HttpJspBase;
  17. import org.apache.jasper.runtime.JspSourceDependent;
  18.  
  19. public final class index_jsp extends HttpJspBase implements JspSourceDependent {
  20.    private static Vector _jspx_dependants;
  21.  
  22.    public List getDependants() {
  23.       return _jspx_dependants;
  24.    }
  25.  
  26.    public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  27.       JspFactory _jspxFactory = null;
  28.       PageContext pageContext = null;
  29.       HttpSession session = null;
  30.       ServletContext application = null;
  31.       ServletConfig config = null;
  32.       JspWriter out = null;
  33.       JspWriter _jspx_out = null;
  34.       PageContext _jspx_page_context = null;
  35.  
  36.       try {
  37.          _jspxFactory = JspFactory.getDefaultFactory();
  38.          response.setContentType("text/html");
  39.          pageContext = _jspxFactory.getPageContext(this, request, response, (String)null, true, 8192, true);
  40.          _jspx_page_context = pageContext;
  41.          application = pageContext.getServletContext();
  42.          config = pageContext.getServletConfig();
  43.          session = pageContext.getSession();
  44.          out = pageContext.getOut();
  45.          out.write("<!--\r\n  Copyright 2004 The Apache Software Foundation\r\n\r\n  Licensed under the Apache License, Version 2.0 (the \"License\");\r\n  you may not use this file except in compliance with the License.\r\n  You may obtain a copy of the License at\r\n\r\n      http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n  Unless required by applicable law or agreed to in writing, software\r\n  distributed under the License is distributed on an \"AS IS\" BASIS,\r\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n  See the License for the specific language governing permissions and\r\n  limitations under the License.\r\n-->\r\n");
  46.          if (request.getParameter("logoff") == null) {
  47.             out.write("\r\n<html>\r\n<head>\r\n<title>Protected Page for Examples</title>\r\n</head>\r\n<body bgcolor=\"white\">\r\n\r\nYou are logged in as remote user <b>");
  48.             out.print(request.getRemoteUser());
  49.             out.write("</b>\r\nin session <b>");
  50.             out.print(session.getId());
  51.             out.write("</b><br><br>\r\n\r\n");
  52.             if (request.getUserPrincipal() != null) {
  53.                out.write("\r\n    Your user principal name is\r\n    <b>");
  54.                out.print(request.getUserPrincipal().getName());
  55.                out.write("</b><br><br>\r\n");
  56.             } else {
  57.                out.write("\r\n    No user principal could be identified.<br><br>\r\n");
  58.             }
  59.  
  60.             out.write("\r\n\r\n");
  61.             String role = request.getParameter("role");
  62.             if (role == null) {
  63.                role = "";
  64.             }
  65.  
  66.             if (role.length() > 0) {
  67.                if (request.isUserInRole(role)) {
  68.                   out.write("\r\n      You have been granted role <b>");
  69.                   out.print(role);
  70.                   out.write("</b><br><br>\r\n");
  71.                } else {
  72.                   out.write("\r\n      You have <i>not</i> been granted role <b>");
  73.                   out.print(role);
  74.                   out.write("</b><br><br>\r\n");
  75.                }
  76.             }
  77.  
  78.             out.write("\r\n\r\nTo check whether your username has been granted a particular role,\r\nenter it here:\r\n<form method=\"GET\" action='");
  79.             out.print(response.encodeURL("index.jsp"));
  80.             out.write("'>\r\n<input type=\"text\" name=\"role\" value=\"");
  81.             out.print(role);
  82.             out.write("\">\r\n</form>\r\n<br><br>\r\n\r\nIf you have configured this app for form-based authentication, you can log\r\noff by clicking\r\n<a href='");
  83.             out.print(response.encodeURL("index.jsp?logoff=true"));
  84.             out.write("'>here</a>.\r\nThis should cause you to be returned to the logon page after the redirect\r\nthat is performed.\r\n\r\n</body>\r\n</html>\r\n");
  85.             return;
  86.          }
  87.  
  88.          session.invalidate();
  89.          response.sendRedirect("index.jsp");
  90.       } catch (Throwable t) {
  91.          if (!(t instanceof SkipPageException)) {
  92.             if (_jspx_out != null && _jspx_out.getBufferSize() != 0) {
  93.                _jspx_out.clearBuffer();
  94.             }
  95.  
  96.             if (_jspx_page_context != null) {
  97.                _jspx_page_context.handlePageException(t);
  98.                return;
  99.             }
  100.          }
  101.  
  102.          return;
  103.       } finally {
  104.          if (_jspxFactory != null) {
  105.             _jspxFactory.releasePageContext(_jspx_page_context);
  106.          }
  107.  
  108.       }
  109.  
  110.    }
  111. }
  112.