
io.prestosql.plugin.jdbc.credential.StaticCredentialProvider Maven / Gradle / Ivy
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.prestosql.plugin.jdbc.credential;
import io.prestosql.plugin.jdbc.JdbcIdentity;
import java.util.Optional;
import static java.util.Objects.requireNonNull;
public class StaticCredentialProvider
implements CredentialProvider
{
public static StaticCredentialProvider of(String user, String password)
{
return new StaticCredentialProvider(Optional.of(user), Optional.of(password));
}
private final Optional connectionUser;
private final Optional connectionPassword;
public StaticCredentialProvider(Optional user, Optional password)
{
this.connectionUser = requireNonNull(user, "user is null");
this.connectionPassword = requireNonNull(password, "password is null");
}
@Override
public Optional getConnectionUser(Optional jdbcIdentity)
{
return connectionUser;
}
@Override
public Optional getConnectionPassword(Optional jdbcIdentity)
{
return connectionPassword;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy