public ICredentials getCredentials( final ConnectionParameter connectionParameter )
{
// Checking if the bind principal is null or empty (no authentication)
if ( connectionParameter.getBindPrincipal() == null || "".equals( connectionParameter.getBindPrincipal() ) ) //$NON-NLS-1$
{
return new Credentials( "", "", connectionParameter ); //$NON-NLS-1$ //$NON-NLS-2$
}
else
{
// Checking of the connection passwords keystore is enabled
if ( PasswordsKeyStoreManagerUtils.isPasswordsKeystoreEnabled() )
{
// Getting the passwords keystore manager
PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
.getPasswordsKeyStoreManager();
// Checking if the keystore is not loaded
if ( !passwordsKeyStoreManager.isLoaded() )
{
// Asking the user to load the keystore
if ( !PasswordsKeyStoreManagerUtils.askUserToLoadKeystore() )
{
// The user failed to load the keystore and cancelled
return null;
}
}
// Getting the password
String password = passwordsKeyStoreManager.getConnectionPassword( connectionParameter.getId() );
// Checking if the bind password is available (the user chose to store the password)
if ( password != null
&& !"".equals( password ) ) //$NON-NLS-1$
{
return new Credentials( connectionParameter.getBindPrincipal(),
password, connectionParameter );
}
// The user chose NOT to store the password, we need to ask him
else
{
return askConnectionPassword( connectionParameter );
}
}
// Connection passwords keystore is NOT enabled
else
{
// Checking if the bind password is available (the user chose to store the password)
if ( connectionParameter.getBindPassword() != null
&& !"".equals( connectionParameter.getBindPassword() ) ) //$NON-NLS-1$
{
return new Credentials( connectionParameter.getBindPrincipal(),
connectionParameter.getBindPassword(), connectionParameter );
}
// The user chose NOT to store the password, we need to ask him
else
{