-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support the use of ciphertext passwords in yml.
feat: support the use of ciphertext passwords in yml.
- Loading branch information
Showing
7 changed files
with
76 additions
and
5 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
27 changes: 27 additions & 0 deletions
27
ngbatis-demo/src/main/java/ye/weicheng/ngbatis/demo/config/Base64PasswordDecoder.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,27 @@ | ||
package ye.weicheng.ngbatis.demo.config; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
import java.util.Base64; | ||
import org.nebula.contrib.ngbatis.PasswordDecoder; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* yml 明码解密器的组建示例,使用 Base64 的方式 | ||
* 如 yml 使用的是明文密码,则不需要这个 bean | ||
* | ||
* @author yeweicheng | ||
* @since 2024-05-23 7:39 | ||
* <br>Now is history! | ||
*/ | ||
@Component | ||
public class Base64PasswordDecoder implements PasswordDecoder { | ||
|
||
@Override | ||
public String decode(String password) { | ||
return new String(Base64.getDecoder().decode(password)); | ||
} | ||
|
||
} |
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
18 changes: 18 additions & 0 deletions
18
src/main/java/org/nebula/contrib/ngbatis/PasswordDecoder.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,18 @@ | ||
package org.nebula.contrib.ngbatis; | ||
|
||
// Copyright (c) 2024 All project authors. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
/** | ||
* 用于:从配置中得到的密码,可以解密获得明文密码 | ||
* | ||
* @author yeweicheng | ||
* @since 2024-05-23 7:31 | ||
* <br>Now is history! | ||
*/ | ||
public interface PasswordDecoder { | ||
|
||
String decode(String password); | ||
|
||
} |
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