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:15:13 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-01-09 12:15:13 +0000
commit35963f5cb727db6b77962a0c58380b73c4e9d952 (patch)
tree72df7858fcf71a093a6a5a09c8f4d51b400a06b2 /src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java
parentae74d148749f8458e825083550c3fc8ed8a201da (diff)
downloadpdf-as-3-35963f5cb727db6b77962a0c58380b73c4e9d952.tar.gz
pdf-as-3-35963f5cb727db6b77962a0c58380b73c4e9d952.tar.bz2
pdf-as-3-35963f5cb727db6b77962a0c58380b73c4e9d952.zip
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@24 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.java119
1 files changed, 0 insertions, 119 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
deleted file mode 100644
index 3a5ec2d..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactory.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package at.knowcenter.wag.egov.egiz.ldap.client;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.apache.log4j.Logger;
-
-import at.knowcenter.wag.egov.egiz.tools.Normalize;
-
-
-/**
- * @author <a href="mailto:thomas.knall@iaik.tugraz.at">Thomas Knall</a>
- */
-public abstract class LDAPClientFactory {
-
- private final Logger log = Logger.getLogger(getClass());
-
- private static Hashtable<String, LDAPClientFactory> ldapClientFactoryInstances = new Hashtable<String, LDAPClientFactory>();
-
- protected static final String DEFAULT_IDENTIFIER = "DEFAULT_IDENTIFIER";
-
- private Hashtable<String, LDAPMapping> registeredMappings;
- private boolean hasBeenConfigured;
- private Normalize normalizer;
- private boolean whiteSpaceRemoval;
-
- protected LDAPClientFactory() {
- this.registeredMappings = new Hashtable<String, LDAPMapping>();
- this.hasBeenConfigured = false;
- this.normalizer = null;
- this.whiteSpaceRemoval = false;
- }
-
- public void resetMappings() {
- this.registeredMappings = new Hashtable<String, LDAPMapping>();
- this.hasBeenConfigured = false;
- }
-
- public boolean hasBeenConfigured() {
- return this.hasBeenConfigured;
- }
-
- public LDAPMapping getMapping(String issuerName) {
- return this.registeredMappings.get(applyFilter(issuerName));
- }
-
- protected Normalize getNormalizer() {
- return this.normalizer;
- }
-
- public synchronized void registerMappings(Iterable<LDAPMapping> iterable) {
- Iterator<LDAPMapping> it = iterable.iterator();
- if (!it.hasNext()) {
- log.warn("There were no ldap mappings provided.");
- } else {
- this.hasBeenConfigured = true;
- }
- while (it.hasNext()) {
- this.registerMapping(it.next());
- }
- }
-
- public synchronized void registerMapping(LDAPMapping... ldapMappings) {
- if (ldapMappings.length == 0) {
- log.warn("There were no ldap mappings provided.");
- } else {
- this.hasBeenConfigured = true;
- }
- for (LDAPMapping ldapMapping : ldapMappings) {
- log.debug("Registering Mapping for " + LDAPClientFactory.class.getSimpleName() + ": " + ldapMapping + ".");
- String issuerName = applyFilter(ldapMapping.getIssuerName().getName());
- if (this.registeredMappings.containsKey(issuerName)) {
- log.warn("Skipping mapping for issuer name \"" + issuerName + "\" because it has already been registered.");
- } else {
- this.registeredMappings.put(issuerName, ldapMapping);
- }
- }
- }
-
- public void setNormalizer(Normalize normalizer) throws LDAPException {
- if (this.hasBeenConfigured) {
- throw new LDAPException("It is not allowed to set a normalizer after mappings have been defined.");
- }
- this.normalizer = normalizer;
- }
-
- public void setWhiteSpaceRemoval(boolean whiteSpaceRemoval) throws LDAPException {
- if (this.hasBeenConfigured) {
- throw new LDAPException("It is not allowed to set whitespace removal after mappings have been defined.");
- }
- this.whiteSpaceRemoval = whiteSpaceRemoval;
- }
-
- private String applyFilter(String text) {
- if (this.normalizer != null) {
- text = this.normalizer.normalize(text);
- }
- if (this.whiteSpaceRemoval) {
- text = text.replaceAll("\\s", "");
- }
- return text;
- }
-
- 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;
-
-}