-
Notifications
You must be signed in to change notification settings - Fork 102
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 #275 from xyoye/dev_4.2.0
Dev 4.2.0
- Loading branch information
Showing
18 changed files
with
511 additions
and
1 deletion.
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
Binary file not shown.
Binary file not shown.
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
26 changes: 26 additions & 0 deletions
26
common_component/src/main/java/com/xyoye/common_component/config/DevelopConfigTable.kt
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,26 @@ | ||
package com.xyoye.common_component.config | ||
|
||
import com.xyoye.mmkv_annotation.MMKVFiled | ||
import com.xyoye.mmkv_annotation.MMKVKotlinClass | ||
|
||
/** | ||
* author: [email protected] | ||
* time : 2025/1/22 | ||
* desc : 开发者配置表 | ||
*/ | ||
|
||
@MMKVKotlinClass(className = "DevelopConfig") | ||
object DevelopConfigTable { | ||
|
||
// AppId | ||
@MMKVFiled | ||
const val appId = "" | ||
|
||
// App Secret | ||
@MMKVFiled | ||
const val appSecret = "" | ||
|
||
// 是否已自动显示认证弹窗 | ||
@MMKVFiled | ||
const val isAutoShowAuthDialog = false | ||
} |
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
49 changes: 49 additions & 0 deletions
49
...rc/main/java/com/xyoye/common_component/network/helper/DeveloperCertificateInterceptor.kt
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,49 @@ | ||
package com.xyoye.common_component.network.helper | ||
|
||
import com.xyoye.common_component.config.DevelopConfig | ||
import com.xyoye.common_component.utils.SecurityHelper | ||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
|
||
/** | ||
* author: [email protected] | ||
* time : 2025/1/22 | ||
* desc : 开发者凭证拦截器 | ||
*/ | ||
class DeveloperCertificateInterceptor : Interceptor { | ||
companion object { | ||
const val HEADER_APP_ID = "X-AppId" | ||
const val HEADER_APP_SECRET = "X-AppSecret" | ||
} | ||
|
||
|
||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val oldRequest = chain.request() | ||
|
||
// 官方应用,不做处理 | ||
if (SecurityHelper.getInstance().isOfficialApplication) { | ||
return chain.proceed(oldRequest) | ||
} | ||
|
||
// 请求自带凭证,不做处理 | ||
val requestAppId = oldRequest.header(HEADER_APP_ID) | ||
val requestAppSecret = oldRequest.header(HEADER_APP_SECRET) | ||
if (requestAppId?.isNotEmpty() == true && requestAppSecret?.isNotEmpty() == true) { | ||
return chain.proceed(oldRequest) | ||
} | ||
|
||
// 未配置凭证,不做处理 | ||
val appId = DevelopConfig.getAppId() | ||
val appSecret = DevelopConfig.getAppSecret() | ||
if (appId.isNullOrEmpty() || appSecret.isNullOrEmpty()) { | ||
return chain.proceed(oldRequest) | ||
} | ||
|
||
// 添加凭证 | ||
return chain.proceed( | ||
oldRequest.newBuilder() | ||
.header(HEADER_APP_ID, appId) | ||
.header(HEADER_APP_SECRET, appSecret).build() | ||
) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...component/src/main/java/com/xyoye/common_component/network/helper/SignatureInterceptor.kt
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,29 @@ | ||
package com.xyoye.common_component.network.helper | ||
|
||
import com.xyoye.common_component.base.app.BaseApplication | ||
import com.xyoye.common_component.utils.SecurityHelper | ||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
|
||
|
||
/** | ||
* author: [email protected] | ||
* time : 2025/1/21 | ||
* desc : 签名验证拦截器 | ||
*/ | ||
class SignatureInterceptor : Interceptor { | ||
|
||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val oldRequest = chain.request() | ||
val newRequest = oldRequest.newBuilder() | ||
|
||
SecurityHelper.getInstance().getSignatureMap( | ||
oldRequest.url.encodedPath, | ||
BaseApplication.getAppContext() | ||
).forEach { | ||
newRequest.addHeader(it.key, it.value ?: "") | ||
} | ||
|
||
return chain.proceed(newRequest.build()) | ||
} | ||
} |
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
Oops, something went wrong.