cziegeler    2002/06/13 03:31:23

  Modified:    src/webapp/docs/samples samples.xml
               src/webapp/samples samples.xml
  Added:       src/webapp/samples/authentication sitemap.xmap
               src/webapp/samples/authentication/docs login.xml
                        protected.xml userlist.xml
               src/webapp/samples/authentication/stylesheets
                        authenticate.xsl simple-page2html.xsl
  Log:
  Adding a simple authentication sample
  
  Revision  Changes    Path
  1.14      +6 -2      xml-cocoon2/src/webapp/docs/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/samples.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- samples.xml       3 Jun 2002 11:45:52 -0000       1.13
  +++ samples.xml       13 Jun 2002 10:31:23 -0000      1.14
  @@ -57,7 +57,11 @@
       More ways of implementing dynamic content.
      </sample>
   
  -   <sample name="Portal &amp; Authentication" 
href="samples/portal/sunspotdemoportal">
  +   <sample name="Authentication Framework" href="samples/authentication/login">
  +    This is a demo of the authentication framework integrated into Cocoon.
  +   </sample>
  +
  +   <sample name="Portal Framework" href="samples/portal/sunspotdemoportal">
       This is a demo of the portal framework integrated into Cocoon.
      </sample>
   
  
  
  
  1.10      +6 -2      xml-cocoon2/src/webapp/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/samples/samples.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- samples.xml       3 Jun 2002 11:45:52 -0000       1.9
  +++ samples.xml       13 Jun 2002 10:31:23 -0000      1.10
  @@ -131,7 +131,11 @@
       More ways of implementing dynamic content.
      </sample>
   
  -   <sample name="Portal &amp; Authentication" href="portal/sunspotdemoportal">
  +   <sample name="Authentication Framework" href="authentication/login">
  +    This is a demo of the authentication framework integrated into Cocoon.
  +   </sample>
  +
  +   <sample name="Portal Framework" href="portal/sunspotdemoportal">
       This is a demo of the portal framework integrated into Cocoon.
      </sample>
   
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/authentication/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>
  <!-- =========================== Components ================================ -->
  
   <map:components>
  
    <map:generators default="file"/>
    <map:transformers default="xslt"/>
    <map:serializers default="html"/>
    <map:matchers default="wildcard"/>
    <map:selectors default="browser"/>
    <map:readers default="resource"/>
   </map:components>
  
  
  <!-- =========================== Pipelines ================================= -->
  
   <map:pipelines>
    <map:component-configurations>
    <authentication-manager>
      <handlers>
        <handler name="demohandler">
                <redirect-to uri="cocoon:/login"/>
                <authentication uri="cocoon:raw:/authenticate"/>
        </handler>
       </handlers>
     </authentication-manager>
    </map:component-configurations>
  
    <map:pipeline>
  
        <map:match pattern="">
          <map:redirect-to uri="login"/>
        </map:match>
  
        <!-- ================= -->
        <!-- Simple login page -->
        <!-- ================= -->
        <map:match pattern="login">
              <!-- if we are already logged in, redirect to the protected document -->
                <map:act type="auth-loggedIn">
                        <map:parameter name="handler" value="demohandler"/> 
                        <map:redirect-to uri="protected"/>
                </map:act> 
              <map:generate src="docs/login.xml"/>
              <map:transform src="stylesheets/simple-page2html.xsl"/>
                <map:transform type="encodeURL"/>
              <map:serialize/>
        </map:match>
  
        <!-- ========================================= -->
        <!-- Form target which performs auth service   -->
        <!-- ========================================= -->
        <map:match pattern="do-login">
              <!-- try to login -->
                <map:act type="auth-login">
                <map:parameter name="handler" value="demohandler"/>
                        <map:parameter name="parameter_name" value="request:username"/>
                        <map:redirect-to uri="protected"/>
              </map:act>
              <!-- something was wrong, try it again -->
              <map:redirect-to uri="login"/>
        </map:match>
  
        <!-- ================ -->
        <!-- Protected area   -->
        <!-- ================ -->
        <map:match pattern="protected">
                <map:act type="auth-protect">
                        <map:parameter name="handler" value="demohandler"/> 
  
                  <map:generate src="docs/protected.xml"/>
                  <map:transform src="stylesheets/simple-page2html.xsl"/>
                    <map:transform type="encodeURL"/>
                  <map:serialize/>
              </map:act>
              <!-- something was wrong, redirect to login page -->
              <map:redirect-to uri="login"/>
        </map:match>
  
        <!-- ========================================= -->
        <!-- Logout link which invalidates the session -->
        <!-- ========================================= -->
        <map:match pattern="do-logout">
                <map:act type="auth-protect">
                        <map:parameter name="handler" value="demohandler"/> 
  
                       <map:act type="auth-logout"/>
              </map:act>
              <map:redirect-to uri="login"/>
        </map:match>
  
    </map:pipeline>
  
    <map:pipeline internal-only="true">
      <!-- This is the authentication respource -->
        <map:match pattern="authenticate">
                        <map:generate src="docs/userlist.xml"/>
                        <map:transform src="stylesheets/authenticate.xsl">
                                <map:parameter name="use-request-parameters" 
