diff options
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas')
-rw-r--r-- | src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java | 53 | ||||
-rw-r--r-- | src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java | 38 |
2 files changed, 84 insertions, 7 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);
}
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java index 2ccc1b7..e94acfd 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java @@ -81,6 +81,7 @@ public class PdfAsObject implements PdfAs /**
* This constructor is for internal use only - use
* {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
+ * Note: IAIK JCE and IAIK ECC security providers are automatically registered.
*
* @param workDirectory
* The work directory.
@@ -89,14 +90,32 @@ public class PdfAsObject implements PdfAs */
public PdfAsObject(File workDirectory) throws PdfAsException
{
- String path = workDirectory != null ? workDirectory.getPath() : null;
+ this(workDirectory, SettingsReader.REGISTER_IAIK_PROVIDERS_ON_DEFAULT);
+ }
+
+ /**
+ * This constructor is for internal use only - use
+ * {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
+ *
+ * @param workDirectory
+ * The work 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
+ * @throws PdfAsException
+ * Thrown, if the configuration cannot be processed.
+ */
+ public PdfAsObject(File workDirectory, boolean registerProvider) throws PdfAsException
+ {
+ String path = workDirectory != null ? workDirectory.getPath() : null;
SettingsReader.initialize(path, path);
- reloadConfig();
+ reloadConfig(registerProvider);
}
/**
* This constructor is for internal use only - use
* {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
+ * Note: IAIK JCE and IAIK ECC security providers are automatically registered.
*
* @throws PdfAsException
* Thrown, if the configuration cannot be processed.
@@ -112,7 +131,20 @@ public class PdfAsObject implements PdfAs public void reloadConfig() throws PdfAsException
{
ConfigUtils.initializeLogger();
- SettingsReader.createInstance();
+ SettingsReader.createInstance();
+ SignatureTypes.createInstance();
+ }
+
+ /**
+ * @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
+ * @see at.gv.egiz.pdfas.api.PdfAs#reloadConfig()
+ */
+ private void reloadConfig(boolean registerProvider) throws PdfAsException
+ {
+ ConfigUtils.initializeLogger();
+ SettingsReader.createInstance(registerProvider);
SignatureTypes.createInstance();
}
|