Browse Source

Update servlet to look better, add jars

master
James Childers 13 years ago
parent
commit
9fcb78e405
  1. 9
      .externalToolBuilders/SimpleCaptcha build.xml [Builder].launch
  2. 2
      .settings/org.eclipse.jdt.core.prefs
  3. 36
      Java/src/nl/captcha/servlet/SimpleCaptchaServlet.java
  4. BIN
      dist/simplecaptcha-1.1.1.jar
  5. 1
      dist/simplecaptcha-latest.jar
  6. 4
      docs/layouts/default.txt
  7. 1
      examples/grails/lib/imaging.jar
  8. 1
      examples/grails/lib/imaging.jar
  9. BIN
      examples/j2ee/WEB-INF/lib/simplecaptcha-1.1.1.jar
  10. BIN
      examples/j2ee/simplecaptcha-j2ee-example.war

9
.externalToolBuilders/SimpleCaptcha build.xml [Builder].launch

@ -10,12 +10,11 @@
</listAttribute>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="SimpleCaptcha"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="simplecaptcha"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="JVM 1.6"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.launching.macosx.MacOSXType"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/SimpleCaptcha/build.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/simplecaptcha/build.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>

2
.settings/org.eclipse.jdt.core.prefs

@ -1,4 +1,4 @@
#Wed Oct 15 15:27:14 CDT 2008
#Fri Dec 17 15:23:11 CST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6

36
Java/src/nl/captcha/servlet/SimpleCaptchaServlet.java

@ -3,7 +3,10 @@ package nl.captcha.servlet;
import static nl.captcha.Captcha.NAME;
import java.awt.Color;
import java.awt.Font;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@ -12,9 +15,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import nl.captcha.Captcha;
import nl.captcha.backgrounds.FlatColorBackgroundProducer;
import nl.captcha.gimpy.ShearGimpyRenderer;
import nl.captcha.noise.StraightLineNoiseProducer;
import nl.captcha.backgrounds.GradiatedBackgroundProducer;
import nl.captcha.gimpy.DropShadowGimpyRenderer;
import nl.captcha.text.renderer.ColoredEdgesWordRenderer;
/**
@ -29,6 +32,18 @@ public class SimpleCaptchaServlet extends HttpServlet {
private static int _width = 200;
private static int _height = 50;
private static final List<Color> COLORS = new ArrayList<Color>(2);
private static final List<Font> FONTS = new ArrayList<Font>(3);
static {
COLORS.add(Color.BLACK);
COLORS.add(Color.BLUE);
FONTS.add(new Font("Geneva", Font.ITALIC, 48));
FONTS.add(new Font("Courier", Font.BOLD, 48));
FONTS.add(new Font("Arial", Font.BOLD, 48));
}
@Override
public void init(ServletConfig config) throws ServletException {
@ -45,13 +60,14 @@ public class SimpleCaptchaServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Captcha captcha = new Captcha.Builder(_width, _height)
.addText()
.addBackground(new FlatColorBackgroundProducer(Color.WHITE))
.gimp(new ShearGimpyRenderer())
.addNoise(new StraightLineNoiseProducer())
.build();
ColoredEdgesWordRenderer wordRenderer = new ColoredEdgesWordRenderer(COLORS, FONTS);
Captcha captcha = new Captcha.Builder(_width, _height).addText(wordRenderer)
.gimp()
.gimp(new DropShadowGimpyRenderer())
.addBackground(new GradiatedBackgroundProducer())
.addBorder()
.build();
CaptchaServletUtil.writeImage(resp, captcha.getImage());
CaptchaServletUtil.writeImage(resp, captcha.getImage());
req.getSession().setAttribute(NAME, captcha);

BIN
dist/simplecaptcha-1.1.1.jar

1
dist/simplecaptcha-latest.jar

@ -0,0 +1 @@
simplecaptcha-1.1.1.jar

4
docs/layouts/default.txt

@ -40,12 +40,12 @@ filter:
<div class="column span-5 append-2 last">
<h4><a href="/index.html">Home</a></h4>
<h4><a href="http://downloads.sourceforge.net/simplecaptcha/SimpleCaptcha-1.1.jar?use_mirror=">Download v1.1</a></h4>
<h4><a href="http://sourceforge.net/projects/simplecaptcha/files/SimpleCaptcha/1.1.1/SimpleCaptcha-1.1.1.jar/download">Download SimpleCaptcha</a></h4>
<ul style="list-style: none; padding-top: -20px; margin-top: -15px;">
<li>- <a href="http://downloads.sourceforge.net/simplecaptcha/SimpleCaptcha-1.1-src.zip?use_mirror=">Source</a></li>
<li>&nbsp;</li>
<li>- <a href="http://sourceforge.net/projects/simplecaptcha/files/SimpleCaptcha/1.1.1/Sample%20Apps/simplecaptcha-grails-example.war/download">Grails Example App</a></li>
<li>- <a href="">J2EE Example App</a></li>
<li>- <a href="http://sourceforge.net/projects/simplecaptcha/files/SimpleCaptcha/1.1.1/Sample%20Apps/simplecaptcha-j2ee-example.war/download">J2EE Example App</a></li>
</ul>
<h4><a href="/installing.html">Installing</a></h4>
<h4><a href="/extending.html">Extending</a></h4>

1
examples/grails/lib/imaging.jar

@ -1 +0,0 @@
../../../lib/imaging.jar

1
examples/grails/lib/imaging.jar

@ -0,0 +1 @@
../../../lib/imaging.jar

BIN
examples/j2ee/WEB-INF/lib/simplecaptcha-1.1.1.jar

BIN
examples/j2ee/simplecaptcha-j2ee-example.war

Loading…
Cancel
Save