Skip to content

Commit

Permalink
Add javadoc plugin and example README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
oopsguy committed Dec 23, 2018
1 parent 79c21da commit a650a4f
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 60 deletions.
4 changes: 4 additions & 0 deletions kapcha-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
</dependencies>

</project>
6 changes: 6 additions & 0 deletions kaptcha-spring-boot-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<!--For java 9 or up-->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
17 changes: 17 additions & 0 deletions kaptcha-spring-boot-starter-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Kaptcha Spring Boot Starter Example

This project is a demo based on Spring Boot, you can run it as a jar
or by following maven command:

```
mvn spring-boot:run
```

The project will run on port `8081`.

You can view the results by browsing the links below:


- [`http://localhost:8081/index.html`](htpp://localhost:8081/index.html)
- [`http://localhost:8081/home/captcha`](htpp://localhost:8081/home/captcha)
- [`http://localhost:8081/captcha`](http://localhost:8081/captcha)
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public interface NoiseProducer {
* curve.
*
* @param image the image to add the noise to
* @param factorOne
* @param factorTwo
* @param factorThree
* @param factorFour
* @param factorOne factorOne
* @param factorTwo factorTwo
* @param factorThree factorThree
* @param factorFour factorFour
*/
public void makeNoise(BufferedImage image, float factorOne,
float factorTwo, float factorThree, float factorFour);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2015-2018 the original author or authors.
*
* 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.google.code.kaptcha.impl;

import com.google.code.kaptcha.NoiseProducer;
Expand All @@ -17,13 +33,13 @@
public class DefaultNoise extends Configurable implements NoiseProducer {
/**
* Draws a noise on the image. The noise curve depends on the factor values.
* Noise won't be visible if all factors have the value > 1.0f
* Noise won't be visible if all factors have the value &gt; 1.0f
*
* @param image the image to add the noise to
* @param factorOne
* @param factorTwo
* @param factorThree
* @param factorFour
* @param factorOne factorOne
* @param factorTwo factorTwo
* @param factorThree factorThree
* @param factorFour factorFour
*/
public void makeNoise(BufferedImage image, float factorOne,
float factorTwo, float factorThree, float factorFour) {
Expand Down
45 changes: 21 additions & 24 deletions kaptcha/src/main/java/com/google/code/kaptcha/util/Config.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2015-2018 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.google.code.kaptcha.util;

import com.google.code.kaptcha.*;
Expand All @@ -18,48 +34,41 @@
* specifies default values when no value is specified.
*/
public class Config {
/** */

private Properties properties;

/** */
private ConfigHelper helper;

/** */
public Config(Properties properties) {
this.properties = properties;
this.helper = new ConfigHelper();
}

/** */
public boolean isBorderDrawn() {
String paramName = Constants.KAPTCHA_BORDER;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getBoolean(paramName, paramValue, true);
}

/** */
public Color getBorderColor() {
String paramName = Constants.KAPTCHA_BORDER_COLOR;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getColor(paramName, paramValue, Color.BLACK);
}

/** */
public int getBorderThickness() {
String paramName = Constants.KAPTCHA_BORDER_THICKNESS;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getPositiveInt(paramName, paramValue, 1);
}

/** */
public Producer getProducerImpl() {
String paramName = Constants.KAPTCHA_PRODUCER_IMPL;
String paramValue = this.properties.getProperty(paramName);
Producer producer = (Producer) this.helper.getClassInstance(paramName, paramValue, new DefaultKaptcha(), this);
return producer;
}

/** */
public TextProducer getTextProducerImpl() {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_IMPL;
String paramValue = this.properties.getProperty(paramName);
Expand All @@ -68,21 +77,18 @@ public TextProducer getTextProducerImpl() {
return textProducer;
}

/** */
public char[] getTextProducerCharString() {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_CHAR_STRING;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getChars(paramName, paramValue, "abcde2345678gfynmnpwx".toCharArray());
}

/** */
public int getTextProducerCharLength() {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getPositiveInt(paramName, paramValue, 5);
}

/** */
public Font[] getTextProducerFonts(int fontSize) {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES;
String paramValue = this.properties.getProperty(paramName);
Expand All @@ -91,28 +97,24 @@ public Font[] getTextProducerFonts(int fontSize) {
});
}

/** */
public int getTextProducerFontSize() {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getPositiveInt(paramName, paramValue, 40);
}

/** */
public Color getTextProducerFontColor() {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getColor(paramName, paramValue, Color.BLACK);
}

/** */
public int getTextProducerCharSpace() {
String paramName = Constants.KAPTCHA_TEXTPRODUCER_CHAR_SPACE;
String paramValue = properties.getProperty(paramName);
return this.helper.getPositiveInt(paramName, paramValue, 2);
}

/** */
public NoiseProducer getNoiseImpl() {
String paramName = Constants.KAPTCHA_NOISE_IMPL;
String paramValue = this.properties.getProperty(paramName);
Expand All @@ -121,22 +123,19 @@ public NoiseProducer getNoiseImpl() {
return noiseProducer;
}

/** */
public Color getNoiseColor() {
String paramName = Constants.KAPTCHA_NOISE_COLOR;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getColor(paramName, paramValue, Color.BLACK);
}

/** */
public GimpyEngine getObscurificatorImpl() {
String paramName = Constants.KAPTCHA_OBSCURIFICATOR_IMPL;
String paramValue = this.properties.getProperty(paramName);
GimpyEngine gimpyEngine = (GimpyEngine) this.helper.getClassInstance(paramName, paramValue, new WaterRipple(), this);
return gimpyEngine;
}

/** */
public WordRenderer getWordRendererImpl() {
String paramName = Constants.KAPTCHA_WORDRENDERER_IMPL;
String paramValue = this.properties.getProperty(paramName);
Expand All @@ -145,7 +144,6 @@ public WordRenderer getWordRendererImpl() {
return wordRenderer;
}

/** */
public BackgroundProducer getBackgroundImpl() {
String paramName = Constants.KAPTCHA_BACKGROUND_IMPL;
String paramValue = this.properties.getProperty(paramName);
Expand All @@ -154,28 +152,24 @@ public BackgroundProducer getBackgroundImpl() {
return backgroundProducer;
}

/** */
public Color getBackgroundColorFrom() {
String paramName = Constants.KAPTCHA_BACKGROUND_CLR_FROM;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getColor(paramName, paramValue, Color.LIGHT_GRAY);
}

/** */
public Color getBackgroundColorTo() {
String paramName = Constants.KAPTCHA_BACKGROUND_CLR_TO;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getColor(paramName, paramValue, Color.WHITE);
}

/** */
public int getWidth() {
String paramName = Constants.KAPTCHA_IMAGE_WIDTH;
String paramValue = this.properties.getProperty(paramName);
return this.helper.getPositiveInt(paramName, paramValue, 200);
}

/** */
public int getHeight() {
String paramName = Constants.KAPTCHA_IMAGE_HEIGHT;
String paramValue = this.properties.getProperty(paramName);
Expand All @@ -185,6 +179,8 @@ public int getHeight() {
/**
* Allows one to override the key name which is stored in the users
* HttpSession. Defaults to Constants.KAPTCHA_SESSION_KEY.
*
* @return session key
*/
public String getSessionKey() {
return this.properties.getProperty(Constants.KAPTCHA_SESSION_CONFIG_KEY, Constants.KAPTCHA_SESSION_KEY);
Expand All @@ -193,12 +189,13 @@ public String getSessionKey() {
/**
* Allows one to override the date name which is stored in the
* users HttpSession. Defaults to Constants.KAPTCHA_SESSION_KEY.
*
* @return session date
*/
public String getSessionDate() {
return this.properties.getProperty(Constants.KAPTCHA_SESSION_CONFIG_DATE, Constants.KAPTCHA_SESSION_DATE);
}

/** */
public Properties getProperties() {
return this.properties;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2015-2018 the original author or authors.
*
* 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.google.code.kaptcha.util;

/**
Expand Down
Loading

0 comments on commit a650a4f

Please sign in to comment.