|
@@ -55,7 +55,6 @@ import password.pwm.ldap.UserInfo;
|
|
|
import password.pwm.ldap.UserInfoFactory;
|
|
|
import password.pwm.ldap.search.SearchConfiguration;
|
|
|
import password.pwm.util.PasswordData;
|
|
|
-import password.pwm.util.i18n.LocaleHelper;
|
|
|
import password.pwm.util.java.JavaHelper;
|
|
|
import password.pwm.util.java.StringUtil;
|
|
|
import password.pwm.util.java.TimeDuration;
|
|
@@ -85,7 +84,6 @@ import java.util.Set;
|
|
|
public class LDAPHealthChecker implements HealthChecker
|
|
|
{
|
|
|
private static final PwmLogger LOGGER = PwmLogger.forClass( LDAPHealthChecker.class );
|
|
|
- private static final String TOPIC = "LDAP";
|
|
|
|
|
|
@Override
|
|
|
public List<HealthRecord> doHealthCheck( final PwmApplication pwmApplication )
|
|
@@ -387,9 +385,9 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
}
|
|
|
catch ( final PwmUnrecoverableException e )
|
|
|
{
|
|
|
- returnRecords.add( new HealthRecord(
|
|
|
- HealthStatus.WARN,
|
|
|
- makeLdapTopic( ldapProfile, config ),
|
|
|
+ returnRecords.add( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_TestUserError,
|
|
|
+ PwmSetting.LDAP_TEST_USER_DN.toMenuLocationDebug( ldapProfile.getIdentifier(), PwmConstants.DEFAULT_LOCALE ),
|
|
|
"unable to read test user data: " + e.getMessage() ) );
|
|
|
return returnRecords;
|
|
|
}
|
|
@@ -444,9 +442,9 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
catch ( final Exception e )
|
|
|
{
|
|
|
final String errorString = "error connecting to ldap server '" + loopURL + "': " + e.getMessage();
|
|
|
- returnRecords.add( new HealthRecord(
|
|
|
- HealthStatus.WARN,
|
|
|
- makeLdapTopic( ldapProfile, config ),
|
|
|
+ returnRecords.add( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_No_Connection,
|
|
|
+ loopURL,
|
|
|
errorString ) );
|
|
|
}
|
|
|
finally
|
|
@@ -486,11 +484,19 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
final PasswordData proxyPW = ldapProfile.readSettingAsPassword( PwmSetting.LDAP_PROXY_USER_PASSWORD );
|
|
|
if ( proxyDN == null || proxyDN.length() < 1 )
|
|
|
{
|
|
|
- return Collections.singletonList( new HealthRecord( HealthStatus.WARN, HealthTopic.LDAP, "Missing Proxy User DN" ) );
|
|
|
+ final String menuLocationStr = PwmSetting.LDAP_PROXY_USER_DN.toMenuLocationDebug( ldapProfile.getIdentifier(), PwmConstants.DEFAULT_LOCALE );
|
|
|
+ return Collections.singletonList( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_No_Connection,
|
|
|
+ ldapProfile.getIdentifier(),
|
|
|
+ "Missing Proxy User DN: " + menuLocationStr ) );
|
|
|
}
|
|
|
if ( proxyPW == null )
|
|
|
{
|
|
|
- return Collections.singletonList( new HealthRecord( HealthStatus.WARN, HealthTopic.LDAP, "Missing Proxy User Password" ) );
|
|
|
+ final String menuLocationStr = PwmSetting.LDAP_PROXY_USER_PASSWORD.toMenuLocationDebug( ldapProfile.getIdentifier(), PwmConstants.DEFAULT_LOCALE );
|
|
|
+ return Collections.singletonList( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_No_Connection,
|
|
|
+ ldapProfile.getIdentifier(),
|
|
|
+ "Missing Proxy User Password: " + menuLocationStr ) );
|
|
|
}
|
|
|
chaiProvider = LdapOperationsHelper.createChaiProvider( pwmApplication, SessionLabel.HEALTH_SESSION_LABEL, ldapProfile, config, proxyDN, proxyPW );
|
|
|
final ChaiUser adminEntry = chaiProvider.getEntryFactory().newChaiUser( proxyDN );
|
|
@@ -533,10 +539,11 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
}
|
|
|
errorString.append( ")" );
|
|
|
}
|
|
|
- returnRecords.add( new HealthRecord(
|
|
|
- HealthStatus.WARN,
|
|
|
- makeLdapTopic( ldapProfile, config ),
|
|
|
+ returnRecords.add( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_No_Connection,
|
|
|
+ ldapProfile.getIdentifier(),
|
|
|
errorString.toString() ) );
|
|
|
+
|
|
|
pwmApplication.getLdapConnectionService().setLastLdapFailure( ldapProfile,
|
|
|
new ErrorInformation( PwmError.ERROR_DIRECTORY_UNAVAILABLE, errorString.toString() ) );
|
|
|
return returnRecords;
|
|
@@ -566,14 +573,24 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
|
|
|
if ( objectClasses == null || objectClasses.isEmpty() )
|
|
|
{
|
|
|
- final String errorString = "ldap context setting '" + loopContext + "' is not valid";
|
|
|
- returnRecords.add( new HealthRecord( HealthStatus.WARN, makeLdapTopic( ldapProfile, config ), errorString ) );
|
|
|
+ final String errorString = "ldap context setting '"
|
|
|
+ + PwmSetting.LDAP_CONTEXTLESS_ROOT.toMenuLocationDebug( ldapProfile.getIdentifier(), PwmConstants.DEFAULT_LOCALE )
|
|
|
+ + "' value '" + loopContext + "' is not valid";
|
|
|
+ returnRecords.add( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_No_Connection,
|
|
|
+ ldapProfile.getIdentifier(),
|
|
|
+ errorString ) );
|
|
|
}
|
|
|
}
|
|
|
catch ( final Exception e )
|
|
|
{
|
|
|
- final String errorString = "ldap root context '" + loopContext + "' is not valid: " + e.getMessage();
|
|
|
- returnRecords.add( new HealthRecord( HealthStatus.WARN, makeLdapTopic( ldapProfile, config ), errorString ) );
|
|
|
+ final String errorString = "ldap context setting '"
|
|
|
+ + PwmSetting.LDAP_CONTEXTLESS_ROOT.toMenuLocationDebug( ldapProfile.getIdentifier(), PwmConstants.DEFAULT_LOCALE )
|
|
|
+ + "' value '" + loopContext + "' is not valid: " + e.getMessage();
|
|
|
+ returnRecords.add( HealthRecord.forMessage(
|
|
|
+ HealthMessage.LDAP_No_Connection,
|
|
|
+ ldapProfile.getIdentifier(),
|
|
|
+ errorString ) );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -650,26 +667,6 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private static String makeLdapTopic(
|
|
|
- final LdapProfile ldapProfile,
|
|
|
- final Configuration configuration
|
|
|
- )
|
|
|
- {
|
|
|
- return makeLdapTopic( ldapProfile.getIdentifier(), configuration );
|
|
|
- }
|
|
|
-
|
|
|
- private static String makeLdapTopic(
|
|
|
- final String profileID,
|
|
|
- final Configuration configuration
|
|
|
- )
|
|
|
- {
|
|
|
- if ( configuration.getLdapProfiles().isEmpty() || configuration.getLdapProfiles().size() < 2 )
|
|
|
- {
|
|
|
- return TOPIC;
|
|
|
- }
|
|
|
- return TOPIC + "-" + profileID;
|
|
|
- }
|
|
|
-
|
|
|
private List<HealthRecord> checkVendorSameness( final PwmApplication pwmApplication )
|
|
|
{
|
|
|
final Map<HealthMonitor.HealthMonitorFlag, Serializable> healthProperties = pwmApplication.getHealthMonitor().getHealthProperties();
|
|
@@ -916,7 +913,7 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
HealthRecord.forMessage(
|
|
|
HealthMessage.NewUser_PwTemplateBad,
|
|
|
PwmSetting.NEWUSER_PASSWORD_POLICY_USER.toMenuLocationDebug( newUserProfile.getIdentifier(), locale ),
|
|
|
- LocaleHelper.valueNotApplicable( locale )
|
|
|
+ "Value missing"
|
|
|
)
|
|
|
);
|
|
|
}
|
|
@@ -944,7 +941,8 @@ public class LDAPHealthChecker implements HealthChecker
|
|
|
return Collections.singletonList(
|
|
|
HealthRecord.forMessage(
|
|
|
HealthMessage.NewUser_PwTemplateBad,
|
|
|
- PwmSetting.NEWUSER_PASSWORD_POLICY_USER.toMenuLocationDebug( newUserProfile.getIdentifier(), locale )
|
|
|
+ PwmSetting.NEWUSER_PASSWORD_POLICY_USER.toMenuLocationDebug( newUserProfile.getIdentifier(), locale ),
|
|
|
+ "userDN value is not valid"
|
|
|
)
|
|
|
);
|
|
|
}
|