Permalink
Browse files

Adding entity static metadata, removing security classes

  • Loading branch information...
1 parent bfc54e9 commit 399818a0f9457544d037273a048ee0a91f0e89e1 @LightGuard LightGuard committed Jan 28, 2012
Showing with 566 additions and 430 deletions.
  1. +15 −0 open18_java_ee_6/pom.xml
  2. +0 −4 open18_java_ee_6/src/main/java/org/open18/ProfileNotFoundException.java
  3. +0 −37 open18_java_ee_6/src/main/java/org/open18/auth/PasswordBean.java
  4. +0 −81 open18_java_ee_6/src/main/java/org/open18/auth/PasswordManager.java
  5. +0 −52 open18_java_ee_6/src/main/java/org/open18/auth/auth-1.0.xsd
  6. +0 −5 open18_java_ee_6/src/main/java/org/open18/auth/package-info.java
  7. +0 −83 open18_java_ee_6/src/main/java/org/open18/captcha/Captcha.java
  8. +0 −39 open18_java_ee_6/src/main/java/org/open18/captcha/CaptchaImage.java
  9. +0 −34 open18_java_ee_6/src/main/java/org/open18/criteria/RoundCriteria.java
  10. +5 −6 open18_java_ee_6/src/main/java/org/open18/model/Member.java
  11. +29 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/CourseDao.java
  12. +29 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/FacilityDao.java
  13. +29 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/GolferDao.java
  14. +29 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/HoleDao.java
  15. +29 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/RoundDao.java
  16. +30 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/TeeDao.java
  17. +29 −0 open18_java_ee_6/src/main/java/org/open18/model/dao/TeeSetDao.java
  18. +22 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/CourseComment_.java
  19. +31 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Course_.java
  20. +31 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Facility_.java
  21. +28 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Golfer_.java
  22. +25 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Hole_.java
  23. +20 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Member_.java
  24. +15 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Role_.java
  25. +25 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Round_.java
  26. +16 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/TeeId_.java
  27. +28 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/TeeSet_.java
  28. +20 −0 open18_java_ee_6/src/main/java/org/open18/model/meta/Tee_.java
  29. +41 −0 open18_java_ee_6/src/main/java/org/open18/persistence/EntityManagerProducer.java
  30. +0 −36 open18_java_ee_6/src/main/java/org/open18/persistence/PersistenceContextValidator.java
  31. +40 −53 open18_java_ee_6/src/main/java/org/open18/validator/GolferValidator.java
