From 94a9acedadf258689f58fce4296d5847404e368c Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Mon, 10 Jul 2006 11:48:35 +0000 Subject: [PATCH] Added checks to ensure object is properly initialized --- .../providers/ldap/LdapAuthenticationProvider.java | 6 ++++-- .../ldap/authenticator/AbstractLdapAuthenticator.java | 1 + .../ldap/populator/DefaultLdapAuthoritiesPopulator.java | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java index b01e05a502..b294a21dbf 100644 --- a/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java @@ -148,7 +148,8 @@ public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticatio this.authenticator = authenticator; } - public LdapAuthenticator getAuthenticator() { + protected LdapAuthenticator getAuthenticator() { + Assert.notNull(authenticator, "You must set the authenticator before using this instance."); return authenticator; } @@ -157,7 +158,8 @@ public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticatio this.authoritiesPopulator = authoritiesPopulator; } - public LdapAuthoritiesPopulator getAuthoritiesPopulator() { + protected LdapAuthoritiesPopulator getAuthoritiesPopulator() { + Assert.notNull(authoritiesPopulator, "You must set the authoritiesPopulator before using this instance."); return authoritiesPopulator; } diff --git a/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java b/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java index d5d888f516..8fca23fb03 100644 --- a/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java +++ b/core/src/main/java/org/acegisecurity/providers/ldap/authenticator/AbstractLdapAuthenticator.java @@ -111,6 +111,7 @@ public abstract class AbstractLdapAuthenticator implements LdapAuthenticator, In } public InitialDirContextFactory getInitialDirContextFactory() { + Assert.notNull(initialDirContextFactory, "You must set the initialDirContextFactory before using this instance."); return initialDirContextFactory; } diff --git a/core/src/main/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulator.java b/core/src/main/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulator.java index badf13314f..4138184d66 100644 --- a/core/src/main/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulator.java +++ b/core/src/main/java/org/acegisecurity/providers/ldap/populator/DefaultLdapAuthoritiesPopulator.java @@ -248,6 +248,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator } protected InitialDirContextFactory getInitialDirContextFactory() { + Assert.notNull(initialDirContextFactory, "You must set the initialDirContextFactory before using this instance."); return initialDirContextFactory; } @@ -280,6 +281,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator } protected String getGroupSearchBase() { + Assert.notNull(groupSearchBase, "You must set the groupSearchBase before using this instance."); return groupSearchBase; }