-
Notifications
You must be signed in to change notification settings - Fork 22
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 #8 from admin4j/dev
v0.9.5
- Loading branch information
Showing
90 changed files
with
3,225 additions
and
743 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
43 changes: 43 additions & 0 deletions
43
...mmon-spring-web/src/main/java/com/admin4j/common/config/UserContextAutoConfiguration.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,43 @@ | ||
package com.admin4j.common.config; | ||
|
||
import com.admin4j.common.constant.WebConstant; | ||
import com.admin4j.common.service.IUserContextHolder; | ||
import com.admin4j.common.service.impl.SimpleUserContextHolder; | ||
import com.admin4j.common.util.UserContextUtil; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.boot.autoconfigure.AutoConfigureOrder; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author andanyang | ||
* @since 2023/9/15 9:19 | ||
*/ | ||
@Configuration | ||
@AutoConfigureOrder(WebConstant.IUserContextHolderOrder + 6) | ||
public class UserContextAutoConfiguration implements InitializingBean, ApplicationContextAware { | ||
|
||
private ApplicationContext applicationContext; | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(IUserContextHolder.class) | ||
@ConditionalOnClass(name = "com.alibaba.ttl.TransmittableThreadLocal") | ||
public IUserContextHolder userContextHolder() { | ||
return new SimpleUserContextHolder(); | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
this.applicationContext = applicationContext; | ||
} | ||
|
||
@Override | ||
public void afterPropertiesSet() throws Exception { | ||
UserContextUtil.userContextHolder = applicationContext.getBean(IUserContextHolder.class); | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
admin4j-common-spring-web/src/main/java/com/admin4j/common/config/UserContextConfig.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
admin4j-common-spring-web/src/main/java/com/admin4j/common/constant/WebConstant.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,13 @@ | ||
package com.admin4j.common.constant; | ||
|
||
/** | ||
* @author andanyang | ||
* @since 2023/12/1 11:18 | ||
*/ | ||
public final class WebConstant { | ||
|
||
/** | ||
* IUserContextHolder 接口再spring中初始化顺序 | ||
*/ | ||
public static final int IUserContextHolderOrder = -1; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
admin4j-common-spring-web/src/main/resources/META-INF/spring.factories
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
com.admin4j.common.config.UserContextConfig | ||
com.admin4j.common.config.UserContextAutoConfiguration |
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
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
45 changes: 45 additions & 0 deletions
45
admin4j-common/src/test/java/com/admin4j/common/crypto/RSAUtilTest.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,45 @@ | ||
// package com.admin4j.common.crypto; | ||
// | ||
// import org.junit.Before; | ||
// import org.junit.Test; | ||
// | ||
// import java.security.NoSuchAlgorithmException; | ||
// import java.util.Base64; | ||
// | ||
// /** | ||
// * @author andanyang | ||
// * @since 2023/11/27 16:26 | ||
// */ | ||
// public class RSAUtilTest { | ||
// private static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqLh8XuAeLvjCly5hesbWtjanpgjVOwNGMPX8lx2937pdP48KlaacrW576lconObZahf60CuNohFTyZrRf9y770tXrC1NF2iDAxZpFjsZChlbftwmk94Okvq/9AkJxyprXZniLZ7fU9gI77sVsKx1wASpaAsLFwSu/y4pgsMa+hESr3r0mRZ1hoVSvKr53EbJfqgtoeeqRYzTZJzbpwKyPhrP2fEIG/9NGgiehp0vIzyFtKET9FcLZZzPi0nA6pVIohZUMS1t/qFdwWuebjBDqfH86ZapqUBYqhWBMr8xBI4vYYH3y02eJwYILpKMlJlEXH55C360+g+Zxg8A9mLZ9QIDAQAB"; | ||
// private static final String PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCouHxe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qpLvfnG7tiuZdAbzLs8PbRGirMNp1l/c6BqWhk6YRjYm6xKGQ2klQinu1SUV3zdTIpUniwtWLdxZf29Jw0P4AT8RcJC3dlrbtFhm+WxLHr1ZDA7VtyZrJjTka/fQZqrLR1FbzMBd2jpBPuv2oFtEM/NKwKBgArQTaXxo9ZPTU8Kr22v+7FE8OyOo5T7ThVfLKmnBVq4K6n/5emERWQ/CI25KEJjpDVYCHCGYM7jTr2kPXrElYt9V2NfJl4N4tlROwCYbKzhD+Fdso9JRA8acXl3W9xE7euzOchg1eMRFouoii6kXNbxfNGq+45GTgzjnvVYpPt5AoGAZ1fE7Dj+y5bhyIl0mQq7DV3Zeoi97E2h7a8Z2SAvQjgk9EPnU4oQLbOdSwsxVSC/jivfFY82tckMcirBxQjz8VAzFy/DNgnlWyN76WeCZgzgyTuOPnRjOCPvvPMWDApSzUY9UwxAY4eqvCaziRMFEMRI+M1Nr0+ICYGC0YuSvec="; | ||
// static RSAUtil.RSAKeyPair rsaKeyPair; | ||
// | ||
// @Before | ||
// public void init() throws NoSuchAlgorithmException { | ||
// rsaKeyPair = RSAUtil.generateKeyPair(2048); | ||
// System.out.println("getPublicKey = " + rsaKeyPair.getPublicKey()); | ||
// System.out.println("getPrivateKey = " + rsaKeyPair.getPrivateKey()); | ||
// } | ||
// | ||
// @Test | ||
// public void testEncrypt() { | ||
// | ||
// // RSAUtil. | ||
// String data = "bec36c76-d315-40bd-af6d-cf32feee49ae-221"; | ||
// byte[] keyBytes = PRIVATE_KEY.getBytes(); | ||
// | ||
// byte[] encrypt = RSAUtil.encrypt(data.getBytes(), RSAUtil.getPrivateKey(keyBytes)); | ||
// System.out.println("encrypt = " + Base64.getEncoder().encodeToString(encrypt)); | ||
// | ||
// // // // TODO TEST | ||
// // String decrypt = RSAUtil.decrypt(encrypt, PUBLIC_KEY); | ||
// // System.out.println("decrypt = " + decrypt); | ||
// // assert encrypt.equals(decrypt); | ||
// } | ||
// | ||
// public void testDecrypt() { | ||
// } | ||
// | ||
// | ||
// } |
Oops, something went wrong.