Permalink
Browse files

Remove tapx-kaptcha, as there's now an official tapestry-kaptcha as p…

…art of Tapestry 5.3
  • Loading branch information...
1 parent e9cad0b commit 6fb2f99a6870afe59ee591e991e0dab0e81f47a7 @hlship committed Feb 9, 2012
View
@@ -38,18 +38,14 @@ base on Geolocation data (if allowed by the client).
* Components:
* DateField
* TimeZoneIdentifier
-
-tapx-kaptcha
-------------
-Two components for enabling KAPTCHA verification that the client is a living person, based on the [kaptcha](http://code.google.com/p/kaptcha/) project.
+tapx-heroku
+-----------
-This code has been moved to the Tapestry framework in Tapestry 5.3.
+A small wrapper that allows Tapestry applications to be deployed onto the Heroku cloud computing service.
+
+The documentation is currently just a posting on [James Ward's blog](http://www.jamesward.com/2012/02/08/deploy-containerless-tapestry-apps-on-heroku).
-* Components:
- * KaptchaField
- * KaptchaImage
-
tapx-plainmessage
-----------------
View
@@ -1,3 +1,3 @@
-include "tapx-core", "tapx-kaptcha", "tapx-datefield", "tapx-plainmessage"
+include "tapx-core", "tapx-datefield", "tapx-plainmessage"
include "tapx-templating", "tapx-yui"
include "tapx-json", "tapx-jms-core", "tapx-heroku"
View
@@ -1,12 +0,0 @@
-description = "Kaptcha image support"
-
-dependencies {
- compile project(':tapx-core')
- compile "com.google.code.kaptcha:kaptcha:2.3"
-}
-
-jar {
- manifest {
- attributes 'Tapestry-Module-Classes': 'com.howardlewisship.tapx.kaptcha.services.KaptchaModule'
- }
-}
@@ -1,106 +0,0 @@
-// Copyright 2010 Howard M. Lewis Ship
-//
-// 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 com.howardlewisship.tapx.kaptcha.components;
-
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.FieldValidator;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.ValidationTracker;
-import org.apache.tapestry5.annotations.BeginRender;
-import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.annotations.SupportsInformalParameters;
-import org.apache.tapestry5.corelib.base.AbstractField;
-import org.apache.tapestry5.internal.TapestryInternalUtils;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.FieldValidatorSource;
-import org.apache.tapestry5.services.Request;
-
-/**
- * Field paired with a {@link KaptchaImage} to ensure that the user has provided
- * the correct value.
- */
-@SupportsInformalParameters
-public class KaptchaField extends AbstractField
-{
-
- /**
- * The image output for this field. The image will display a distorted text
- * string. The user must decode the distorted text and enter the same value.
- */
- @Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT)
- private KaptchaImage image;
-
- @Inject
- private Request request;
-
- @Inject
- private Messages messages;
-
- @Inject
- private ComponentResources resources;
-
- @Environmental
- private ValidationTracker validationTracker;
-
- @Inject
- private FieldValidatorSource fieldValidatorSource;
-
- @Override
- public boolean isRequired()
- {
- return true;
- }
-
- @Override
- protected void processSubmission(String elementName)
- {
- String userValue = request.getParameter(elementName);
-
- if (TapestryInternalUtils.isEqual(image.getCaptchaText(), userValue))
- return;
-
- validationTracker.recordError(this, messages.get("tapx-incorrect-captcha"));
- }
-
- @SuppressWarnings("rawtypes")
- @BeginRender
- boolean begin(MarkupWriter writer)
- {
-
- writer.element("input",
-
- "type", "password",
-
- "id", getClientId(),
-
- "name", getControlName(),
-
- "value", "");
-
- resources.renderInformalParameters(writer);
-
- FieldValidator fieldValidator = fieldValidatorSource
- .createValidator(this, "required", null);
-
- fieldValidator.render(writer);
-
- writer.end();
-
- return false;
- }
-}
@@ -1,106 +0,0 @@
-// Copyright 2010 Howard M. Lewis Ship
-//
-// 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 com.howardlewisship.tapx.kaptcha.components;
-
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.SupportsInformalParameters;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.Response;
-
-import com.howardlewisship.tapx.kaptcha.services.KaptchaProducer;
-
-/**
- * Part of a Captcha based authentication scheme; a KaptchaImage generates a new
- * text image whenever it <em>renders</em> and can provide the previously
- * rendred text subsequently (it is stored persistently in the session).
- * <p>
- * The component renders an &lt;img&gt; tag, including width and height attributes. Other attributes
- * come from informal parameters.
- */
-@SupportsInformalParameters
-public class KaptchaImage
-{
-
- @Persist
- private String captchaText;
-
- @Inject
- private KaptchaProducer producer;
-
- @Inject
- private ComponentResources resources;
-
- @Inject
- private Response response;
-
- public String getCaptchaText()
- {
- return captchaText;
- }
-
- void setupRender()
- {
- captchaText = producer.createText();
- }
-
- boolean beginRender(MarkupWriter writer)
- {
- Link link = resources.createEventLink("image");
-
- writer.element("img",
-
- "src", link.toURI(),
-
- "width", producer.getWidth(),
-
- "height", producer.getHeight());
-
- resources.renderInformalParameters(writer);
-
- writer.end();
-
- return false;
- }
-
- void onImage() throws IOException
- {
- BufferedImage image = producer.createImage(captchaText);
-
- response.setDateHeader("Expires", 0);
- // Set standard HTTP/1.1 no-cache headers.
- response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
- // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
- response.setHeader("Cache-Control", "post-check=0, pre-check=0");
- // Set standard HTTP/1.0 no-cache header.
- response.setHeader("Pragma", "no-cache");
-
- OutputStream stream = response.getOutputStream("image/jpeg");
-
- ImageIO.write(image, "jpg", stream);
-
- stream.flush();
-
- stream.close();
- }
-}
@@ -1,86 +0,0 @@
-// Copyright 2010 Howard M. Lewis Ship
-//
-// 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 com.howardlewisship.tapx.kaptcha.internal.services;
-
-import java.awt.image.BufferedImage;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.tapestry5.ioc.annotations.Symbol;
-
-import com.google.code.kaptcha.impl.DefaultKaptcha;
-import com.google.code.kaptcha.util.Config;
-import com.howardlewisship.tapx.core.CoreSymbols;
-import com.howardlewisship.tapx.kaptcha.services.KaptchaProducer;
-
-public class KaptchaProducerImpl implements KaptchaProducer
-{
- private final DefaultKaptcha producer;
-
- private final int height;
-
- private final int width;
-
- private final boolean testMode;
-
- public KaptchaProducerImpl(Map<String, String> configuration, @Symbol(CoreSymbols.TEST_MODE)
- boolean testMode)
- {
- producer = new DefaultKaptcha();
-
- Config config = new Config(toProperties(configuration));
-
- producer.setConfig(config);
-
- height = config.getHeight();
- width = config.getWidth();
-
- this.testMode = testMode;
- }
-
- public int getHeight()
- {
- return height;
- }
-
- public int getWidth()
- {
- return width;
- }
-
- public BufferedImage createImage(String text)
- {
- return producer.createImage(text);
- }
-
- public String createText()
- {
- return testMode ? "i8cookies" : producer.createText();
- }
-
- private static Properties toProperties(Map<String, String> map)
- {
-
- Properties result = new Properties();
-
- for (String key : map.keySet())
- {
- result.put(key, map.get(key));
- }
-
- return result;
-
- }
-}
@@ -1,31 +0,0 @@
-package com.howardlewisship.tapx.kaptcha.services;
-
-import org.apache.tapestry5.ioc.Configuration;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Value;
-import org.apache.tapestry5.services.LibraryMapping;
-
-import com.howardlewisship.tapx.kaptcha.internal.services.KaptchaProducerImpl;
-
-public class KaptchaModule
-{
- public static void bind(ServiceBinder binder)
- {
- binder.bind(KaptchaProducer.class, KaptchaProducerImpl.class);
- }
-
- public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
- {
- configuration.add(new LibraryMapping("tapx", "com.howardlewisship.tapx.kaptcha"));
- }
-
- public static void contributeComponentMessagesSource(
- OrderedConfiguration<Resource> configuration,
- @Value("classpath:com/howardlewisship/tapx/kaptcha/tapx-kaptcha.properties")
- Resource coreCatalog)
- {
- configuration.add("TapxKaptcha", coreCatalog, "before:AppCatalog");
- }
-}
Oops, something went wrong.

0 comments on commit 6fb2f99

Please sign in to comment.