jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r627262 [1/2] - /incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/
Date Wed, 13 Feb 2008 06:15:49 GMT
Author: ajaquith
Date: Tue Feb 12 22:15:47 2008
New Revision: 627262

URL: http://svn.apache.org/viewvc?rev=627262&view=rev
Log:
Initial commit.

Added:
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Captcha.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Comment.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/CookieError.jsp   (with props)
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Delete.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/DeleteGroup.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Diff.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Edit.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/EditGroup.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Error.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Group.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Install.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Login.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LoginForm.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Logout.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LostPassword.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Message.jsp   (with props)
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewBlogEntry.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewGroup.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageInfo.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageModified.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Preview.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Rename.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Search.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/SisterSites.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Upload.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/UserPreferences.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Vote.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Wiki.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Workflow.jsp
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/atom.css
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/rss.jsp

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Captcha.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Captcha.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Captcha.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Captcha.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,88 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="org.apache.commons.httpclient.*" %>
+<%@ page import="org.apache.commons.httpclient.methods.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
+<%@ page import="org.apache.commons.lang.time.StopWatch" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    String content = request.getParameter("text");
+
+    if( content != null )
+    {
+        String ticket = request.getParameter("Asirra_Ticket");
+        HttpClient client = new HttpClient();
+        HttpMethod method = new GetMethod("http://challenge.asirra.com/cgi/Asirra?action=ValidateTicket&ticket="+ticket);
+
+        int status = client.executeMethod(method);
+        String body = method.getResponseBodyAsString();
+
+        if( status == HttpStatus.SC_OK )
+        {
+            if( body.indexOf("Pass") != -1 )
+            {
+                session.setAttribute("captcha","ok");
+                response.sendRedirect( wikiContext.getURL(WikiContext.EDIT, request.getParameter("page") ) );
+                return;
+            }
+        }
+
+        response.sendRedirect("Message.jsp?message=NOK");
+    }
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+%>
+<html>
+
+<head>
+  <title><wiki:Variable var="applicationname" />: <wiki:PageName /></title>
+  <%-- <wiki:Include page="commonheader.jsp"/> --%>
+  <meta name="robots" content="noindex,nofollow" />
+  <script type="text/javascript">
+    function HumanCheckComplete(isHuman)
+    {
+       if (isHuman)
+       {
+          formElt = document.getElementById("mainForm");
+          formElt.submit();
+       }
+       else
+       {
+          alert("Please correctly identify the cats.");
+          return false;
+       }
+    }
+   </script>
+</head>
+<body>
+<div style="margin:8px">
+   <p>We believe you may be a robot or a spammer.  Could you please pick out the kittens from the below
+   set of images, so we know you are a normal human being?</p>
+
+   <form action="<wiki:Link jsp='Captcha.jsp' format='url'/>" method="post" id="mainForm">
+      <input type="hidden" value="foo" name="text" />
+      <input type="hidden" value='<%=request.getParameter("page")%>' name='page'/>
+      <script type="text/javascript" src="http://challenge.asirra.com/js/AsirraClientSide.js"></script>
+      <script type="text/javascript">
+         asirraState.SetEnlargedPosition("right");
+         // asirraState.SetCellsPerRow(6);
+      </script>
+      <br />
+      <input type="button" value="Submit" onclick="javascript:Asirra_CheckIfHuman(HumanCheckComplete)" />
+  </form>
+
+</div>
+</body>
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Comment.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Comment.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Comment.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Comment.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,283 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.filters.*" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="com.ecyrd.jspwiki.htmltowiki.HtmlStringToWikiTranslator" %>
+<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
+<%@ page import="com.ecyrd.jspwiki.util.HttpUtil" %>
+<%@ page import="com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.DecisionRequiredException" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ page import="javax.servlet.http.Cookie" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+
+	String findParam( PageContext ctx, String key )
+	{
+	    ServletRequest req = ctx.getRequest();
+	
+	    String val = req.getParameter( key );
+	
+	    if( val == null )
+	    {
+	        val = (String)ctx.findAttribute( key );
+	    }
+	
+	    return val;
+	}
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.COMMENT );
+    if( !wikiContext.hasAccess( response ) ) return;
+    String pagereq = wikiContext.getName();
+
+    ResourceBundle rb = wikiContext.getBundle("CoreResources");
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    String storedUser = wikiSession.getUserPrincipal().getName();
+
+    if( wikiSession.isAnonymous() )
+    {
+        storedUser  = TextUtil.replaceEntities( request.getParameter( "author" ) );
+    }
+
+    String ok      = request.getParameter("ok");
+    String preview = request.getParameter("preview");
+    String cancel  = request.getParameter("cancel");
+    String author  = TextUtil.replaceEntities( request.getParameter("author") );
+    String link    = TextUtil.replaceEntities( request.getParameter("link") );
+    String remember = request.getParameter("remember");
+    String changenote = TextUtil.replaceEntities( request.getParameter( "changenote" ) );
+
+    WikiPage wikipage = wikiContext.getPage();
+    WikiPage latestversion = wiki.getPage( pagereq );
+    if( latestversion == null )
+    {
+        latestversion = wikiContext.getPage();
+    }
+
+    //
+    //  Setup everything for the editors and possible preview.  We store everything in the
+    //  session.
+    //
+
+    if( remember == null )
+    {
+        remember = (String)session.getAttribute("remember");
+    }
+
+    if( remember == null ) remember = "false";
+
+    session.setAttribute("remember",remember);
+
+    if( author == null )
+    {
+        author = storedUser;
+    }
+    if( author == null || author.length() == 0 ) author = "AnonymousCoward";
+
+    session.setAttribute("author",author);
+
+    if( link == null )
+    {
+        link = HttpUtil.retrieveCookieValue( request, "link" );
+        if( link == null ) link = "";
+    }
+
+    session.setAttribute( "link", link );
+
+    //
+    //  Branch
+    //
+    log.debug("preview="+preview+", ok="+ok);
+
+    if( ok != null )
+    {
+        log.info("Saving page "+pagereq+". User="+storedUser+", host="+request.getRemoteAddr() );
+
+        //  Modifications are written here before actual saving
+
+        WikiPage modifiedPage = (WikiPage)wikiContext.getPage().clone();
+
+        //  FIXME: I am not entirely sure if the JSP page is the
+        //  best place to check for concurrent changes.  It certainly
+        //  is the best place to show errors, though.
+
+        String spamhash = request.getParameter( SpamFilter.getHashFieldName(request) );
+        
+        if( !SpamFilter.checkHash(wikiContext,pageContext) )
+        {
+            return;
+        }
+        
+        //
+        //  We expire ALL locks at this moment, simply because someone has
+        //  already broken it.
+        //
+        PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
+        wiki.getPageManager().unlockPage( lock );
+        session.removeAttribute( "lock-"+pagereq );
+
+        //
+        //  Set author and changenote information
+        //
+
+        modifiedPage.setAuthor( storedUser );
+
+        if( changenote == null ) changenote = (String) session.getAttribute("changenote");
+
+        session.removeAttribute("changenote");
+
+        modifiedPage.setAttribute( WikiPage.CHANGENOTE, "Comment by "+storedUser );
+
+        //
+        //  Build comment part
+        //
+
+        StringBuffer pageText = new StringBuffer(wiki.getPureText( wikipage ));
+
+        log.debug("Page initial contents are "+pageText.length()+" chars");
+
+        //
+        //  Add a line on top only if we need to separate it from the content.
+        //
+        if( pageText.length() > 0 )
+        {
+            pageText.append( "\n\n----\n\n" );
+        }
+        
+        String commentText = EditorManager.getEditedText(pageContext);
+        
+        //
+        //  WYSIWYG editor sends us its greetings
+        //
+        String htmlText = findParam( pageContext, "htmlPageText" );
+        if( htmlText != null && cancel == null )
+        {
+        	commentText = new HtmlStringToWikiTranslator().translate(htmlText,wikiContext);
+        }
+        
+        pageText.append( commentText );
+
+        log.debug("Author name ="+author);
+        if( author != null && author.length() > 0 )
+        {
+            String signature = author;
+
+            if( link != null && link.length() > 0 )
+            {
+                link = HttpUtil.guessValidURI( link );
+
+                signature = "["+author+"|"+link+"]";
+            }
+
+            Calendar cal = Calendar.getInstance();
+            SimpleDateFormat fmt = new SimpleDateFormat("dd-MMM-yyyy");
+
+            pageText.append("\n\n--"+signature+", "+fmt.format(cal.getTime()));
+        }
+
+        if( TextUtil.isPositive(remember) )
+        {
+            if( link != null )
+            {
+                Cookie linkcookie = new Cookie("link", link);
+                linkcookie.setMaxAge(1001*24*60*60);
+                response.addCookie( linkcookie );
+            }
+
+            CookieAssertionLoginModule.setUserCookie( response, author );
+        }
+        else
+        {
+            session.removeAttribute("link");
+            session.removeAttribute("author");
+        }
+
+        try
+        {
+            wikiContext.setPage( modifiedPage );
+            wiki.saveText( wikiContext, pageText.toString() );
+        }
+        catch( DecisionRequiredException e )
+        {
+        	String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
+            response.sendRedirect( redirect );
+            return;
+        }
+        catch( RedirectException e )
+        {
+            session.setAttribute( VariableManager.VAR_MSG, e.getMessage() );
+            response.sendRedirect( e.getRedirect() );
+            return;
+        }
+        response.sendRedirect(wiki.getViewURL(pagereq));
+        return;
+    }
+    else if( preview != null )
+    {
+        log.debug("Previewing "+pagereq);
+        session.setAttribute(EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext));
+        response.sendRedirect( TextUtil.replaceString( wiki.getURL(WikiContext.PREVIEW, pagereq, "action=comment", false),"&amp;","&") );
+        return;
+    }
+    else if( cancel != null )
+    {
+        log.debug("Cancelled editing "+pagereq);
+        PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
+
+        if( lock != null )
+        {
+            wiki.getPageManager().unlockPage( lock );
+            session.removeAttribute( "lock-"+pagereq );
+        }
+        response.sendRedirect( wiki.getViewURL(pagereq) );
+        return;
+    }
+
+    log.info("Commenting page "+pagereq+". User="+request.getRemoteUser()+", host="+request.getRemoteAddr() );
+
+    //
+    //  Determine and store the date the latest version was changed.  Since
+    //  the newest version is the one that is changed, we need to track
+    //  that instead of the edited version.
+    //
+    long lastchange = 0;
+
+    Date d = latestversion.getLastModified();
+    if( d != null ) lastchange = d.getTime();
+
+    pageContext.setAttribute( "lastchange",
+                              Long.toString( lastchange ),
+                              PageContext.REQUEST_SCOPE );
+
+    //  This is a hack to get the preview to work.
+    // pageContext.setAttribute( "comment", Boolean.TRUE, PageContext.REQUEST_SCOPE );
+
+    //
+    //  Attempt to lock the page.
+    //
+    PageLock lock = wiki.getPageManager().lockPage( wikipage,
+                                                    storedUser );
+
+    if( lock != null )
+    {
+        session.setAttribute( "lock-"+pagereq, lock );
+    }
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    response.setHeader( "Cache-control", "max-age=0" );
+    response.setDateHeader( "Expires", new Date().getTime() );
+    response.setDateHeader( "Last-Modified", new Date().getTime() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "EditTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" />

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/CookieError.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/CookieError.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/CookieError.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/CookieError.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,14 @@
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context; authorization check not needed
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+ 
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "CookieErrorTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />

Propchange: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/CookieError.jsp
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Delete.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Delete.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Delete.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Delete.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,74 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="java.util.*" %>
+<%@ page import="com.ecyrd.jspwiki.attachment.Attachment" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.DELETE );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    WikiPage wikipage      = wikiContext.getPage();
+    WikiPage latestversion = wiki.getPage( pagereq );
+
+    String delete = request.getParameter( "delete" );
+    String deleteall = request.getParameter( "delete-all" );
+
+    if( latestversion == null )
+    {
+        latestversion = wikiContext.getPage();
+    }
+
+    // If deleting an attachment, go to the parent page.
+    String redirTo = pagereq;
+    if( wikipage instanceof Attachment ) {
+        redirTo = ((Attachment)wikipage).getParentName();
+    }
+
+    if( deleteall != null )
+    {
+        log.info("Deleting page "+pagereq+". User="+request.getRemoteUser()+", host="+request.getRemoteAddr() );
+
+        wiki.deletePage( pagereq );
+        response.sendRedirect(wiki.getViewURL(redirTo));
+        return;
+    }
+    else if( delete != null )
+    {
+        log.info("Deleting a range of pages from "+pagereq);
+        
+        for( Enumeration params = request.getParameterNames(); params.hasMoreElements(); )
+        {
+            String paramName = (String)params.nextElement();
+            
+            if( paramName.startsWith("delver") )
+            {
+                int version = Integer.parseInt( paramName.substring(7) );
+                
+                WikiPage p = wiki.getPage( pagereq, version );
+                
+                log.debug("Deleting version "+version);
+                wiki.deleteVersion( p );
+            }
+        }
+        
+        response.sendRedirect(wiki.getURL( WikiContext.INFO, redirTo, null, false ));
+        return; 
+    }
+
+    // Set the content type and include the response content
+    // FIXME: not so.
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "EditTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/DeleteGroup.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/DeleteGroup.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/DeleteGroup.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/DeleteGroup.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,56 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.NoSuchPrincipalException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.WikiSecurityException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.GroupManager" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.DELETE_GROUP );
+    if(!wikiContext.hasAccess( response )) return;
+
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getGroupManager();
+    String name = request.getParameter( "group" );
+    
+    if ( name == null )
+    {
+        // Group parameter was null
+        wikiSession.addMessage( GroupManager.MESSAGES_KEY, "Parameter 'group' cannot be null." );
+        response.sendRedirect( "Group.jsp" );
+    }
+
+    // Check that the group exists first
+    try
+    {
+        groupMgr.getGroup( name );
+    }
+    catch ( NoSuchPrincipalException e )
+    {
+        // Group does not exist
+        wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+        response.sendRedirect( "Group.jsp" );
+    }
+
+    // Now, let's delete the group
+    try 
+    {
+        groupMgr.removeGroup( name );
+        response.sendRedirect( "." );
+    }
+    catch ( WikiSecurityException e )
+    {
+        // Send error message
+        wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+        response.sendRedirect( "Group.jsp" );
+    }
+
+%>
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Diff.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Diff.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Diff.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Diff.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,74 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ page import="com.ecyrd.jspwiki.tags.InsertDiffTag" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.DIFF );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    WatchDog w = wiki.getCurrentWatchDog();
+    try
+    {
+    w.enterState("Generating INFO response",60);
+    
+    // Notused ? 
+    // String pageurl = wiki.encodeName( pagereq );
+
+    // If "r1" is null, then assume current version (= -1)
+    // If "r2" is null, then assume the previous version (=current version-1)
+
+    // FIXME: There is a set of unnecessary conversions here: InsertDiffTag
+    //        does the String->int conversion anyway.
+
+    WikiPage wikipage = wikiContext.getPage();
+
+    String srev1 = request.getParameter("r1");
+    String srev2 = request.getParameter("r2");
+
+    int ver1 = -1, ver2 = -1;
+
+    if( srev1 != null )
+    {
+        ver1 = Integer.parseInt( srev1 );
+    }
+
+    if( srev2 != null )
+    {
+        ver2 = Integer.parseInt( srev2 );
+    }
+    else
+    {
+        int lastver = wikipage.getVersion();
+
+        if( lastver > 1 )
+        {
+            ver2 = lastver-1;
+        }
+    }
+
+    pageContext.setAttribute( InsertDiffTag.ATTR_OLDVERSION,
+                              new Integer(ver1),
+                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( InsertDiffTag.ATTR_NEWVERSION,
+                              new Integer(ver2),
+                              PageContext.REQUEST_SCOPE );
+
+    // log.debug("Request for page diff for '"+pagereq+"' from "+request.getRemoteAddr()+" by "+request.getRemoteUser()+".  R1="+ver1+", R2="+ver2 );
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+<% } finally { w.exitState(); } %>
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Edit.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Edit.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Edit.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Edit.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,269 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.filters.*" %>
+<%@ page import="java.util.*" %>
+<%@ page import="com.ecyrd.jspwiki.htmltowiki.HtmlStringToWikiTranslator" %>
+<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.DecisionRequiredException" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+
+    String findParam( PageContext ctx, String key )
+    {
+        ServletRequest req = ctx.getRequest();
+
+        String val = req.getParameter( key );
+
+        if( val == null )
+        {
+            val = (String)ctx.findAttribute( key );
+        }
+
+        return val;
+    }
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    String user = wikiSession.getUserPrincipal().getName();
+    String action  = request.getParameter("action");
+    String ok      = request.getParameter("ok");
+    String preview = request.getParameter("preview");
+    String cancel  = request.getParameter("cancel");
+    String append  = request.getParameter("append");
+    String edit    = request.getParameter("edit");
+    String author  = TextUtil.replaceEntities( findParam( pageContext, "author" ) );
+    String changenote = TextUtil.replaceEntities( findParam( pageContext, "changenote" ) );
+    String text    = EditorManager.getEditedText( pageContext );
+    String link    = TextUtil.replaceEntities( findParam( pageContext, "link") );
+    String spamhash = findParam( pageContext, SpamFilter.getHashFieldName(request) );
+    String captcha = (String)session.getAttribute("captcha");
+
+    if ( !wikiSession.isAuthenticated() && wikiSession.isAnonymous()
+         && author != null )
+    {
+        user  = TextUtil.replaceEntities( findParam( pageContext, "author" ) );
+    }
+
+    //
+    //  WYSIWYG editor sends us its greetings
+    //
+    String htmlText = findParam( pageContext, "htmlPageText" );
+    if( htmlText != null && cancel == null )
+    {
+        text = new HtmlStringToWikiTranslator().translate(htmlText,wikiContext);
+    }
+
+    WikiPage wikipage = wikiContext.getPage();
+    WikiPage latestversion = wiki.getPage( pagereq );
+
+    if( latestversion == null )
+    {
+        latestversion = wikiContext.getPage();
+    }
+
+    //
+    //  Set the response type before we branch.
+    //
+
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    response.setHeader( "Cache-control", "max-age=0" );
+    response.setDateHeader( "Expires", new Date().getTime() );
+    response.setDateHeader( "Last-Modified", new Date().getTime() );
+
+    //log.debug("Request character encoding="+request.getCharacterEncoding());
+    //log.debug("Request content type+"+request.getContentType());
+    log.debug("preview="+preview+", ok="+ok);
+
+    if( ok != null || captcha != null )
+    {
+        log.info("Saving page "+pagereq+". User="+user+", host="+request.getRemoteAddr() );
+
+        //
+        //  Check for session expiry
+        //
+        
+        if( !SpamFilter.checkHash(wikiContext,pageContext) )
+        {
+            return;
+        }
+        
+        WikiPage modifiedPage = (WikiPage)wikiContext.getPage().clone();
+
+        //  FIXME: I am not entirely sure if the JSP page is the
+        //  best place to check for concurrent changes.  It certainly
+        //  is the best place to show errors, though.
+
+        String h = SpamFilter.getSpamHash( latestversion, request );
+
+        if( !h.equals(spamhash) )
+        {
+            //
+            // Someone changed the page while we were editing it!
+            //
+
+            log.info("Page changed, warning user.");
+
+            session.setAttribute( EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext) );
+            response.sendRedirect( wiki.getURL(WikiContext.CONFLICT, pagereq, null, false) );
+            return;
+        }
+
+        //
+        //  We expire ALL locks at this moment, simply because someone has
+        //  already broken it.
+        //
+        PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
+        wiki.getPageManager().unlockPage( lock );
+        session.removeAttribute( "lock-"+pagereq );
+
+        //
+        //  Set author information and other metadata
+        //
+
+        modifiedPage.setAuthor( user );
+
+        if( changenote == null ) changenote = (String) session.getAttribute("changenote");
+
+        session.removeAttribute("changenote");
+
+        if( changenote != null && changenote.length() > 0 )
+        {
+            modifiedPage.setAttribute( WikiPage.CHANGENOTE, changenote );
+        }
+        else
+        {
+            modifiedPage.removeAttribute( WikiPage.CHANGENOTE );
+        }
+
+        //
+        //  Figure out the actual page text
+        //
+
+        if( text == null )
+        {
+            throw new ServletException( "No parameter text set!" );
+        }
+
+        //
+        //  If this is an append, then we just append it to the page.
+        //  If it is a full edit, then we will replace the previous contents.
+        //
+
+        try
+        {
+            wikiContext.setPage( modifiedPage );
+
+            if( captcha != null )
+            {
+                wikiContext.setVariable( "captcha", Boolean.TRUE );
+                session.removeAttribute( "captcha" );
+            }
+
+            if( append != null )
+            {
+                StringBuffer pageText = new StringBuffer(wiki.getText( pagereq ));
+
+                pageText.append( text );
+
+                wiki.saveText( wikiContext, pageText.toString() );
+            }
+            else
+            {
+                wiki.saveText( wikiContext, text );
+            }
+        }
+        catch( DecisionRequiredException ex )
+        {
+        	String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
+            response.sendRedirect( redirect );
+            return;
+        }
+        catch( RedirectException ex )
+        {
+            // FIXME: Cut-n-paste code.
+            wikiContext.getWikiSession().addMessage( ex.getMessage() ); // FIXME: should work, but doesn't
+            session.setAttribute( "message", ex.getMessage() );
+            session.setAttribute(EditorManager.REQ_EDITEDTEXT,
+                                 EditorManager.getEditedText(pageContext));
+            session.setAttribute("author",user);
+            session.setAttribute("link",link != null ? link : "" );
+            if( htmlText != null ) session.setAttribute( EditorManager.REQ_EDITEDTEXT, text );
+
+            session.setAttribute("changenote", changenote != null ? changenote : "" );
+            session.setAttribute(SpamFilter.getHashFieldName(request), spamhash);
+            response.sendRedirect( ex.getRedirect() );
+            return;
+        }
+
+        response.sendRedirect(wiki.getViewURL(pagereq));
+        return;
+    }
+    else if( preview != null )
+    {
+        log.debug("Previewing "+pagereq);
+        session.setAttribute(EditorManager.REQ_EDITEDTEXT,
+                             EditorManager.getEditedText(pageContext));
+        session.setAttribute("author",user);
+        session.setAttribute("link",link != null ? link : "" );
+
+        if( htmlText != null ) session.setAttribute( EditorManager.REQ_EDITEDTEXT, text );
+
+        session.setAttribute("changenote", changenote != null ? changenote : "" );
+        response.sendRedirect( wiki.getURL(WikiContext.PREVIEW,pagereq,null,false) );
+        return;
+    }
+    else if( cancel != null )
+    {
+        log.debug("Cancelled editing "+pagereq);
+        PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
+
+        if( lock != null )
+        {
+            wiki.getPageManager().unlockPage( lock );
+            session.removeAttribute( "lock-"+pagereq );
+        }
+        response.sendRedirect( wiki.getViewURL(pagereq) );
+        return;
+    }
+
+    session.removeAttribute( EditorManager.REQ_EDITEDTEXT );
+
+    log.info("Editing page "+pagereq+". User="+user+", host="+request.getRemoteAddr() );
+
+    //
+    //  Determine and store the date the latest version was changed.  Since
+    //  the newest version is the one that is changed, we need to track
+    //  that instead of the edited version.
+    //
+    String lastchange = SpamFilter.getSpamHash( latestversion, request );
+
+    pageContext.setAttribute( "lastchange",
+                              lastchange,
+                              PageContext.REQUEST_SCOPE );
+
+    //
+    //  Attempt to lock the page.
+    //
+    PageLock lock = wiki.getPageManager().lockPage( wikipage,
+                                                    user );
+
+    if( lock != null )
+    {
+        session.setAttribute( "lock-"+pagereq, lock );
+    }
+
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "EditTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/EditGroup.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/EditGroup.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/EditGroup.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/EditGroup.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,66 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.WikiSecurityException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.Group" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.GroupManager" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT_GROUP );
+    if(!wikiContext.hasAccess( response )) return;
+    
+    // Extract the current user, group name, members and action attributes
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getGroupManager();
+    Group group = null;
+    try 
+    {
+        group = groupMgr.parseGroup( wikiContext, false );
+        pageContext.setAttribute ( "Group", group, PageContext.REQUEST_SCOPE );
+    }
+    catch ( WikiSecurityException e )
+    {
+        wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+        response.sendRedirect( "Group.jsp" );
+    }
+    
+    // Are we saving the group?
+    if( "save".equals(request.getParameter("action")) )
+    {
+        // Validate the group
+        groupMgr.validateGroup( wikiContext, group );
+
+        // If no errors, save the group now
+        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 )
+        {
+            try
+            {
+                groupMgr.setGroup( wikiSession, group );
+            }
+            catch( WikiSecurityException e )
+            {
+                // Something went horribly wrong! Maybe it's an I/O error...
+                wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+            }
+        }
+        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 )
+        {
+            response.sendRedirect( "Group.jsp?group=" + group.getName() );
+            return;
+        }
+    }
+        
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "EditTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Error.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Error.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Error.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Error.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,83 @@
+<%@ page isErrorPage="true" %>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    WikiContext wikiContext = wiki.createContext( request, 
+                                                  WikiContext.ERROR );
+    String pagereq = wikiContext.getName();
+
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+
+    String msg = "An unknown error was caught by Error.jsp";
+
+    Throwable realcause = null;
+
+    if( exception != null )        
+    {   
+        msg = exception.getMessage();
+        if( msg == null || msg.length() == 0 )
+        {
+            msg = "An unknown exception "+exception.getClass().getName()+" was caught by Error.jsp.";
+        }
+
+        //
+        //  This allows us to get the actual cause of the exception.
+        //  Note the cast; at least Tomcat has two classes called "JspException"
+        //  imported in JSP pages.
+        //
+
+
+        if( exception instanceof javax.servlet.jsp.JspException )
+        {
+            log.debug("IS JSPEXCEPTION");
+            realcause = ((javax.servlet.jsp.JspException)exception).getRootCause();
+            log.debug("REALCAUSE="+realcause);
+        }
+
+        if( realcause == null ) realcause = exception;    
+    }
+    else
+    {
+        realcause = new Exception("Unknown general exception");
+    }
+
+    log.debug("Error.jsp exception is: ",exception);
+
+
+    wikiContext.getWikiSession().addMessage( msg );
+%>
+
+   <h3>JSPWiki has detected an error</h3>
+
+   <dl>
+      <dt><b>Error Message</b></dt>
+      <dd>
+         <wiki:Messages div="error" />
+      </dd>      
+      <dt><b>Exception</b></dt>
+      <dd><%=realcause.getClass().getName()%></dd>
+      <dt><b>Place where detected</b></dt>
+      <dd><%=FileUtil.getThrowingMethod(realcause)%></dd>
+   </dl>
+   <p>
+   If you have changed the templates, please do check them.  This error message
+   may show up because of that.  If you have not changed them, and you are
+   either installing JSPWiki for the first time or have changed configuration,
+   then you might want to check your configuration files.  If you are absolutely sure
+   that JSPWiki was running quite okay or you can't figure out what is going
+   on, then by all means, come over to <a href="http://www.jspwiki.org/">jspwiki.org</a>
+   and tell us.  There is more information in the log file (like the full stack trace, 
+   which you should add to any error report).
+   </p>
+   <p>
+   And don't worry - it's just a computer program.  Nothing really
+   serious is probably going on: at worst you can lose a few nights
+   sleep.  It's not like it's the end of the world.
+   </p>
+
+   <br clear="all" />

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Group.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Group.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Group.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Group.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,44 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.NoSuchPrincipalException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.WikiSecurityException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.Group" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.GroupManager" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW_GROUP );
+    if(!wikiContext.hasAccess( response )) return;
+    
+    // Extract the current user, group name, members
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getGroupManager();
+    Group group = null;
+    try 
+    {
+        group = groupMgr.parseGroup( wikiContext, false );
+        pageContext.setAttribute ( "Group", group, PageContext.REQUEST_SCOPE );
+    }
+    catch ( NoSuchPrincipalException e )
+    {
+        // New group; let GroupContent print out the message...
+    }
+    catch ( WikiSecurityException e )
+    {
+        wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+    }
+    
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Install.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Install.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Install.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Install.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.AuthenticationManager" %>
+<%@ page import="com.ecyrd.jspwiki.ui.Installer" %>
+<%@ page import="org.apache.log4j.*" %>
+
+<%!
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+// Create wiki context and check for authorization
+WikiContext wikiContext = wiki.createContext( request, WikiContext.INSTALL );
+if(!wikiContext.hasAccess( response )) return;
+
+Installer installer = new Installer( request, config );
+WikiSession wikiSession = wikiContext.getWikiSession();
+
+// Parse the existing properties
+installer.parseProperties();
+boolean validated = false;
+String password = null;
+
+// If user hit "submit" button, validate and install them
+if( request.getParameter("submit") != null )
+{
+    validated = installer.validateProperties();
+    if ( validated )
+    {
+        installer.saveProperties();
+        password = installer.createAdministrator();
+        if ( password != null )
+        {
+            wikiSession.addMessage( Installer.INSTALL_INFO, "Because no administrator account "
+              + "exists yet, JSPWiki created one for you, with a random password. You can change "
+              + "this password later, of course. The account's id is <strong>" + Installer.ADMIN_ID
+              + "</strong> and the password is <strong>" + password + "</strong>. "
+              + "<em>Please write this information down and keep it in a safe place</em>. "
+              + "JSPWiki also created a wiki group called <strong>" + Installer.ADMIN_GROUP
+              + "</strong> that contains this user." );
+       }
+    }
+}
+
+if ( !installer.adminExists() )
+{
+    wikiSession.addMessage( Installer.INSTALL_WARNING, "Is this the first time you've run the "
+        + " Installer? If it is, you should know that after JSPWiki validates and saves your " 
+        + "configuration for the first time, you will need administrative privileges to access "
+        + "this page again. We do this to prevent random people on the Internet from doing bad "
+        + "things to your wiki." );
+}
+
+    // Make this HTTP response non-cached, and never-expiring
+    response.addHeader("Pragma", "no-cache");
+    response.setHeader( "Expires", "-1" );
+    response.setHeader("Cache-Control", "no-cache" );
+    response.setContentType("text/html; charset=UTF-8");
+%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+  <title>JSPWiki Installer</title>
+  <link rel="stylesheet" media="screen, projection" type="text/css" href="<wiki:Link format="url" templatefile="jspwiki.css"/>"/>
+  <wiki:IncludeResources type="stylesheet"/>
+</head>
+<body class="view">
+<div id="wikibody">
+<div id="page">
+<div id="pagecontent">
+
+<h1>JSPWiki Installer</h1>
+
+<p>Welcome!  This little JSP page is here to help you do the first difficult stage of JSPWiki
+installation.  If you're seeing this page, you have already installed JSPWiki correctly
+inside your container.</p>
+
+<p>There are now some things that you should configure.  When you press submit, the
+<code>jspwiki.properties</code> file from the distribution will be modified, or if it 
+can't be found, a new one will be created.</p>
+
+<p>This setup system is really meant for people who just want to be up and running really quickly.
+If you want to integrate JSPWiki with an existing system, I would recommend that you go and edit
+the <code>jspwiki.properties</code> file directly.  You can find a sample config file from 
+<code>yourwiki/WEB-INF/</code>.</p>
+
+<!-- Any messages or errors? -->
+<div class="instructions">
+  <wiki:Messages div="information" topic="<%=Installer.INSTALL_INFO%>" prefix="Good news:"/>
+  <wiki:Messages div="warning" topic="<%=Installer.INSTALL_WARNING%>" prefix="Warning: "/>
+  <wiki:Messages div="error" topic="<%=Installer.INSTALL_ERROR%>" prefix="Could not save configuration: "/>
+</div>
+ 
+<div class="formcontainer">
+
+<form action="Install.jsp" method="post">
+
+  <!-- Page and log directories -->
+  <h3>Basics</h3>
+  <div class="block">
+  
+    <label>Application Name</label>
+    <input type="text" name="<%=Installer.APP_NAME%>" size="20" value="<%=installer.getProperty( Installer.APP_NAME )%>"/><br />
+    <div class="description">
+      What should your wiki be called?  Try and make this a relatively short name.
+    </div>
+    
+    <label>Base URL</label>
+    <input type="text" name="<%=Installer.BASE_URL%>" size="40" value="<%=installer.getProperty( Installer.BASE_URL )%>"/><br />
+    <div class="description">
+      Please tell JSPWiki where your wiki is located.
+    </div>
+    
+    <label>Page storage</label>
+    <input type="text" name="<%=Installer.PAGE_DIR%>" size="40" value="<%=installer.getProperty( Installer.PAGE_DIR )%>"/><br />
+    <div class="description">
+      By default, JSPWiki will use the VersioningFileProvider that stores files in a particular
+      directory on your hard drive. If you specify a directory that does not exist, JSPWiki will
+      create one for you. All attachments will also be put in the same directory.
+    </div>
+    
+  </div>
+  
+  <h3>Security</h3>
+  <div class="block">
+  
+    <label>Security configuration</label><br/>
+    <input type="radio" name="<%=AuthenticationManager.PROP_SECURITY%>" value="<%=AuthenticationManager.SECURITY_JAAS%>" checked="checked"/>
+      JAAS plus container security (default)<br/>
+    <input type="radio" name="<%=AuthenticationManager.PROP_SECURITY%>" value="<%=AuthenticationManager.SECURITY_OFF%>"/>
+      Container security only
+   <div class="description">
+     By default, JSPWiki manages access to resources using a JAAS-based security system. 
+     It will also respect any container security constraints you might have,
+     if you've enabled them in your <code>web.xml</code> file. If you disable JAAS security,
+     JSPWiki might not work as you expect. But sometimes you might want to do this if you're
+     trying to troubleshoot.
+   </div>
+  
+    <% 
+      if( validated )
+      {
+        if ( password != null )
+        {
+    %>
+      <label>Administrator account</label>
+      <p>Enabled</p>
+      <div class="description">
+        This wiki has an administrator account named <strong>admin</strong> that is part of
+        the wiki group <strong>Admin</strong>. By default, JSPWiki's security policy grants 
+        all members of the Admin group the all-powerful <code>AllPermission</code>.
+      </div>
+    <%
+        }
+      }
+      else
+      {
+    %>
+      <label>Administrator account</label>
+      <p>Not enabled</p>
+      <div class="description">
+        This wiki doesn't seem to have an administrator account. When you click <em>Configure!</em>,
+        JSPWiki will create one for you.
+      </div>
+    <%
+      }
+    %>
+  </div>
+  
+  <h3>Advanced Settings</h3>
+  <div class="block">
+    <label>Log files</label>
+    <input type="text" name="<%=Installer.LOG_DIR%>" value="<%=installer.getProperty( Installer.LOG_DIR )%>" size="40"/><br />
+    <div class="description">
+      JSPWiki uses Jakarta Log4j for logging.  Please tell JSPWiki where the log files should go.
+    </div>
+
+    <label>Work directory</label>
+    <input type="text" name="<%=Installer.WORK_DIR%>" size="40" value="<%=installer.getProperty( Installer.WORK_DIR )%>"/><br />
+    <div class="description">
+      This is the place where all caches and other runtime stuff is stored.
+    </div>
+  </div>
+    
+  <div class="block">
+    <div class="instructions">
+      After you click <em>Configure!</em>, the installer will write your settings to 
+      <code><%=installer.getPropertiesPath()%></code>. It will also create an 
+      Administrator account with a random password and a corresponding Admin group.
+    </div>
+    <input type="submit" name="submit" value="Configure!" />
+  </div>
+      
+</form>
+
+</div>
+
+<hr />
+    <% 
+      if( validated )
+      {
+    %>
+       <h3>Here is your new jspwiki.properties</h3>
+       <pre><%=installer.getProperties()%></pre>
+   <%
+     }
+   %>
+
+<!-- We're done... -->
+</div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Login.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Login.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Login.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Login.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,176 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="java.security.Principal" %>
+<%@ page import="com.ecyrd.jspwiki.auth.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule" %>
+<%@ page import="com.ecyrd.jspwiki.auth.login.CookieAuthenticationLoginModule" %>
+<%@ page import="com.ecyrd.jspwiki.auth.user.DuplicateUserException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.user.UserProfile" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.DecisionRequiredException" %>
+<%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ page import="java.util.*" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    AuthenticationManager mgr = wiki.getAuthenticationManager();
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.LOGIN );
+    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
+                              wikiContext,
+                              PageContext.REQUEST_SCOPE );
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    ResourceBundle rb = wikiContext.getBundle("CoreResources");
+
+    // Set the redirect-page variable if one was passed as a parameter
+    if( request.getParameter( "redirect" ) != null )
+    {
+        wikiContext.setVariable( "redirect", request.getParameter( "redirect" ) );
+    }
+    else
+    {
+        wikiContext.setVariable( "redirect", wiki.getFrontPage());
+    }
+
+    // Are we saving the profile?
+    if( "saveProfile".equals(request.getParameter("action")) )
+    {
+        UserManager userMgr = wiki.getUserManager();
+        UserProfile profile = userMgr.parseProfile( wikiContext );
+         
+        // Validate the profile
+        userMgr.validateProfile( wikiContext, profile );
+
+        // If no errors, save the profile now & refresh the principal set!
+        if ( wikiSession.getMessages( "profile" ).length == 0 )
+        {
+            try
+            {
+                userMgr.setUserProfile( wikiSession, profile );
+                CookieAssertionLoginModule.setUserCookie( response, profile.getFullname() );
+            }
+            catch( DuplicateUserException e )
+            {
+                // User collision! (full name or wiki name already taken)
+                wikiSession.addMessage( "profile", e.getMessage() );
+            }
+            catch( DecisionRequiredException e )
+            {
+                String redirect = wiki.getURL(WikiContext.VIEW,"ApprovalRequiredForUserProfiles",null,true);
+                response.sendRedirect( redirect );
+                return;
+            }
+            catch( WikiSecurityException e )
+            {
+                // Something went horribly wrong! Maybe it's an I/O error...
+                wikiSession.addMessage( "profile", e.getMessage() );
+            }
+        }
+        if ( wikiSession.getMessages( "profile" ).length == 0 )
+        {
+            String redirectPage = request.getParameter( "redirect" );
+            response.sendRedirect( wiki.getViewURL(redirectPage) );
+            return;
+        }
+    }
+
+    // If NOT using container auth, perform all of the access control logic here...
+    // (Note: if using the container for auth, it will handle all of this for us.)
+    if( !mgr.isContainerAuthenticated() )
+    {
+        // If user got here and is already authenticated, it means
+        // they just aren't allowed access to what they asked for.
+        // Weepy tears and hankies all 'round.
+        if( wikiSession.isAuthenticated() )
+        {
+            response.sendError( HttpServletResponse.SC_FORBIDDEN, rb.getString("login.error.noaccess") );
+            return;
+        }
+
+        // If using custom auth, we need to do the login now
+
+        String action = request.getParameter("action");
+        if( request.getParameter("submitlogin") != null )
+        {
+            String uid    = request.getParameter( "j_username" );
+            String passwd = request.getParameter( "j_password" );
+            log.debug( "Attempting to authenticate user " + uid );
+
+            // Log the user in!
+            if ( mgr.login( wikiSession, uid, passwd ) )
+            {
+                log.info( "Successfully authenticated user " + uid + " (custom auth)" );
+            }
+            else
+            {
+                log.info( "Failed to authenticate user " + uid );
+                wikiSession.addMessage( "login", rb.getString("login.error.password") );
+            }
+        }
+    }
+    else
+    {
+        //
+        //  Have we already been submitted?  If yes, then we can assume that
+        //  we have been logged in before.
+        //
+        Object seen = session.getAttribute("_redirect");
+        if( seen != null )
+        {
+            response.sendError( HttpServletResponse.SC_FORBIDDEN, rb.getString("login.error.noaccess") );
+            session.removeAttribute("_redirect");
+            return;
+        }
+        session.setAttribute("_redirect","I love Outi"); // Just any marker will do
+
+        // If using container auth, the container will have automatically
+        // attempted to log in the user before Login.jsp was loaded.
+        // Thus, if we got here, the container must have authenticated
+        // the user already. All we do is simply record that fact.
+        // Nice and easy.
+
+        Principal user = wikiSession.getLoginPrincipal();
+        log.info( "Successfully authenticated user " + user.getName() + " (container auth)" );
+    }
+
+    // If user logged in, set the user cookie with the wiki principal's name.
+    // redirect to wherever we're supposed to go. If login.jsp
+    // was called without parameters, this will be the front page. Otherwise,
+    // there's probably a 'page' parameter telling us where to go.
+
+    if( wikiSession.isAuthenticated() )
+    {
+        String rember = request.getParameter( "j_remember" );
+
+        // Set user cookie
+        Principal principal = wikiSession.getUserPrincipal();
+        CookieAssertionLoginModule.setUserCookie( response, principal.getName() );
+
+        if( rember != null )
+        {
+            CookieAuthenticationLoginModule.setLoginCookie( wiki, response, principal.getName() );
+        }
+
+        // If wiki page was "Login", redirect to main, otherwise use the page supplied
+        String redirectPage = request.getParameter( "redirect" );
+        if ( redirectPage == null )
+        {
+           redirectPage = wiki.getFrontPage();
+        }
+        String viewUrl = ( "Login".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL( redirectPage );
+
+        // Redirect!
+        log.info( "Redirecting user to " + viewUrl );
+        response.sendRedirect( viewUrl );
+        return;
+    }
+
+    // If we've gotten here, the user hasn't authenticated yet.
+    // So, find the login form and include it. This should be in the same directory
+    // as this page. We don't need to use the wiki:Include tag.
+
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+
+%><jsp:include page="LoginForm.jsp" />
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LoginForm.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LoginForm.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LoginForm.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LoginForm.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,40 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    /**
+     * This page contains the logic for finding and including
+       the correct login form, which is usually loaded from
+       the template directory's LoginContent.jsp page.
+       It should not be requested directly by users. If
+       container-managed authentication is in force, the container
+       will prevent direct access to it.
+     */
+    Logger log = Logger.getLogger("JSPWiki"); 
+
+%>
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Retrieve the Login page context, then go and find the login form
+
+    WikiContext wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, PageContext.REQUEST_SCOPE );
+    
+    // If no context, it means we're using container auth.  So, create one anyway
+    if( wikiContext == null )
+    {
+        wikiContext = wiki.createContext( request, WikiContext.LOGIN );
+        pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
+                                  wikiContext,
+                                  PageContext.REQUEST_SCOPE );
+    }
+    
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+                                                            
+    log.debug("Login template content is: " + contentPage);
+    
+%><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Logout.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Logout.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Logout.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Logout.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,17 @@
+<%@page import="com.ecyrd.jspwiki.auth.login.CookieAuthenticationLoginModule"%>
+<%@page import="com.ecyrd.jspwiki.WikiEngine" %>
+<%@page import="com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule" %>
+<%
+  WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+  wiki.getAuthenticationManager().logout( request );
+
+  // Clear the user cookie
+  CookieAssertionLoginModule.clearUserCookie( response );
+
+  // Delete the login cookie
+  CookieAuthenticationLoginModule.clearLoginCookie( wiki, request, response );
+
+  // Redirect to the webroot
+  // TODO: Should redirect to a "goodbye" -page?
+  response.sendRedirect(".");
+%>

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LostPassword.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LostPassword.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LostPassword.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/LostPassword.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,142 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.*" %>
+<%@ page import="javax.mail.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.user.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ page import="com.ecyrd.jspwiki.i18n.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase" %>
+<%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+
+    String message = null;
+    public boolean resetPassword(WikiEngine wiki, HttpServletRequest request, ResourceBundle rb )
+    {
+        // Reset pw for account name
+        String name = request.getParameter("name");
+        UserDatabase userDatabase = wiki.getUserManager().getUserDatabase();
+        boolean success = false;
+
+        try
+        {
+            UserProfile profile = null;
+/*
+// This is disabled because it would otherwise be possible to DOS JSPWiki instances
+// by requesting new passwords for all users.  See https://issues.apache.org/jira/browse/JSPWIKI-78
+            try
+            {
+                profile = userDatabase.find(name);
+            }
+            catch (NoSuchPrincipalException e)
+            {
+                // Try email as well
+            }
+ */
+            if( profile == null )
+            {
+                profile = userDatabase.findByEmail(name);
+            }
+ 
+			String email = profile.getEmail();
+
+			String randomPassword = TextUtil.generateRandomPassword();
+
+			// Try sending email first, as that is more likely to fail.
+
+            Object[] args = { profile.getLoginName(),
+                             randomPassword,
+                             wiki.getURLConstructor().makeURL(WikiContext.NONE, "Login.jsp", true, ""),
+                             wiki.getApplicationName()
+            };
+
+            String mailMessage = MessageFormat.format( rb.getString("lostpwd.newpassword.email"), args );
+
+            Object[] args2 = { wiki.getApplicationName() };
+ 			MailUtil.sendMessage( wiki,
+                                  email,
+ 			                      MessageFormat.format( rb.getString("lostpwd.newpassword.subject"), args2),
+ 			                      mailMessage );
+
+            log.info("User "+email+" requested and received a new password.");
+
+			// Mail succeeded.  Now reset the password.
+			// If this fails, we're kind of screwed, because we already emailed.
+			profile.setPassword(randomPassword);
+			userDatabase.save(profile);
+			userDatabase.commit();
+			success = true;
+        }
+        catch (NoSuchPrincipalException e)
+        {
+            Object[] args = { name };
+            message = MessageFormat.format( rb.getString("lostpwd.nouser"), args );
+            log.info("Tried to reset password for non-existent user '" + name + "'");
+        }
+        catch (SendFailedException e)
+        {
+            message = rb.getString("lostpwd.nomail");
+            log.error("Tried to reset password and got SendFailedException: " + e);
+        }
+        catch (AuthenticationFailedException e)
+        {
+            message = rb.getString("lostpwd.nomail");
+            log.error("Tried to reset password and got AuthenticationFailedException: " + e);
+        }
+        catch (Exception e)
+        {
+            message = rb.getString("lostpwd.nomail");
+            log.error("Tried to reset password and got another exception: " + e);
+        }
+        return success;
+    }
+%>
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+
+	//Create wiki context like in Login.jsp:
+    //don't check for access permissions: if you have lost your password you cannot login!
+	WikiContext wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, PageContext.REQUEST_SCOPE );
+
+	// If no context, it means we're using container auth.  So, create one anyway
+	if( wikiContext == null )
+	{
+	    wikiContext = wiki.createContext( request, WikiContext.LOGIN ); /* reuse login context ! */
+	    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
+	                              wikiContext,
+	                              PageContext.REQUEST_SCOPE );
+	}
+
+	ResourceBundle rb = wikiContext.getBundle("CoreResources");
+
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    String action  = request.getParameter("action");
+
+    boolean done = false;
+
+    if ((action != null) && (action.equals("resetPassword"))) {
+	    if ( resetPassword( wiki, request, rb ) ) {
+	        done = true;
+	        wikiSession.addMessage( "resetpw", rb.getString("lostpwd.emailed") );
+            pageContext.setAttribute("passwordreset","done");
+	    }
+	    else // Error
+	    {
+            wikiSession.addMessage( "resetpw", message);
+	    } 
+    }
+
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    response.setHeader( "Cache-control", "max-age=0" );
+    response.setDateHeader( "Expires", new Date().getTime() );
+    response.setDateHeader( "Last-Modified", new Date().getTime() );
+
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );                                                            
+%>
+<wiki:Include page="<%=contentPage%>" />
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Message.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Message.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Message.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Message.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,24 @@
+<%@ page isErrorPage="true" %>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    WikiContext wikiContext = wiki.createContext( request, 
+                                                  WikiContext.MESSAGE );
+
+    // Stash the wiki context and message text
+    request.setAttribute( WikiTagBase.ATTR_CONTEXT, wikiContext );
+    request.setAttribute( "message", request.getParameter("message"));
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file