View
@@ -12,6 +12,7 @@
<!-- It's easier to set versions here thar will / could be used in multiple locations. -->
<properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jboss.javaee6.version>2.1.0.Beta1</jboss.javaee6.version>
<richfaces.version>4.1.0.Final</richfaces.version>
<apache.shiro.version>1.2.0</apache.shiro.version>
@@ -127,4 +128,18 @@
</dependency>
</dependencies>
+ <!-- Tells Maven this project is to use Java 6, also creates the static meta model for the entities -->
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
@@ -1,9 +1,5 @@
package org.open18;
-import javax.servlet.http.HttpServletResponse;
-import org.jboss.seam.annotations.exception.HttpError;
-
-@HttpError(errorCode = HttpServletResponse.SC_NOT_FOUND)
public class ProfileNotFoundException extends RuntimeException {
public ProfileNotFoundException(Long id) {
super(id == null ? "No profile was requested" : "The requested profile does not exist: " + id);
@@ -1,37 +0,0 @@
-package org.open18.auth;
-
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-@BypassInterceptors
-public class PasswordBean {
- private String password;
- private String confirm;
-
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getConfirm() {
- return confirm;
- }
- public void setConfirm(String confirm) {
- this.confirm = confirm;
- }
-
- public boolean verify() {
- return confirm != null && confirm.equals(password);
- }
-
- @Override
- public String toString() {
- return new StringBuffer()
- .append(getClass().getName()).append("[")
- .append("password=").append(password).append(",")
- .append("confirm=").append(confirm)
- .append("]").toString();
- }
-
-}
@@ -1,81 +0,0 @@
-package org.open18.auth;
-
-import java.security.MessageDigest;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.util.Hex;
-import org.jboss.seam.util.Base64;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-
-@Name("org.open18.auth.passwordManager")
-@BypassInterceptors
-public class PasswordManager {
- private String digestAlgorithm;
- private String charset;
- private String saltPhrase;
- public enum Encoding { base64, hex }
- private Encoding encoding = Encoding.hex;
-
- public String getDigestAlgorithm() {
- return this.digestAlgorithm;
- }
-
- public void setDigestAlgorithm(String algorithm) {
- this.digestAlgorithm = algorithm;
- }
-
- public String getCharset() {
- return this.charset;
- }
-
- public void setCharset(String charset) {
- this.charset = charset;
- }
-
- public Encoding getEncoding() {
- return this.encoding;
- }
-
- public void setEncoding(Encoding encoding) {
- this.encoding = encoding;
- }
-
- public String getSaltPhrase() {
- return this.saltPhrase;
- }
-
- public void setSaltPhrase(String saltPhrase) {
- this.saltPhrase = saltPhrase;
- }
-
- public String hash(String plainTextPassword) {
- try {
- MessageDigest digest = MessageDigest.getInstance(digestAlgorithm);
- if (saltPhrase != null) {
- digest.update(saltPhrase.getBytes(charset));
- byte[] salt = digest.digest();
- digest.reset();
- digest.update(plainTextPassword.getBytes(charset));
- digest.update(salt);
- }
- else {
- digest.update(plainTextPassword.getBytes(charset));
- }
- byte[] rawHash = digest.digest();
- if (encoding != null && encoding.equals(Encoding.base64)) {
- return Base64.encodeBytes(rawHash);
- }
- else {
- return new String(Hex.encodeHex(rawHash));
- }
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static PasswordManager instance() {
- return (PasswordManager) Component.getInstance(PasswordManager.class, ScopeType.EVENT);
- }
-}
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
- targetNamespace="http://open18.org/components/auth" xmlns:auth="http://open18.org/components/auth"
- xmlns:components="http://jboss.com/products/seam/components" attributeFormDefault="unqualified">
- <xs:import namespace="http://jboss.com/products/seam/components" schemaLocation="http://jboss.com/products/seam/components-2.0.xsd"/>
-
- <xs:element name="password-manager">
- <xs:complexType mixed="true">
- <xs:sequence>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="auth:digest-algorithm"/>
- <xs:element ref="auth:charset" />
- <xs:element ref="auth:salt-phrase" />
- <xs:element ref="auth:encoding" />
- </xs:choice>
- </xs:sequence>
- <xs:attributeGroup ref="components:attlist.component"/>
- <xs:attributeGroup ref="auth:attlist.passwordManager"/>
- </xs:complexType>
- </xs:element>
- <xs:attributeGroup name="attlist.passwordManager">
- <xs:attribute name="digest-algorithm" type="xs:string"/>
- <xs:attribute name="charset" type="xs:string"/>
- <xs:attribute name="salt-phrase" type="xs:string"/>
- <xs:attribute name="encoding" type="auth:encodingType"/>
- </xs:attributeGroup>
-
- <xs:element name="digest-algorithm" type="xs:string" />
-
- <xs:element name="charset" type="xs:string" />
-
- <xs:element name="salt-phrase" type="xs:string" />
-
- <xs:element name="encoding" type="auth:encodingType"/>
-
- <xs:element name="password-bean">
- <xs:complexType mixed="true">
- <xs:attributeGroup ref="components:attlist.component"/>
- <xs:attributeGroup ref="auth:attlist.passwordBean"/>
- </xs:complexType>
- </xs:element>
- <xs:attributeGroup name="attlist.passwordBean">
- </xs:attributeGroup>
-
- <xs:simpleType name="encodingType">
- <xs:restriction base="xs:token">
- <xs:enumeration value="base64"/>
- <xs:enumeration value="hex"/>
- </xs:restriction>
- </xs:simpleType>
-
-</xs:schema>
@@ -1,5 +0,0 @@
-@Namespace(value = "http://open18.org/components/auth", prefix = "org.open18.auth")
-@AutoCreate
-package org.open18.auth;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Namespace;
@@ -1,83 +0,0 @@
-package org.open18.captcha;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import javax.imageio.ImageIO;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-
-/**
- * Override built-in captcha to make it more configurable.
- */
-@Name("org.jboss.seam.captcha.captcha")
-@BypassInterceptors
-public class Captcha extends org.jboss.seam.captcha.Captcha {
-
- private Color backgroundColor = Color.WHITE;
-
- private Color textColor = Color.BLACK;
-
- private String imageFormatName = "png";
-
- @Override
- public BufferedImage renderChallenge() {
- BufferedImage challenge = new BufferedImage(70, 20, BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics = challenge.createGraphics();
- graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- graphics.setFont(new Font("SansSerif", Font.PLAIN, 12));
- graphics.setColor(getChallengeBackgroundColor());
- graphics.fillRect(0, 0, getChallengeImageWidth(), 20);
- graphics.setColor(getChallengeTextColor());
- graphics.drawString(getChallenge(), 5, 14);
- return challenge;
- }
-
- @Override
- protected Color getChallengeBackgroundColor() {
- return backgroundColor != null ? backgroundColor : super.getChallengeBackgroundColor();
- }
-
- @Override
- protected Color getChallengeTextColor() {
- return textColor != null ? textColor : super.getChallengeTextColor();
- }
-
- public void setBackgroundColor(String colorValue) {
- this.backgroundColor = Color.decode(colorValue);
- }
-
- public void setTextColor(String colorValue) {
- this.textColor = Color.decode(colorValue);
- }
-
- public String getImageMIMEType() {
- return "image/" + getImageFormatName();
- }
-
- public String getImageFormatName() {
- return imageFormatName;
- }
-
- public void setImageFormatName(String formatName) {
- if (!ImageIO.getImageWritersByFormatName(formatName).hasNext()) {
- throw new IllegalArgumentException("Image format unknown: " + formatName);
- }
-
- this.imageFormatName = formatName;
- }
-
- public static Captcha instance() {
- if (!Contexts.isSessionContextActive()) {
- throw new IllegalStateException("No session context active");
- }
- return (Captcha) Component.getInstance(Captcha.class, ScopeType.SESSION);
- }
-
-}
@@ -1,39 +0,0 @@
-package org.open18.captcha;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.ServletLifecycle;
-
-/**
- * Override built-in component to create png instead of jpg
- */
-@Name("org.jboss.seam.captcha.captchaImage")
-@BypassInterceptors
-public class CaptchaImage extends org.jboss.seam.captcha.CaptchaImage {
-
- @Override
- public void getResource(HttpServletRequest request, HttpServletResponse response) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- ServletLifecycle.beginRequest(request);
- Captcha captcha = Captcha.instance();
- try {
- ImageIO.write(captcha.renderChallenge(), captcha.getImageFormatName(), out);
- } finally {
- ServletLifecycle.endRequest(request);
- }
-
- response.setHeader("Cache-Control", "no-store");
- response.setHeader("Pragma", "no-cache");
- response.setDateHeader("Expires", 0);
- response.setContentType(captcha.getImageMIMEType());
- response.getOutputStream().write(out.toByteArray());
- response.getOutputStream().flush();
- response.getOutputStream().close();
- }
-}
@@ -1,34 +0,0 @@
-package org.open18.criteria;
-
-import java.util.Date;
-import java.util.List;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.open18.model.Course;
-import java.io.Serializable;
-
-@Name("roundCriteria")
-@Scope(ScopeType.CONVERSATION)
-public class RoundCriteria implements Serializable {
- private String golferName;
- private Date beforeDate;
- private Date afterDate;
- private boolean self = false;
- private List<Course> courses;
-
- public String getGolferName() { return this.golferName; }
- public void setGolferName(String name) { this.golferName = name; }
-
- public Date getBeforeDate() { return this.beforeDate; }
- public void setBeforeDate(Date date) { this.beforeDate = date; }
-
- public Date getAfterDate() { return this.afterDate; }
- public void setAfterDate(Date date) { this.afterDate = date; }
-
- public boolean isSelf () { return this.self; }
- public void setSelf (boolean self) { this.self = self; }
-
- public List<Course> getCourses() { return this.courses; }
- public void setCourses(List<Course> courses) { this.courses = courses; }
-}
Oops, something went wrong.

0 comments on commit 399818a

Please sign in to comment.