value="true"/>
                    </map:transform>
                        <map:serialize type="xml"/>
        </map:match>
    </map:pipeline>
  
   </map:pipelines>
  
  </map:sitemap>
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/authentication/docs/login.xml
  
  Index: login.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <page>
   <title>Login page</title>
   <content>
     <linkbar/>
     <para>
       This page serves as an example of the authentication framework.
     </para>
     <para>Please log in using your name (cocoon will work)</para>
     <form target="do-login">
       <input type="text" name="username"/>
       <input type="submit">Login</input>
     </form>
   </content>
  </page>
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/authentication/docs/protected.xml
  
  Index: protected.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <page>
   <title>Login page</title>
   <content>
     <linkbar/>
     <para>
       This page serves as an example of the authentication framework.
     </para>
     <para>You're are logged in now, and can read this protected document containing 
very important
           and secret information.</para>
   </content>
  </page>
  
  
  
  
  1.1                  xml-cocoon2/src/webapp/samples/authentication/docs/userlist.xml
  
  Index: userlist.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!-- $Id: userlist.xml,v 1.1 2002/06/13 10:31:23 cziegeler Exp $ 
  
   Description: All users
  
  -->
  <authentication>
        <users>
                <user>
                        <name>cocoon</name>
                </user>
                <user>
                        <name>guest</name>
                </user>
        </users>
  </authentication>
  
  
  
  1.1                  
xml-cocoon2/src/webapp/samples/authentication/stylesheets/authenticate.xsl
  
  Index: authenticate.xsl
  ===================================================================
  <?xml version="1.0"?>
  <!-- $Id: authenticate.xsl,v 1.1 2002/06/13 10:31:23 cziegeler Exp $ 
  
  -->
  
  <xsl:stylesheet version="1.0" 
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
  
  <!-- Get the name from the request paramter -->
  <xsl:param name="name"/>
  
  <xsl:template match="authentication">
    <authentication>
        <xsl:apply-templates select="users"/>
    </authentication>
  </xsl:template>
  
  
  <xsl:template match="users">
      <xsl:apply-templates select="user"/>
  </xsl:template>
  
  
  <xsl:template match="user">
      <!-- Compare the name of the user -->
      <xsl:if test="normalize-space(name) = $name">
          <!-- found, so create the ID -->
          <ID><xsl:value-of select="name"/></ID>
      </xsl:if>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  
xml-cocoon2/src/webapp/samples/authentication/stylesheets/simple-page2html.xsl
  
  Index: simple-page2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
    <xsl:template match="page">
      <html>
        <head>
          <title>
            <xsl:value-of select="title"/>
          </title>
          <META content="0" http-equiv="expires"/>
          <META content="nocache" http-equiv="pragma"/>
        </head>
        <body bgcolor="white" alink="red" link="blue" vlink="blue">
          <xsl:apply-templates/>
        </body>
      </html>
    </xsl:template>
  
    <xsl:template match="title">
      <h2 style="color: navy; text-align: center">
        <xsl:apply-templates/>
      </h2>
    </xsl:template>
  
    <xsl:template match="para">
      <p align="center">
        <i><xsl:apply-templates/></i>
      </p>
    </xsl:template>
  
    <xsl:template match="form">
      <form method="POST" action="{@target}">
        <xsl:apply-templates/>
      </form>
    </xsl:template>
  
    <xsl:template match="input">
      <center>
        <xsl:value-of select="@title"/>
        <input type="{@type}" name="{@name}" value="{.}"/>
      </center><br/>
    </xsl:template>
  
    <xsl:template match="linkbar">
      <center>
        [
        <a href="login"> login </a>
        |
        <a href="protected"> protected </a>
        |
        <a href="do-logout"> logout </a>
        ]
      </center>
    </xsl:template>
  
  </xsl:stylesheet>
  <!-- vim: set et ts=2 sw=2: -->
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to