aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-08-20 10:59:37 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-08-20 10:59:37 +0000
commita95ebceaf0f77a25c26f866dff60faa6b388526c (patch)
tree306312ff46ede4feca7cc87721af1542bd4180ae /src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
parentc8481184208979098d9da7278ffd9f760a32ec9b (diff)
downloadpdf-as-3-a95ebceaf0f77a25c26f866dff60faa6b388526c.tar.gz
pdf-as-3-a95ebceaf0f77a25c26f866dff60faa6b388526c.tar.bz2
pdf-as-3-a95ebceaf0f77a25c26f866dff60faa6b388526c.zip
Internal error passed as RuntimeException instead of being ignored.
PdfAsFactory: Switch implemented that allows to skip provider registration. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@589 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java53
1 files changed, 49 insertions, 4 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java b/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
index 6ec16f1..ceaae85 100644
--- a/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
+++ b/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
@@ -9,6 +9,7 @@ import at.gv.egiz.pdfas.api.PdfAs;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.impl.api.PdfAsObject;
import at.knowcenter.wag.egov.egiz.PdfAS;
+import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
/**
* Main factory for creating a PDF-AS API Instance (PdfAs Interface).
@@ -24,7 +25,8 @@ public class PdfAsFactory
*
* @param workDirectory
* The work directory. If <code>null</code> the configuration is assumed to be located
- * within the user's home directory.
+ * within the user's home directory. Note: IAIK JCE and IAIK ECC security provders are
+ * automatically registered.
*
* @return Returns an instance of the PDF-AS API.
* @throws IllegalArgumentException
@@ -36,12 +38,35 @@ public class PdfAsFactory
*/
public static PdfAs createPdfAs(File workDirectory) throws PdfAsException
{
- return new PdfAsObject(workDirectory);
+ return createPdfAs(workDirectory, SettingsReader.REGISTER_IAIK_PROVIDERS_ON_DEFAULT);
+ }
+
+ /**
+ * Creates a PDF-AS API instance for the given work directory.
+ *
+ * @param workDirectory
+ * The work directory. If <code>null</code> the configuration is assumed to be located
+ * within the user's home directory.
+ *
+ * @param registerProvider <code>true</code>: automatically registers IAIK JCE and ECC Provider;
+ * <code>false</code>: providers will NOT be automatically registered, providers
+ * needed have to be registered by the API user
+ * @return Returns an instance of the PDF-AS API.
+ * @throws IllegalArgumentException
+ * Thrown, if the workDirectory doesn't exist.
+ * @throws PdfAsException
+ * Thrown, if the work directory does not meet its requirements, or
+ * if the config file is invalid.
+ * @see PdfAS#USERHOME_CONFIG_FOLDER
+ */
+ public static PdfAs createPdfAs(File workDirectory, boolean registerProvider) throws PdfAsException
+ {
+ return new PdfAsObject(workDirectory, registerProvider);
}
/**
* Creates a PDF-AS API instance assuming that the configuration is located within the user's
- * home directory.
+ * home directory. Note: IAIK JCE and IAIK ECC security providers are automatically registered.
*
* @return Returns an instance of the PDF-AS API.
* @throws IllegalArgumentException
@@ -53,7 +78,27 @@ public class PdfAsFactory
*/
public static PdfAs createPdfAs() throws PdfAsException
{
- return createPdfAs(null);
+ return createPdfAs(null);
+ }
+
+ /**
+ * Creates a PDF-AS API instance assuming that the configuration is located within the user's
+ * home directory.
+ *
+ * @return Returns an instance of the PDF-AS API.
+ * @param registerProvider <code>true</code>: automatically registers IAIK JCE and ECC Provider;
+ * <code>false</code>: providers will NOT be automatically registered, providers
+ * needed have to be registered by the API user
+ * @throws IllegalArgumentException
+ * Thrown, if the work directory doesn't exist within the user's home directory.
+ * @throws PdfAsException
+ * Thrown, if the work directory does not meet its requirements, or
+ * if the config file is invalid.
+ * @see PdfAS#USERHOME_CONFIG_FOLDER
+ */
+ public static PdfAs createPdfAs(boolean registerProvider) throws PdfAsException
+ {
+ return createPdfAs(null, registerProvider);
}
}