aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-01-09 12:16:27 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-01-09 12:16:27 +0000
commit5e1afa416ca3d38d6a9f4c77de8eec03fa11756f (patch)
tree71eb368182b471c3447c7dedaef75e39cc547b25 /src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java
parent35963f5cb727db6b77962a0c58380b73c4e9d952 (diff)
downloadpdf-as-3-5e1afa416ca3d38d6a9f4c77de8eec03fa11756f.tar.gz
pdf-as-3-5e1afa416ca3d38d6a9f4c77de8eec03fa11756f.tar.bz2
pdf-as-3-5e1afa416ca3d38d6a9f4c77de8eec03fa11756f.zip
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@25 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java
new file mode 100644
index 0000000..f8ce4f2
--- /dev/null
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java
@@ -0,0 +1,87 @@
+package at.knowcenter.wag.egov.egiz.ldap.client;
+
+import iaik.asn1.structures.Name;
+
+import java.util.Hashtable;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * @author <a href="mailto:thomas.knall@iaik.tugraz.at">Thomas Knall</a>
+ */
+public abstract class LDAPClientFactory {
+
+ private final Logger log = Logger.getLogger(getClass());
+
+ protected static final String DEFAULT_IDENTIFIER = "default LDAPClientFactory";
+
+ /**
+ * Mapping of category/identifier to LDAPClientFactory.
+ * Allows the usage of multiple independently configured LDAPClientFactoryImpls.
+ */
+ private static Hashtable<String, LDAPClientFactory> ldapClientFactoryInstances = new Hashtable<String, LDAPClientFactory>();
+
+ private LDAPMappingStore ldapMappingStore;
+
+ protected LDAPClientFactory() {
+ this.ldapMappingStore = new LDAPMappingStore();
+ }
+
+ public LDAPMapping getMapping(String issuerName) throws LDAPException {
+ return this.ldapMappingStore.getMapping(issuerName);
+ }
+
+ public LDAPMapping getMapping(Name name) {
+ return this.ldapMappingStore.getMapping(name);
+ }
+
+ public void resetMappings() {
+ this.ldapMappingStore.clearStore();
+ }
+
+ public boolean hasBeenConfigured() {
+ return !this.ldapMappingStore.isEmpty();
+ }
+
+ public synchronized void registerMappings(Iterable<LDAPMapping> iterable) {
+ if (!iterable.iterator().hasNext()) {
+ log.warn("There were no ldap mappings provided.");
+ }
+ this.ldapMappingStore.storeMappings(iterable);
+ }
+
+ public synchronized void registerMapping(LDAPMapping... ldapMappings) {
+ if (ldapMappings.length == 0) {
+ log.warn("There were no ldap mappings provided.");
+ }
+ this.ldapMappingStore.storeMapping(ldapMappings);
+ }
+
+ public void setLDAPIssuerNameFilter(LDAPIssuerNameFilter filter) throws LDAPException {
+ if (this.hasBeenConfigured()) {
+ throw new LDAPException("Not allowed to set filter after registration of mappings.");
+ }
+ this.ldapMappingStore = new LDAPMappingStore(filter);
+ }
+
+ public boolean isLDAPIssuerNameFilter() {
+ return this.ldapMappingStore.isLDAPIssuerNameFilter();
+ }
+
+ public static synchronized LDAPClientFactory getInstance(String idenfifier) {
+ LDAPClientFactory ldapClientFactoryInstance = ldapClientFactoryInstances.get(idenfifier);
+ if (ldapClientFactoryInstance == null) {
+ ldapClientFactoryInstance = new LDAPClientFactoryImpl();
+ ldapClientFactoryInstances.put(idenfifier, ldapClientFactoryInstance);
+ }
+ return ldapClientFactoryInstance;
+ }
+
+ public static synchronized LDAPClientFactory getInstance() {
+ return getInstance(DEFAULT_IDENTIFIER);
+ }
+
+ public abstract LDAPClient createClient(String issuerName) throws LDAPException;
+
+}