Search in sources :

Example 1 with DBAUserCredentialsProvider

use of org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider in project dbeaver by serge-rider.

the class AuthModelDatabaseNative method loadCredentials.

@NotNull
@Override
public CREDENTIALS loadCredentials(@NotNull DBPDataSourceContainer dataSource, @NotNull DBPConnectionConfiguration configuration) {
    CREDENTIALS credentials = createCredentials();
    DBPDataSourceProvider dataSourceProvider = dataSource.getDriver().getDataSourceProvider();
    if (dataSourceProvider instanceof DBAUserCredentialsProvider) {
        credentials.setUserName(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserName(configuration));
        credentials.setUserPassword(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserPassword(configuration));
    } else {
        credentials.setUserName(configuration.getUserName());
        credentials.setUserPassword(configuration.getUserPassword());
    }
    boolean allowsEmptyPassword = dataSource.getDriver().isAllowsEmptyPassword();
    if (credentials.getUserPassword() == null && allowsEmptyPassword) {
        credentials.setUserPassword("");
    }
    return credentials;
}
Also used : DBAUserCredentialsProvider(org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider) NotNull(org.jkiss.code.NotNull)

Example 2 with DBAUserCredentialsProvider

use of org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider in project dbeaver by dbeaver.

the class AuthModelDatabaseNative method loadCredentials.

@NotNull
@Override
public CREDENTIALS loadCredentials(@NotNull DBPDataSourceContainer dataSource, @NotNull DBPConnectionConfiguration configuration) {
    CREDENTIALS credentials = createCredentials();
    DBPDataSourceProvider dataSourceProvider = dataSource.getDriver().getDataSourceProvider();
    if (dataSourceProvider instanceof DBAUserCredentialsProvider) {
        credentials.setUserName(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserName(configuration));
        credentials.setUserPassword(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserPassword(configuration));
    } else {
        credentials.setUserName(configuration.getUserName());
        credentials.setUserPassword(configuration.getUserPassword());
    }
    boolean allowsEmptyPassword = dataSource.getDriver().isAllowsEmptyPassword();
    if (credentials.getUserPassword() == null && allowsEmptyPassword) {
        credentials.setUserPassword("");
    }
    return credentials;
}
Also used : DBAUserCredentialsProvider(org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider) NotNull(org.jkiss.code.NotNull)

Aggregations

NotNull (org.jkiss.code.NotNull)2 DBPDataSourceProvider (org.jkiss.dbeaver.model.DBPDataSourceProvider)2 DBAUserCredentialsProvider (org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider)2