-
Notifications
You must be signed in to change notification settings - Fork 961
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from confluentinc/CC-29070
Add support for Custom Credentials Provider Class in JDBC connectors
- Loading branch information
Showing
15 changed files
with
539 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/io/confluent/connect/jdbc/util/BasicJdbcCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2018 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (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.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.connect.jdbc.util; | ||
|
||
public class BasicJdbcCredentials implements JdbcCredentials { | ||
|
||
String username; | ||
String password; | ||
|
||
public BasicJdbcCredentials(String user, String password) { | ||
this.username = user; | ||
this.password = password; | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
@Override | ||
public String getPassword() { | ||
return password; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/io/confluent/connect/jdbc/util/DefaultJdbcCredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2018 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (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.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.connect.jdbc.util; | ||
|
||
import java.util.Map; | ||
import org.apache.kafka.common.Configurable; | ||
|
||
public class DefaultJdbcCredentialsProvider implements JdbcCredentialsProvider, Configurable { | ||
|
||
private static final String DB_USERNAME_CONFIG = "connection.user"; | ||
private static final String DB_PASSWORD_CONFIG = "connection.password"; | ||
String username; | ||
String password; | ||
|
||
@Override | ||
public JdbcCredentials getJdbcCredentials() { | ||
return new BasicJdbcCredentials(username, password); | ||
} | ||
|
||
@Override | ||
public void configure(Map<String, ?> map) { | ||
username = (String) map.get(DB_USERNAME_CONFIG); | ||
password = (String) map.get(DB_PASSWORD_CONFIG); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/confluent/connect/jdbc/util/JdbcCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2018 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (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.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.connect.jdbc.util; | ||
|
||
public interface JdbcCredentials { | ||
|
||
/** | ||
* @return Username to use for authentication to database | ||
*/ | ||
String getUsername(); | ||
|
||
/** | ||
* | ||
* @return Password/Token to use for authentication to database | ||
*/ | ||
String getPassword(); | ||
|
||
} |
Oops, something went wrong.