Propchange: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Message.jsp
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewBlogEntry.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewBlogEntry.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewBlogEntry.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewBlogEntry.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,33 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.plugin.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context; no need to check for authorization since the 
+    // redirect will take care of that
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
+    String pagereq = wikiContext.getName();
+    
+    // Redirect if the request was for a 'special page'
+    String specialpage = wiki.getSpecialPageReference( pagereq );
+    if( specialpage != null )
+    {
+        // FIXME: Do Something Else
+        response.sendRedirect( specialpage );
+        return;
+    }
+
+    WeblogEntryPlugin p = new WeblogEntryPlugin();
+    
+    String newEntry = p.getNewEntryPage( wiki, pagereq );
+
+    // Redirect to a new page for user to edit
+    response.sendRedirect( wiki.getEditURL(newEntry) );
+%>
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewGroup.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewGroup.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewGroup.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/NewGroup.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,84 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.NoSuchPrincipalException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.WikiSecurityException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.Group" %>
+<%@ page import="com.ecyrd.jspwiki.auth.authorize.GroupManager" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.*" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.CREATE_GROUP );
+    if(!wikiContext.hasAccess( response )) return;
+    
+    // Extract the current user, group name, members and action attributes
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getGroupManager();
+    Group group = null;
+    try 
+    {
+        group = groupMgr.parseGroup( wikiContext, true );
+        pageContext.setAttribute ( "Group", group, PageContext.REQUEST_SCOPE );
+    }
+    catch ( WikiSecurityException e )
+    {
+        wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+        response.sendRedirect( "Group.jsp" );
+    }
+    
+    // Are we saving the group?
+    if( "save".equals(request.getParameter("action")) )
+    {
+        // Validate the group
+        groupMgr.validateGroup( wikiContext, group );
+        
+        try 
+        {
+            groupMgr.getGroup( group.getName() );
+
+            // Oops! The group already exists. This is mischief!
+            ResourceBundle rb = wikiContext.getBundle("CoreResources");
+            Object[] args = { group.getName() };
+            wikiSession.addMessage( GroupManager.MESSAGES_KEY,
+                                    MessageFormat.format(rb.getString("newgroup.exists"),args));
+        }
+        catch ( NoSuchPrincipalException e )
+        {
+            // Group not found; this is good!
+        }
+
+        // If no errors, save the group now
+        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 )
+        {
+            try
+            {
+                groupMgr.setGroup( wikiSession, group );
+            }
+            catch( WikiSecurityException e )
+            {
+                // Something went horribly wrong! Maybe it's an I/O error...
+                wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
+            }
+        }
+        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 )
+        {
+            response.sendRedirect( "Group.jsp?group=" + group.getName() );
+            return;
+        }
+    }
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageInfo.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageInfo.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageInfo.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageInfo.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,29 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.INFO );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+    
+    WatchDog w = wiki.getCurrentWatchDog();
+    try{
+    w.enterState("Generating INFO response",60);
+    
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+
+<% } finally { w.exitState(); } %>
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageModified.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageModified.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageModified.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/PageModified.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,44 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="org.apache.commons.lang.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.CONFLICT );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    String usertext = (String)session.getAttribute( EditorManager.REQ_EDITEDTEXT );
+
+    // Make the user and conflicting text presentable for display.
+    usertext = StringEscapeUtils.escapeXml( usertext );
+    usertext = TextUtil.replaceString( usertext, "\n", "<br />" );
+
+    String conflicttext = wiki.getText(pagereq);
+    conflicttext = StringEscapeUtils.escapeXml( conflicttext );
+    conflicttext = TextUtil.replaceString( conflicttext, "\n", "<br />" );
+
+    pageContext.setAttribute( "conflicttext",
+                              conflicttext,
+                              PageContext.REQUEST_SCOPE );
+
+    log.info("Page concurrently modified "+pagereq);
+    pageContext.setAttribute( "usertext",
+                              usertext,
+                              PageContext.REQUEST_SCOPE );
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Preview.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Preview.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Preview.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Preview.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,35 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.filters.*" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.PREVIEW );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    pageContext.setAttribute( EditorManager.ATTR_EDITEDTEXT,
+                              session.getAttribute( EditorManager.REQ_EDITEDTEXT ),
+                              PageContext.REQUEST_SCOPE );
+
+    String lastchange = SpamFilter.getSpamHash( wikiContext.getPage(), request );
+
+    pageContext.setAttribute( "lastchange",
+                              lastchange,
+                              PageContext.REQUEST_SCOPE );
+   
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Rename.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Rename.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Rename.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Rename.jsp Tue Feb 12 22:15:47 2008
@@ -0,0 +1,100 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.*" %>
+<fmt:setBundle basename="CoreResources"/>
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+	WikiContext wikiContext = wiki.createContext( request, WikiContext.RENAME );
+    if(!wikiContext.hasAccess( response )) return;
+
+    String renameFrom = wikiContext.getName();
+    String renameTo = request.getParameter( "renameto");
+
+    boolean changeReferences = false;
+
+    ResourceBundle rb = wikiContext.getBundle("CoreResources");
+
+    if (request.getParameter("references") != null)
+    {
+        changeReferences = true;
+    }
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+
+    log.info("Page rename request for page '"+renameFrom+ "' to new name '"+renameTo+"' from "+request.getRemoteAddr()+" by "+request.getRemoteUser() );
+
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    try
+    {
+        if (renameTo.length() > 0)
+        {
+            String renamedTo = wiki.renamePage(wikiContext, renameFrom, renameTo, changeReferences);
+
+            log.info("Page successfully renamed to '"+renamedTo+"'");
+
+            response.sendRedirect( wikiContext.getURL( WikiContext.VIEW, renamedTo ) );
+            return;
+        }
+        else
+        {
+            wikiSession.addMessage(rb.getString("rename.empty"));
+
+            log.info("Page rename request failed because new page name was left blank");
+
+%>
+            <h3><fmt:message key="rename.error.title"/></h3>
+
+            <dl>
+               <dt><b><fmt:message key="rename.error.reason"/></b></dt>
+               <dd>
+                  <wiki:Messages div="error" />
+               </dd>
+            </dl>
+<%
+        }
+
+    }
+    catch (WikiException e)
+    {
+        if (e.getMessage().equals("Page exists"))
+        {
+            if (renameTo.equals( renameFrom ))
+            {
+                log.info("Page rename request failed because page names are identical");
+                wikiSession.addMessage( rb.getString("rename.identical") );
+            }
+            else
+            {
+                log.info("Page rename request failed because new page name is already in use");
+                Object[] args = { renameTo };
+                wikiSession.addMessage(MessageFormat.format(rb.getString("rename.exists"),args));
+            }
+        }
+        else
+        {
+            Object[] args = { e.toString() };
+            wikiSession.addMessage( MessageFormat.format(rb.getString("rename.unknownerror"),args));
+        }
+
+%>
+       <h3><fmt:message key="rename.error.title"/></h3>
+
+       <dl>
+          <dt><b><fmt:message key="rename.error.reason"/></b></dt>
+          <dd>
+             <wiki:Messages div="error" />
+          </dd>
+       </dl>
+<%
+    }
+%>



Mime
View raw message