001    package jsp.security.protected_;
002    
003    import javax.servlet.*;
004    import javax.servlet.http.*;
005    import javax.servlet.jsp.*;
006    
007    public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
008        implements org.apache.jasper.runtime.JspSourceDependent {
009    
010      private static java.util.List _jspx_dependants;
011    
012      public Object getDependants() {
013        return _jspx_dependants;
014      }
015    
016      public void _jspService(HttpServletRequest request, HttpServletResponse response)
017            throws java.io.IOException, ServletException {
018    
019        JspFactory _jspxFactory = null;
020        PageContext pageContext = null;
021        HttpSession session = null;
022        ServletContext application = null;
023        ServletConfig config = null;
024        JspWriter out = null;
025        Object page = this;
026        JspWriter _jspx_out = null;
027        PageContext _jspx_page_context = null;
028    
029    
030        try {
031          _jspxFactory = JspFactory.getDefaultFactory();
032          response.setContentType("text/html");
033          pageContext = _jspxFactory.getPageContext(this, request, response,
034                            null, true, 8192, true);
035          _jspx_page_context = pageContext;
036          application = pageContext.getServletContext();
037          config = pageContext.getServletConfig();
038          session = pageContext.getSession();
039          out = pageContext.getOut();
040          _jspx_out = out;
041    
042          out.write("<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n  contributor license agreements.  See the NOTICE file distributed with\n  this work for additional information regarding copyright ownership.\n  The ASF licenses this file to You under the Apache License, Version 2.0\n  (the \"License\"); you may not use this file except in compliance with\n  the License.  You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n-->\n");
043    
044      if (request.getParameter("logoff") != null) {
045        session.invalidate();
046        response.sendRedirect("index.jsp");
047        return;
048      }
049    
050          out.write("\n<html>\n<head>\n<title>Protected Page for Examples</title>\n</head>\n<body bgcolor=\"white\">\n\nYou are logged in as remote user <b>");
051          out.print( request.getRemoteUser() );
052          out.write("</b>\nin session <b>");
053          out.print( session.getId() );
054          out.write("</b><br><br>\n\n");
055    
056      if (request.getUserPrincipal() != null) {
057    
058          out.write("\n    Your user principal name is\n    <b>");
059          out.print( request.getUserPrincipal().getName() );
060          out.write("</b><br><br>\n");
061    
062      } else {
063    
064          out.write("\n    No user principal could be identified.<br><br>\n");
065    
066      }
067    
068          out.write('\n');
069          out.write('\n');
070    
071      String role = request.getParameter("role");
072      if (role == null)
073        role = "";
074      if (role.length() > 0) {
075        if (request.isUserInRole(role)) {
076    
077          out.write("\n      You have been granted role\n      <b>");
078          out.print( util.HTMLFilter.filter(role) );
079          out.write("</b><br><br>\n");
080    
081        } else {
082    
083          out.write("\n      You have <i>not</i> been granted role\n      <b>");
084          out.print( util.HTMLFilter.filter(role) );
085          out.write("</b><br><br>\n");
086    
087        }
088      }
089    
090          out.write("\n\nTo check whether your username has been granted a particular role,\nenter it here:\n<form method=\"GET\" action='");
091          out.print( response.encodeURL("index.jsp") );
092          out.write("'>\n<input type=\"text\" name=\"role\" value=\"");
093          out.print( util.HTMLFilter.filter(role) );
094          out.write("\">\n</form>\n<br><br>\n\nIf you have configured this app for form-based authentication, you can log\noff by clicking\n<a href='");
095          out.print( response.encodeURL("index.jsp?logoff=true") );
096          out.write("'>here</a>.\nThis should cause you to be returned to the logon page after the redirect\nthat is performed.\n\n</body>\n</html>\n");
097        } catch (Throwable t) {
098          if (!(t instanceof SkipPageException)){
099            out = _jspx_out;
100            if (out != null && out.getBufferSize() != 0)
101              out.clearBuffer();
102            if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
103          }
104        } finally {
105          if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
106        }
107      }
108    }