From a95ebceaf0f77a25c26f866dff60faa6b388526c Mon Sep 17 00:00:00 2001 From: tknall Date: Fri, 20 Aug 2010 10:59:37 +0000 Subject: 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 --- src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java | 53 ++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java') 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 null 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 null the configuration is assumed to be located + * within the user's home directory. + * + * @param registerProvider true: automatically registers IAIK JCE and ECC Provider; + * false: 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 true: automatically registers IAIK JCE and ECC Provider; + * false: 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); } } -- cgit v1.2.3