forked from r2dbc/r2dbc-spi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for dynamic credentials
Signed-off-by: Caleb Woy [email protected] [resolves r2dbc#273] Signed-off-by: calebcodesgud <[email protected]>
- Loading branch information
1 parent
55a6e10
commit de9c40a
Showing
5 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.r2dbc.spi; | ||
|
||
/** | ||
* Credentials used to authenticate with a database. Credential objects are | ||
* mutable. Mutability allows any security sensitive values retained by a | ||
* {@code Credential} to be cleared from memory. Drivers MUST NOT retain a | ||
* reference to a {@code Credential} object after consuming it for database | ||
* authentication. | ||
*/ | ||
interface Credential { | ||
} |
16 changes: 16 additions & 0 deletions
16
r2dbc-spi/src/main/java/io/r2dbc/spi/CredentialFactory.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,16 @@ | ||
package io.r2dbc.spi; | ||
|
||
/** Factory for creating {@link Credential} objects */ | ||
public class CredentialFactory { | ||
|
||
/** | ||
* Returns a new {@link UserPasswordCredential} | ||
* @param user Username. Not null. | ||
* @param password Password. Not null. | ||
*/ | ||
public static UserPasswordCredential createUserPasswordCredential( | ||
String user, CharSequence password) { | ||
return new UserPasswordCredentialImpl(user, password); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
r2dbc-spi/src/main/java/io/r2dbc/spi/UserPasswordCredential.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,9 @@ | ||
package io.r2dbc.spi; | ||
|
||
/** | ||
* UserPasswordCredentials used to authenticate with a database. | ||
*/ | ||
public interface UserPasswordCredential extends Credential { | ||
String user(); | ||
CharSequence password(); | ||
} |
23 changes: 23 additions & 0 deletions
23
r2dbc-spi/src/main/java/io/r2dbc/spi/UserPasswordCredentialImpl.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,23 @@ | ||
package io.r2dbc.spi; | ||
|
||
public class UserPasswordCredentialImpl implements UserPasswordCredential { | ||
|
||
private String user; | ||
|
||
private CharSequence password; | ||
|
||
UserPasswordCredentialImpl(String user, CharSequence password) { | ||
this.user = user; | ||
this.password = password; | ||
} | ||
|
||
@Override | ||
public String user() { | ||
return this.user; | ||
} | ||
|
||
@Override | ||
public CharSequence password() { | ||
return this.password; | ||
} | ||
} |