diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 18:49:12 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 18:49:12 +0000 |
commit | c811ca302d20fb6f2752f7b79787283882ee57a2 (patch) | |
tree | 79ba88074cc6d8ce1ab9151435a8a0dab46bb705 /pdf-over/pdf-signer-interface/src/main/java | |
parent | 3f5eda3adbea29aa8ad2cca5d300cef3f3a444a5 (diff) | |
download | mocca-c811ca302d20fb6f2752f7b79787283882ee57a2.tar.gz mocca-c811ca302d20fb6f2752f7b79787283882ee57a2.tar.bz2 mocca-c811ca302d20fb6f2752f7b79787283882ee57a2.zip |
PDFSignerInterface updated
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@3 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over/pdf-signer-interface/src/main/java')
24 files changed, 203 insertions, 835 deletions
diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/CollimatingMark.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/CollimatingMark.java new file mode 100644 index 00000000..1d209671 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/CollimatingMark.java @@ -0,0 +1,5 @@ +package at.asit.pdfover.pdfsignator; + +public class CollimatingMark { + +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/DocumentSource.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/DocumentSource.java index 9343a981..3550596c 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/DocumentSource.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/DocumentSource.java @@ -1,5 +1,9 @@ package at.asit.pdfover.pdfsignator; +/** + * A Document Source + * @author afitzek + */ public class DocumentSource { } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/InvalidPropertyTypeException.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/InvalidPropertyTypeException.java deleted file mode 100644 index 8f9d54a9..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/InvalidPropertyTypeException.java +++ /dev/null @@ -1,16 +0,0 @@ -package at.asit.pdfover.pdfsignator; - -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; -import at.asit.pdfover.pdfsignator.profileproperties.validators.PropertyValidator; - -public class InvalidPropertyTypeException extends Exception { - /** - * - */ - private static final long serialVersionUID = 6174277563400848906L; - - public InvalidPropertyTypeException(ProfileProperty property, PropertyValidator validator) { - super(String.format("Cannot add validator: %s to Property: %s (incompatible)", - validator.getClass().getName(), property.getClass().getName())); - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/InvalidPropertyValueException.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/InvalidPropertyValueException.java deleted file mode 100644 index 3b3d96e9..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/InvalidPropertyValueException.java +++ /dev/null @@ -1,16 +0,0 @@ -package at.asit.pdfover.pdfsignator; - -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; - - -public class InvalidPropertyValueException extends Exception { - - /** - * - */ - private static final long serialVersionUID = -3823266882732616374L; - - public InvalidPropertyValueException(ProfileProperty property, String message) { - super(String.format("Invalid value for: %s: %s", property.GetKey(), message)); - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignator.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignator.java deleted file mode 100644 index 1801e608..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignator.java +++ /dev/null @@ -1,77 +0,0 @@ -package at.asit.pdfover.pdfsignator; - -import java.util.HashMap; - -/** - * PDF Signator base Class - * This class should be extended to support PDF-AS and PADES. - */ -public abstract class PDFSignator { - - /** - * Map to store profiles - */ - protected HashMap<String, SignatureProfile> profiles = new HashMap<String, SignatureProfile>(); - - /** - * Perfom signature creation - * @param parameter The signature parameters - * @return The signing result - */ - public abstract SignResult Sign(SignParameter parameter); - - /** - * Creates new signing profile - * @param base The profile id of the base profile - * @param profileID The id of the new profile - * @return The new Profile - */ - public abstract SignatureProfile CreateNewProfile(String base, String profileID); - - /** - * Creates new signing profile - * @param base The base profile - * @param profileID The id of the new profile - * @return The new Profile - */ - public abstract SignatureProfile CreateNewProfile(SignatureProfile base, String profileID); - - /** - * Creates new signing profile - * @param profileID The id of the new profile - * @return The new Profile - */ - public abstract SignatureProfile CreateNewProfile(String profileID); - - /** - * Returns Profile object for given profile id - * @param profileID The profile id - * @return The requested Profile - */ - public SignatureProfile GetProfile(String profileID) { - if(this.profiles.containsKey(profileID)) { - // TODO: Think about handing out a copy of the profile to keep default values ... - return this.profiles.get(profileID); - } - - // TODO: throw Exception - return null; - } - - /** - * Get all available profiles - * @return Array containing all knwon profiles - */ - public SignatureProfile[] GetAvailableProfiles() { - // TODO: Think about handing out a copy of the profile to keep default values ... - return this.profiles.values().toArray(new SignatureProfile[0]); - } - - /** - * Gets all available profile ids - * @return Array containing all known profile ids - */ - public String[] GetAvailableProfileIDs() { - return this.profiles.keySet().toArray(new String[0]); - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignatureException.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignatureException.java new file mode 100644 index 00000000..78e66e01 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignatureException.java @@ -0,0 +1,14 @@ +package at.asit.pdfover.pdfsignator; + +/** + * base class for signature exceptions + * @author afitzek + */ +public class PDFSignatureException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 711578398780816710L; + +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignerInterface.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignerInterface.java new file mode 100644 index 00000000..e7ceeff6 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/PDFSignerInterface.java @@ -0,0 +1,38 @@ +package at.asit.pdfover.pdfsignator; + +import java.security.SignatureException; + +/** + * PDF Signator base Class + * This class should be extended to support PDF-AS and PADES. + * @author afitzek + */ +public interface PDFSignerInterface { + + /** + * Prepare a signature + * Defines signature parameters, the pdf library prepares the pdf document to sign and + * creates a Security Layer Request. + * @param parameter The signature parameters + * @return The siging state (contains the prepared document and the signature request + * @throws SignatureException + */ + public SigningState Prepare(SignatureParameter parameter) throws SignatureException; + + /** + * Adds the signature to the document. + * The SL Response has to be set in the state + * @param state The siging state + * @return The signature Result + * @throws SignatureException + */ + public SignResult Sign(SigningState state) throws SignatureException; + + /** + * Creates new signing profile + * @param base The profile id of the base profile + * @param profileID The id of the new profile + * @return The new Profile + */ + public SignatureParameter GetParameter(); +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignParameter.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignParameter.java deleted file mode 100644 index 3f0f2b6f..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignParameter.java +++ /dev/null @@ -1,118 +0,0 @@ -package at.asit.pdfover.pdfsignator; - -/** - * The Signature Parameter - */ -public class SignParameter { - - /** - * The Signature Position - * @uml.property name="signaturePosition" - * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" inverse="signParameter:at.asit.pdfover.pdfsignator.SignaturePosition" - */ - protected SignaturePosition signaturePosition = null; - - /** - * Getter of the property <tt>signaturePosition</tt> - * @return Returns the signaturePosition. - */ - public SignaturePosition GetSignaturePosition() { - return signaturePosition; - } - - /** - * Setter of the property <tt>signaturePosition</tt> - * @param signaturePosition The signaturePosition to set. - */ - public void SetSignaturePosition(SignaturePosition signaturePosition) { - this.signaturePosition = signaturePosition; - } - - /** - * The Signature Profile - * @uml.property name="signatureProfile" - * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" inverse="signParameter:at.asit.pdfover.pdfsignator.SignatureProfile" - */ - protected SignatureProfile signatureProfile = null; - - /** - * Getter of the property <tt>signatureProfile</tt> - * @return Returns the signatureProfile. - */ - public SignatureProfile GetSignatureProfile() { - return signatureProfile; - } - - /** - * Setter of the property <tt>signatureProfile</tt> - * @param signatureProfile The signatureProfile to set. - */ - public void SetSignatureProfile(SignatureProfile signatureProfile) { - this.signatureProfile = signatureProfile; - } - - /** - * The signature Device - */ - protected String signatureDevice = null; - - /** - * Getter of the property <tt>signatureDevice</tt> - * @return Returns the signatureDevice. - */ - public String GetSignatureDevice() { - return signatureDevice; - } - - /** - * Setter of the property <tt>signatureDevice</tt> - * @param value The signatureDevice to set. - */ - public void SetSignatureDevice(String value) { - this.signatureDevice = value; - } - - /** - * The signature Device - */ - protected String KeyIdentifier = null; - - /** - * Getter of the property <tt>KeyIdentifier</tt> - * @return Returns the KeyIdentifier. - */ - public String GetKeyIdentifier() { - return KeyIdentifier; - } - - /** - * Setter of the property <tt>KeyIdentifier</tt> - * @param value The KeyIdentifier to set. - */ - public void SetKeyIdentifier(String value) { - this.KeyIdentifier = value; - } - - /** - * The signature Device - * - * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" inverse="signParameter:at.asit.pdfover.pdfsignator.DocumentSource" - */ - protected DocumentSource documentSource = null; - - /** - * Getter of the property <tt>documentSource</tt> - * @return Returns the documentSource. - */ - public DocumentSource GetDocumentSource() { - return documentSource; - } - - /** - * Setter of the property <tt>documentSource</tt> - * @param value The documentSource to set. - */ - public void SetDocumentSource(DocumentSource value) { - this.documentSource = value; - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignResult.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignResult.java index 56d98952..847d9cd5 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignResult.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignResult.java @@ -2,70 +2,27 @@ package at.asit.pdfover.pdfsignator; import javax.security.cert.Certificate; -public class SignResult { - - /** - * The position of the signatur - * @uml.associationEnd multiplicity="(1 1)" aggregation="composite" inverse="signResult:at.asit.pdfover.pdfsignator.SignaturePosition" - */ - protected SignaturePosition signaturePosition = null; +/** + * Signature Result containing the signed document as document source + * @author afitzek + */ +public interface SignResult { /** * Getter of the property <tt>signaturePosition</tt> * @return Returns the signaturePosition. */ - public SignaturePosition GetSignaturePosition() { - return signaturePosition; - } - - /** - * Setter of the property <tt>signaturePosition</tt> - * @param signaturePosition The signaturePosition to set. - */ - public void SetSignaturePosition(SignaturePosition signaturePosition) { - this.signaturePosition = signaturePosition; - } - - /** - * The signed Document - * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" inverse="signResult:at.asit.pdfover.pdfsignator.DocumentSource" - */ - protected DocumentSource documentSource = null; - + public SignaturePosition GetSignaturePosition(); + /** * Gets the signed Document * @return Returns the documentSource. */ - public DocumentSource GetDocumentSource() { - return documentSource; - } + public DocumentSource GetSignedDocument(); /** - * Setter of the property <tt>documentSource</tt> - * @param documentSource The documentSource to set. - */ - public void SetDocumentSource(DocumentSource documentSource) { - this.documentSource = documentSource; - } - - /** - * The signer certificate - */ - protected Certificate signerCertificate; - - /** - * Sets the signer certificate - * @param cert The signer certificate - */ - public void SetSignerCertificate(Certificate cert) { - this.signerCertificate = cert; - } - - /** * Gets the signer certificate * @return The signer x509 certificate */ - public Certificate SetSignerCertificate() { - return this.signerCertificate; - } + public Certificate GetSignerCertificate(); } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureDimension.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureDimension.java index 133f4f74..5bff2da8 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureDimension.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureDimension.java @@ -2,6 +2,7 @@ package at.asit.pdfover.pdfsignator; /** * The Dimensions of the visible signature block + * @author afitzek */ public class SignatureDimension { diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureParameter.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureParameter.java new file mode 100644 index 00000000..e50b2751 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureParameter.java @@ -0,0 +1,106 @@ +package at.asit.pdfover.pdfsignator; + +/** + * The Signature Parameter + * @author afitzek + */ +public abstract class SignatureParameter { + + /** + * The Signature Position + * @uml.property name="signaturePosition" + * @uml.associationEnd + */ + protected SignaturePosition signaturePosition = null; + + /** + * Getter of the property <tt>signaturePosition</tt> + * @return Returns the signaturePosition. + */ + public SignaturePosition GetSignaturePosition() { + return signaturePosition; + } + + /** + * Setter of the property <tt>signaturePosition</tt> + * @param signaturePosition The signaturePosition to set. + */ + public void SetSignaturePosition(SignaturePosition signaturePosition) { + this.signaturePosition = signaturePosition; + } + + /** + * The signature Device + */ + protected String KeyIdentifier = null; + + /** + * Getter of the property <tt>KeyIdentifier</tt> + * @return Returns the KeyIdentifier. + */ + public String GetKeyIdentifier() { + return KeyIdentifier; + } + + /** + * Setter of the property <tt>KeyIdentifier</tt> + * @param value The KeyIdentifier to set. + */ + public void SetKeyIdentifier(String value) { + this.KeyIdentifier = value; + } + + /** + * The signature Device + * @uml.property name="documentSource" + * @uml.associationEnd + */ + protected DocumentSource documentSource = null; + + /** + * Getter of the property <tt>documentSource</tt> + * @return Returns the documentSource. + */ + public DocumentSource GetInputDocument() { + return documentSource; + } + + /** + * Setter of the property <tt>documentSource</tt> + * @param value The documentSource to set. + */ + public void SetInputDocument(DocumentSource value) { + this.documentSource = value; + } + + /** + * Gets the Dimension to display the Placeholder + * @return the placeholder dimensions + */ + public abstract SignatureDimension GetPlaceholderDimension(); + + /** + * holds the collimating mark + * @uml.property name="collimark" + * @uml.associationEnd + */ + protected CollimatingMark collimark; + + /** + * Gets the collimating mark + * @return + */ + public CollimatingMark GetCollimatingMark() { + return collimark; + } + + /** + * Sets the collimating mark + * @param value The new colimating mark + */ + public void SetCollimatingMark(CollimatingMark value) { + this.collimark = value; + } + + +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureProfile.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureProfile.java deleted file mode 100644 index 84c1023d..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SignatureProfile.java +++ /dev/null @@ -1,81 +0,0 @@ -package at.asit.pdfover.pdfsignator; - -import java.util.ArrayList; -import java.util.List; - -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; - -/** - * Represents a Signature profile - * @author afitzek - */ -public abstract class SignatureProfile { - - /** - * The profile ID - */ - protected String profileID; - - /** - * The Profile properties - * @uml.property name="profileProperty" - * @uml.associationEnd multiplicity="(0 -1)" ordering="true" aggregation="shared" inverse="signatureProfile:at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty" - * - */ - protected List<ProfileProperty> properties = new ArrayList<ProfileProperty>(); - - /** - * Gets the profile ID - * @return Returns the profileID. - */ - public String GetProfileID() { - return profileID; - } - - /** - * Adds a property to this profile - * @param property - */ - public void AddProperty(ProfileProperty property) { - - ProfileProperty replace = this.GetProperty(property.GetKey()); - - if(replace != null) - { - this.properties.remove(replace); - replace = null; - } - - this.properties.add(property); - } - - /** - * Gets a property by its key - * @param key The property key - * @return The ProfileProperty or null if not available - */ - public ProfileProperty GetProperty(String key) { - ProfileProperty find = null; - for(ProfileProperty available : this.properties) { - find = available; - if(find.GetKey().equals(key)) { - return find; - } - } - return null; - } - - /** - * Gets the Signature Dimension - * @return - */ - public abstract SignatureDimension GetSignatureDimension(); - - /** - * Gets available Properties for this Profile - * @return - */ - public ProfileProperty[] GetAvailableProperties() { - return this.properties.toArray(new ProfileProperty[0]); - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SigningState.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SigningState.java new file mode 100644 index 00000000..77479c12 --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/SigningState.java @@ -0,0 +1,26 @@ +package at.asit.pdfover.pdfsignator; + +/** + * The state of the pdf signing library + * @author afitzek + */ +public interface SigningState { + + /** + * Gets the prepared Document + * @return + */ + public DocumentSource GetPreparedDocument(); + + /** + * Gets the Security Layer Request to create the signature + * @return The SL Signature Request + */ + public String GetSLSignatureRequest(); + + /** + * Sets the Security Layer Request to create the signature + * @param value The SL Signature Request + */ + public void SetSLSignatureResponse(String value); +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/DateProfileProperty.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/DateProfileProperty.java deleted file mode 100644 index ac5df52a..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/DateProfileProperty.java +++ /dev/null @@ -1,36 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties; - -import java.util.Date; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; - -/** - * A Date Property - */ -public class DateProfileProperty extends ProfileProperty { - - /** - * Date value of property - */ - protected Date dvalue = null; - - /** - * Sets the date value of the Property - * @param value The date value - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - public void SetValue(Date value) throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.SetTextValue(value.toString()); - this.dvalue = value; - } - - /** - * Gets the date value - * @return the date value of the property - */ - public Date GetValue() { - return this.dvalue; - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/FileProfileProperty.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/FileProfileProperty.java deleted file mode 100644 index 46c5cd12..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/FileProfileProperty.java +++ /dev/null @@ -1,33 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties; - -import java.io.File; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; - -public class FileProfileProperty extends ProfileProperty { - - /** - * File value of property - */ - protected File fvalue = null; - - /** - * Sets the file value of the Property - * @param value The file value - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - public void SetValue(File value) throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.SetTextValue(value.getAbsolutePath()); - this.fvalue = value; - } - - /** - * Gets the file value - * @return the file value of the property - */ - public File GetValue() { - return this.fvalue; - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/FloatProfileProperty.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/FloatProfileProperty.java deleted file mode 100644 index 51c4089e..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/FloatProfileProperty.java +++ /dev/null @@ -1,30 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; - -public class FloatProfileProperty extends ProfileProperty { - /** - * Float value of property - */ - protected Float fvalue = null; - - /** - * Sets the float value of the Property - * @param value The float value - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - public void SetValue(float value) throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.SetTextValue(Float.toString(value)); - this.fvalue = value; - } - - /** - * Gets the float value - * @return the float value of the property - */ - public Float GetValue() { - return this.fvalue; - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/IntegerProfileProperty.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/IntegerProfileProperty.java deleted file mode 100644 index 7bb91226..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/IntegerProfileProperty.java +++ /dev/null @@ -1,31 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; - -public class IntegerProfileProperty extends ProfileProperty { - - /** - * Integer value of property - */ - protected Integer ivalue = null; - - /** - * Sets the integer value of the Property - * @param value The integer value - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - public void SetValue(int value) throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.SetTextValue(Integer.toString(value)); - this.ivalue = value; - } - - /** - * Gets the integer value - * @return the integer value of the property - */ - public Integer GetValue() { - return this.ivalue; - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/ProfileProperty.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/ProfileProperty.java deleted file mode 100644 index ebd247d6..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/ProfileProperty.java +++ /dev/null @@ -1,112 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; -import at.asit.pdfover.pdfsignator.profileproperties.validators.PropertyValidator; -import at.asit.pdfover.pdfsignator.profileproperties.validators.PropertyValidatorComparer; - -/** - * Defines a Profile Property - */ -public abstract class ProfileProperty { - - /** - * Is this property optional - */ - protected boolean optional; - - /** - * The value of the property - */ - private String value; - - /** - * The key of the property - */ - private String key; - - /** - * The list of PropertyValidator - * @uml.property name="propertyValidator" - * @uml.associationEnd multiplicity="(0 -1)" ordering="true" aggregation="shared" inverse="profileProperty:at.asit.pdfover.pdfsignator.profileproperties.validators.PropertyValidator" - */ - protected List<PropertyValidator> validators = new ArrayList<PropertyValidator>(); - - /** - * Validates the ProfileProperty - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - protected void Validate() throws InvalidPropertyValueException, InvalidPropertyTypeException { - for(PropertyValidator validator : validators) { - validator.validate(this); - } - } - - /** - * Adds a new PropertyValidator to this Property and sorts the validators according to their priority - * @param validator - * @throws InvalidPropertyTypeException - */ - public void AddValidator(PropertyValidator validator) throws InvalidPropertyTypeException { - validator.CheckPropertyType(this); - validators.add(validator); - Collections.sort(validators, new PropertyValidatorComparer()); - } - - /** - * Sets if the property is optional - * @param value The new optional value - */ - public void SetOptional(boolean value) { - this.optional = value; - } - - /** - * Gets if the Property is Optional - * @return Is the property optional - */ - public boolean GetOptional() { - return this.optional; - } - - /** - * Sets the string value of the property and validates the Property - * (All subclasses should set the value via this method!) - * @param value The new value - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - public void SetTextValue(String value) throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.value = value; - this.Validate(); - } - - /** - * Gets the property text value - * @return The property text value - */ - public String GetTextValue() { - return this.value; - } - - /** - * Sets the propety key - * @param value The new property key - */ - public void SetKey(String value) { - this.key = value; - } - - /** - * Gets the property Key - * @return The property key - */ - public String GetKey() { - return this.key; - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/StringProfileProperty.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/StringProfileProperty.java deleted file mode 100644 index 35d903af..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/StringProfileProperty.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; - -public class StringProfileProperty extends ProfileProperty { - /** - * Sets the string value of the Property - * @param value The string value - * @throws InvalidPropertyValueException - * @throws InvalidPropertyTypeException - */ - public void SetValue(String value) throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.SetTextValue(value); - } - - /** - * Gets the string value - * @return the string value of the property - */ - public String GetValue() { - return this.GetTextValue(); - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/FloatRangeValidator.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/FloatRangeValidator.java deleted file mode 100644 index 8cca9230..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/FloatRangeValidator.java +++ /dev/null @@ -1,57 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties.validators; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; -import at.asit.pdfover.pdfsignator.profileproperties.FloatProfileProperty; -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; - -public class FloatRangeValidator extends PropertyValidator { - - /** - * The maximum value - */ - protected float max; - - /** - * The minimum value - */ - protected float min; - - /** - * Constructor - * @param min The minimum allowed value - * @param max The maximum allowed value - */ - public FloatRangeValidator(float min, float max) { - this.max = max; - this.min = min; - } - - @Override - public void validate(ProfileProperty property) - throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.CheckPropertyType(property); - - FloatProfileProperty prop = (FloatProfileProperty) property; - - if (prop.GetValue() == null) { - throw new InvalidPropertyValueException(property, - "Value is not set!"); - } - - float value = prop.GetValue(); - - if (value < min || value > max) { - throw new InvalidPropertyValueException(property, String.format( - "Value has to be between %f and %f", min, max)); - } - } - - @Override - public void CheckPropertyType(ProfileProperty property) - throws InvalidPropertyTypeException { - if (!(property instanceof FloatProfileProperty)) { - throw new InvalidPropertyTypeException(property, this); - } - } -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/IntegerRangeValidator.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/IntegerRangeValidator.java deleted file mode 100644 index 504cb482..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/IntegerRangeValidator.java +++ /dev/null @@ -1,58 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties.validators; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; -import at.asit.pdfover.pdfsignator.profileproperties.IntegerProfileProperty; -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; - -public class IntegerRangeValidator extends PropertyValidator { - - /** - * Maximum value of property - */ - protected int max; - - /** - * Minimum value of property - */ - protected int min; - - /** - * Constructor - * @param min The minimum allowed value - * @param max The maximum allowed value - */ - public IntegerRangeValidator(int min, int max) { - this.max = max; - this.min = min; - } - - @Override - public void validate(ProfileProperty property) - throws InvalidPropertyValueException, InvalidPropertyTypeException { - this.CheckPropertyType(property); - - IntegerProfileProperty prop = (IntegerProfileProperty) property; - - if(prop.GetValue() == null) - { - throw new InvalidPropertyValueException(property, "Value is not set!"); - } - - int value = prop.GetValue(); - - if(value < min || value > max) { - throw new InvalidPropertyValueException(property, - String.format("Value has to be between %d and %d", min, max)); - } - } - - @Override - public void CheckPropertyType(ProfileProperty property) - throws InvalidPropertyTypeException { - if(!(property instanceof IntegerProfileProperty)) { - throw new InvalidPropertyTypeException(property, this); - } - } - -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/PropertyValidator.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/PropertyValidator.java deleted file mode 100644 index 8da9babc..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/PropertyValidator.java +++ /dev/null @@ -1,41 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties.validators; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; - -/** - * Validates the value of a property - */ -public abstract class PropertyValidator { - - /** - * The priority of this property should determine the order of validations - */ - protected int priority = 1; - - /** - * Called to validate the value of the given property and throws an InvalidPropertyValueException if value is invalid - * @param propety - * @throws InvalidPropertyValueException - */ - public abstract void validate(ProfileProperty property) throws InvalidPropertyValueException, InvalidPropertyTypeException; - - /** - * Sets the priority of this validator - * @param value The new priority - */ - public void SetPriority(int value) { - this.priority = value; - } - - /** - * Gets the priority of this validator - * @return The priority of this validator - */ - public int GetPriority() { - return this.priority; - } - - public abstract void CheckPropertyType(ProfileProperty property) throws InvalidPropertyTypeException; -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/PropertyValidatorComparer.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/PropertyValidatorComparer.java deleted file mode 100644 index 76c7f0e2..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/PropertyValidatorComparer.java +++ /dev/null @@ -1,16 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties.validators; - -import java.util.Comparator; - -/** - * Compares the Priority of two PropertyValidators - * @author afitzek - * - */ -public class PropertyValidatorComparer implements Comparator<PropertyValidator> { - - public int compare(PropertyValidator o1, PropertyValidator o2) { - return o1.GetPriority() - o2.GetPriority(); - } - -} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/RegExValidator.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/RegExValidator.java deleted file mode 100644 index 9ca8d113..00000000 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsignator/profileproperties/validators/RegExValidator.java +++ /dev/null @@ -1,37 +0,0 @@ -package at.asit.pdfover.pdfsignator.profileproperties.validators; - -import at.asit.pdfover.pdfsignator.InvalidPropertyTypeException; -import at.asit.pdfover.pdfsignator.InvalidPropertyValueException; -import at.asit.pdfover.pdfsignator.profileproperties.ProfileProperty; - -public class RegExValidator extends PropertyValidator { - - /** - * The regex value - */ - protected String regex; - - /** - * Constructor - * @param regex The regex to check - */ - public RegExValidator(String regex) { - this.regex = regex; - } - - @Override - public void validate(ProfileProperty property) - throws InvalidPropertyValueException, InvalidPropertyTypeException { - - if(!property.GetTextValue().matches(this.regex)) { - throw new InvalidPropertyValueException(property, String.format( - "Value is invalid!")); - } - } - - @Override - public void CheckPropertyType(ProfileProperty property) - throws InvalidPropertyTypeException { - // Is valid on all Property Types - } -} |