/*
 * $Id$ $Revision:
 * 4296 $ $Date$
 * 
 * ==================================================================== Licensed
 * under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the
 * License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package wicket.examples.signin2;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import wicket.Component;
import wicket.ISessionFactory;
import wicket.RestartResponseAtInterceptPageException;
import wicket.Session;
import wicket.authorization.Action;
import wicket.authorization.IAuthorizationStrategy;
import wicket.examples.WicketExampleApplication;
import wicket.protocol.http.WebRequest;
import wicket.protocol.http.WebRequestWithCryptedUrl;
import wicket.protocol.http.WebResponse;
import wicket.protocol.http.WebResponseWithCryptedUrl;

/**
 * Forms example.
 * 
 * @author Jonathan Locke
 */
public final class SignIn2Application extends WicketExampleApplication
{
	/**
	 * Constructor.
	 */
	public SignIn2Application()
	{
	}

	/**
	 * @see wicket.examples.WicketExampleApplication#init()
	 */
	protected void init()
	{
		super.init();
		
		getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy()
		{
			public boolean isActionAuthorized(Component component, Action action)
			{
				return true;
			}

			public boolean isInstantiationAuthorized(Class componentClass)
			{
				if (AuthenticatedWebPage.class.isAssignableFrom(componentClass))
				{
					// Is user signed in?
					if (((SignIn2Session)Session.get()).isSignedIn())
					{
						// okay to proceed
						return true;
					}

					// Force sign in
					throw new RestartResponseAtInterceptPageException(SignIn2.class);
				}
				return true;
			}
		});
	}

	/**
	 * @see wicket.protocol.http.WebApplication#getSessionFactory()
	 */
	public ISessionFactory getSessionFactory()
	{
		return new ISessionFactory()
		{
			public Session newSession()
			{
				return new SignIn2Session(SignIn2Application.this);
			}
		};
	}

	/**
	 * @see wicket.protocol.http.WebApplication#newWebRequest(javax.servlet.http.HttpServletRequest)
	 */
	protected WebRequest newWebRequest(HttpServletRequest servletRequest)
	{
		return new WebRequestWithCryptedUrl(servletRequest);
	}

	/**
	 * @see wicket.protocol.http.WebApplication#newWebResponse(javax.servlet.http.HttpServletResponse)
	 */
	protected WebResponse newWebResponse(HttpServletResponse servletResponse)
	{
		return new WebResponseWithCryptedUrl(servletResponse);
	}

	/**
	 * @see wicket.Application#getHomePage()
	 */
	public Class getHomePage()
	{
		return Home.class;
	}

}

@@ -703,102 +703,8 @@
 2;%0A%0A
-import javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A
 impo
@@ -998,26 +998,58 @@
 ol.http.
-WebRequest
+request.CryptedUrlWebRequestCodingStrategy
 ;%0Aimport
@@ -1066,24 +1066,32 @@
 otocol.http.
+request.
 WebRequestWi
@@ -1088,30 +1088,30 @@
 bRequest
-WithCryptedUrl
+CodingStrategy
 ;%0Aimport
@@ -1122,88 +1122,100 @@
 ket.
-protocol.http.WebResponse;%0Aimport wicket.protocol.http.WebResponseWithCryptedUrl
+request.IRequestCycleProcessor;%0Aimport wicket.request.compound.CompoundRequestCycleProcessor
 ;%0A%0A/
@@ -2376,24 +2376,25 @@
 %09%09%7D%0A%09%09%7D;%0A%09%7D%0A
+%09
 %0A%09/**%0A%09 * @s
@@ -2439,56 +2439,30 @@
 #new
-Web
 Request
-(javax.servlet.http.HttpServletRequest
+CycleProcessor(
 )%0A%09 
@@ -2479,372 +2479,207 @@
 ted 
-Web
+I
 Request
+CycleProcessor
  new
-Web
 Request
-(HttpServletRequest servletRequest)%0A%09%7B%0A%09%09return new WebRequestWithCryptedUrl(servletRequest);%0A%09%7D%0A%0A%09/**%0A%09 * @see wicket.protocol.http.WebApplication#newWebResponse(javax.servlet.http.HttpServletResponse)%0A%09 */%0A%09protected WebResponse newWebResponse(HttpServletResponse servletResponse)%0A%09%7B%0A%09%09return new WebResponseWithCryptedUrl(servletResponse
+CycleProcessor()%0A%09%7B%0A%09%09return new CompoundRequestCycleProcessor(%0A%09%09%09%09new CryptedUrlWebRequestCodingStrategy(new WebRequestCodingStrategy()),%0A%09%09%09%09null, null, null, null
 );%0A%09

Update encrypting URL querystring to use request coding strategy