|
@@ -23,7 +23,6 @@
|
|
package password.pwm.health;
|
|
package password.pwm.health;
|
|
|
|
|
|
import com.novell.ldapchai.ChaiEntry;
|
|
import com.novell.ldapchai.ChaiEntry;
|
|
-import com.novell.ldapchai.ChaiFactory;
|
|
|
|
import com.novell.ldapchai.ChaiUser;
|
|
import com.novell.ldapchai.ChaiUser;
|
|
import com.novell.ldapchai.exception.ChaiError;
|
|
import com.novell.ldapchai.exception.ChaiError;
|
|
import com.novell.ldapchai.exception.ChaiErrors;
|
|
import com.novell.ldapchai.exception.ChaiErrors;
|
|
@@ -31,7 +30,6 @@ import com.novell.ldapchai.exception.ChaiException;
|
|
import com.novell.ldapchai.exception.ChaiUnavailableException;
|
|
import com.novell.ldapchai.exception.ChaiUnavailableException;
|
|
import com.novell.ldapchai.provider.ChaiConfiguration;
|
|
import com.novell.ldapchai.provider.ChaiConfiguration;
|
|
import com.novell.ldapchai.provider.ChaiProvider;
|
|
import com.novell.ldapchai.provider.ChaiProvider;
|
|
-import com.novell.ldapchai.provider.ChaiProviderFactory;
|
|
|
|
import com.novell.ldapchai.provider.ChaiSetting;
|
|
import com.novell.ldapchai.provider.ChaiSetting;
|
|
import com.novell.ldapchai.provider.DirectoryVendor;
|
|
import com.novell.ldapchai.provider.DirectoryVendor;
|
|
import com.novell.ldapchai.util.ChaiUtility;
|
|
import com.novell.ldapchai.util.ChaiUtility;
|
|
@@ -101,7 +99,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
checkBasicLdapConnectivity(pwmApplication, config, entry.getValue(), true));
|
|
checkBasicLdapConnectivity(pwmApplication, config, entry.getValue(), true));
|
|
|
|
|
|
if (profileRecords.isEmpty()) {
|
|
if (profileRecords.isEmpty()) {
|
|
- profileRecords.addAll(checkLdapServerUrls(config, ldapProfiles.get(profileID)));
|
|
|
|
|
|
+ profileRecords.addAll(checkLdapServerUrls(pwmApplication, config, ldapProfiles.get(profileID)));
|
|
}
|
|
}
|
|
|
|
|
|
if (profileRecords.isEmpty()) {
|
|
if (profileRecords.isEmpty()) {
|
|
@@ -192,6 +190,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
try {
|
|
try {
|
|
|
|
|
|
chaiProvider = LdapOperationsHelper.createChaiProvider(
|
|
chaiProvider = LdapOperationsHelper.createChaiProvider(
|
|
|
|
+ pwmApplication,
|
|
SessionLabel.HEALTH_SESSION_LABEL,
|
|
SessionLabel.HEALTH_SESSION_LABEL,
|
|
ldapProfile,
|
|
ldapProfile,
|
|
config,
|
|
config,
|
|
@@ -199,7 +198,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
proxyUserPW
|
|
proxyUserPW
|
|
);
|
|
);
|
|
|
|
|
|
- theUser = ChaiFactory.createChaiUser(testUserDN, chaiProvider);
|
|
|
|
|
|
+ theUser = chaiProvider.getEntryFactory().newChaiUser(testUserDN);
|
|
|
|
|
|
} catch (ChaiUnavailableException e) {
|
|
} catch (ChaiUnavailableException e) {
|
|
returnRecords.add(HealthRecord.forMessage(HealthMessage.LDAP_TestUserUnavailable,
|
|
returnRecords.add(HealthRecord.forMessage(HealthMessage.LDAP_TestUserUnavailable,
|
|
@@ -353,7 +352,11 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public List<HealthRecord> checkLdapServerUrls(final Configuration config, final LdapProfile ldapProfile)
|
|
|
|
|
|
+ public List<HealthRecord> checkLdapServerUrls(
|
|
|
|
+ final PwmApplication pwmApplication,
|
|
|
|
+ final Configuration config,
|
|
|
|
+ final LdapProfile ldapProfile
|
|
|
|
+ )
|
|
{
|
|
{
|
|
final List<HealthRecord> returnRecords = new ArrayList<>();
|
|
final List<HealthRecord> returnRecords = new ArrayList<>();
|
|
final List<String> serverURLs = ldapProfile.readSettingAsStringArray(PwmSetting.LDAP_SERVER_URLS);
|
|
final List<String> serverURLs = ldapProfile.readSettingAsStringArray(PwmSetting.LDAP_SERVER_URLS);
|
|
@@ -362,6 +365,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
ChaiProvider chaiProvider = null;
|
|
ChaiProvider chaiProvider = null;
|
|
try {
|
|
try {
|
|
chaiProvider = LdapOperationsHelper.createChaiProvider(
|
|
chaiProvider = LdapOperationsHelper.createChaiProvider(
|
|
|
|
+ pwmApplication,
|
|
SessionLabel.HEALTH_SESSION_LABEL,
|
|
SessionLabel.HEALTH_SESSION_LABEL,
|
|
config,
|
|
config,
|
|
ldapProfile,
|
|
ldapProfile,
|
|
@@ -369,8 +373,8 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
proxyDN,
|
|
proxyDN,
|
|
ldapProfile.readSettingAsPassword(PwmSetting.LDAP_PROXY_USER_PASSWORD)
|
|
ldapProfile.readSettingAsPassword(PwmSetting.LDAP_PROXY_USER_PASSWORD)
|
|
);
|
|
);
|
|
- final ChaiUser proxyUser = ChaiFactory.createChaiUser(proxyDN, chaiProvider);
|
|
|
|
- proxyUser.isValid();
|
|
|
|
|
|
+ final ChaiUser proxyUser = chaiProvider.getEntryFactory().newChaiUser(proxyDN);
|
|
|
|
+ proxyUser.exists();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
final String errorString = "error connecting to ldap server '" + loopURL + "': " + e.getMessage();
|
|
final String errorString = "error connecting to ldap server '" + loopURL + "': " + e.getMessage();
|
|
returnRecords.add(new HealthRecord(
|
|
returnRecords.add(new HealthRecord(
|
|
@@ -406,9 +410,9 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
if (proxyPW == null) {
|
|
if (proxyPW == null) {
|
|
return Collections.singletonList(new HealthRecord(HealthStatus.WARN,HealthTopic.LDAP,"Missing Proxy User Password"));
|
|
return Collections.singletonList(new HealthRecord(HealthStatus.WARN,HealthTopic.LDAP,"Missing Proxy User Password"));
|
|
}
|
|
}
|
|
- chaiProvider = LdapOperationsHelper.createChaiProvider(SessionLabel.HEALTH_SESSION_LABEL,ldapProfile,config,proxyDN,proxyPW);
|
|
|
|
- final ChaiEntry adminEntry = ChaiFactory.createChaiEntry(proxyDN,chaiProvider);
|
|
|
|
- adminEntry.isValid();
|
|
|
|
|
|
+ chaiProvider = LdapOperationsHelper.createChaiProvider(pwmApplication, SessionLabel.HEALTH_SESSION_LABEL,ldapProfile,config,proxyDN,proxyPW);
|
|
|
|
+ final ChaiEntry adminEntry = chaiProvider.getEntryFactory().newChaiEntry(proxyDN);
|
|
|
|
+ adminEntry.exists();
|
|
directoryVendor = chaiProvider.getDirectoryVendor();
|
|
directoryVendor = chaiProvider.getDirectoryVendor();
|
|
} catch (ChaiException e) {
|
|
} catch (ChaiException e) {
|
|
final ChaiError chaiError = ChaiErrors.getErrorForMessage(e.getMessage());
|
|
final ChaiError chaiError = ChaiErrors.getErrorForMessage(e.getMessage());
|
|
@@ -447,7 +451,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
if (testContextlessRoot) {
|
|
if (testContextlessRoot) {
|
|
for (final String loopContext : ldapProfile.readSettingAsStringArray(PwmSetting.LDAP_CONTEXTLESS_ROOT)) {
|
|
for (final String loopContext : ldapProfile.readSettingAsStringArray(PwmSetting.LDAP_CONTEXTLESS_ROOT)) {
|
|
try {
|
|
try {
|
|
- final ChaiEntry contextEntry = ChaiFactory.createChaiEntry(loopContext,chaiProvider);
|
|
|
|
|
|
+ final ChaiEntry contextEntry = chaiProvider.getEntryFactory().newChaiEntry(loopContext);
|
|
final Set<String> objectClasses = contextEntry.readObjectClass();
|
|
final Set<String> objectClasses = contextEntry.readObjectClass();
|
|
|
|
|
|
if (objectClasses == null || objectClasses.isEmpty()) {
|
|
if (objectClasses == null || objectClasses.isEmpty()) {
|
|
@@ -549,7 +553,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
);
|
|
);
|
|
final Collection<ChaiConfiguration> replicaConfigs = ChaiUtility.splitConfigurationPerReplica(profileChaiConfiguration, Collections.<ChaiSetting,String>emptyMap());
|
|
final Collection<ChaiConfiguration> replicaConfigs = ChaiUtility.splitConfigurationPerReplica(profileChaiConfiguration, Collections.<ChaiSetting,String>emptyMap());
|
|
for (final ChaiConfiguration chaiConfiguration : replicaConfigs) {
|
|
for (final ChaiConfiguration chaiConfiguration : replicaConfigs) {
|
|
- final ChaiProvider loopProvider = ChaiProviderFactory.createProvider(chaiConfiguration);
|
|
|
|
|
|
+ final ChaiProvider loopProvider = pwmApplication.getLdapConnectionService().getChaiProviderFactory().newProvider(chaiConfiguration);
|
|
replicaVendorMap.put(chaiConfiguration.getSetting(ChaiSetting.BIND_URLS), loopProvider.getDirectoryVendor());
|
|
replicaVendorMap.put(chaiConfiguration.getSetting(ChaiSetting.BIND_URLS), loopProvider.getDirectoryVendor());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -614,7 +618,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
);
|
|
);
|
|
final Collection<ChaiConfiguration> replicaConfigs = ChaiUtility.splitConfigurationPerReplica(profileChaiConfiguration, Collections.<ChaiSetting,String>emptyMap());
|
|
final Collection<ChaiConfiguration> replicaConfigs = ChaiUtility.splitConfigurationPerReplica(profileChaiConfiguration, Collections.<ChaiSetting,String>emptyMap());
|
|
for (final ChaiConfiguration chaiConfiguration : replicaConfigs) {
|
|
for (final ChaiConfiguration chaiConfiguration : replicaConfigs) {
|
|
- final ChaiProvider loopProvider = ChaiProviderFactory.createProvider(chaiConfiguration);
|
|
|
|
|
|
+ final ChaiProvider loopProvider = pwmApplication.getLdapConnectionService().getChaiProviderFactory().newProvider(chaiConfiguration);
|
|
final ChaiEntry rootDSE = ChaiUtility.getRootDSE(loopProvider);
|
|
final ChaiEntry rootDSE = ChaiUtility.getRootDSE(loopProvider);
|
|
final Set<String> controls = rootDSE.readMultiStringAttribute("supportedControl");
|
|
final Set<String> controls = rootDSE.readMultiStringAttribute("supportedControl");
|
|
final boolean asnSupported = controls.contains(PwmConstants.LDAP_AD_PASSWORD_POLICY_CONTROL_ASN);
|
|
final boolean asnSupported = controls.contains(PwmConstants.LDAP_AD_PASSWORD_POLICY_CONTROL_ASN);
|
|
@@ -766,8 +770,8 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
final ChaiProvider chaiProvider = pwmApplication.getProxyChaiProvider(ldapProfileID);
|
|
final ChaiProvider chaiProvider = pwmApplication.getProxyChaiProvider(ldapProfileID);
|
|
try {
|
|
try {
|
|
if (!isExampleDN(dnValue)) {
|
|
if (!isExampleDN(dnValue)) {
|
|
- final ChaiEntry baseDNEntry = ChaiFactory.createChaiEntry(dnValue, chaiProvider);
|
|
|
|
- if (!baseDNEntry.isValid()) {
|
|
|
|
|
|
+ final ChaiEntry baseDNEntry = chaiProvider.getEntryFactory().newChaiEntry(dnValue);
|
|
|
|
+ if (!baseDNEntry.exists()) {
|
|
return "DN '" + dnValue + "' is invalid";
|
|
return "DN '" + dnValue + "' is invalid";
|
|
} else {
|
|
} else {
|
|
final String canonicalDN = baseDNEntry.readCanonicalDN();
|
|
final String canonicalDN = baseDNEntry.readCanonicalDN();
|
|
@@ -820,7 +824,7 @@ public class LDAPStatusChecker implements HealthChecker {
|
|
profileRecords.addAll(ldapStatusChecker.checkBasicLdapConnectivity(tempApplication, config, ldapProfile,
|
|
profileRecords.addAll(ldapStatusChecker.checkBasicLdapConnectivity(tempApplication, config, ldapProfile,
|
|
testContextless));
|
|
testContextless));
|
|
if (fullTest) {
|
|
if (fullTest) {
|
|
- profileRecords.addAll(ldapStatusChecker.checkLdapServerUrls(config, ldapProfile));
|
|
|
|
|
|
+ profileRecords.addAll(ldapStatusChecker.checkLdapServerUrls(pwmApplication, config, ldapProfile));
|
|
}
|
|
}
|
|
|
|
|
|
if (profileRecords.isEmpty()) {
|
|
if (profileRecords.isEmpty()) {
|